From 1be8537dafe52e47cba265a4288c3844a7821f5c Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 25 Oct 2024 15:26:27 +1100 Subject: [PATCH] finality: refactor voting power table and APIs (#222) Second half of #24 This PR moves the voting power table/cache and relevant APIs to `x/finality`. This includes the following - [x] move voting power table KV store to `x/finality` - [x] move voting power dist cache to `x/finality` - [x] move 4 APIs `ActiveFinalityProvidersAtHeight`, `FinalityProviderPowerAtHeight`, `FinalityProviderCurrentPower`, `ActivatedHeight` to `x/finality` - [x] fix fuzz tests - [x] fix e2e tests - [x] fix doc - [x] fix changelog Note that this affects many LoCs since it touches a bunch of proto files. The actual modification is much smaller than it looks like. --- CHANGELOG.md | 3 +- client/query/btcstaking.go | 45 - client/query/finality.go | 45 + proto/babylon/btcstaking/v1/genesis.proto | 25 - proto/babylon/btcstaking/v1/incentive.proto | 62 - proto/babylon/btcstaking/v1/query.proto | 111 +- proto/babylon/finality/v1/finality.proto | 56 + proto/babylon/finality/v1/genesis.proto | 23 + proto/babylon/finality/v1/query.proto | 108 +- test/e2e/btc_staking_e2e_test.go | 9 +- test/e2e/btc_staking_pre_approval_e2e_test.go | 9 +- .../configurer/chain/queries_btcstaking.go | 11 +- testutil/datagen/incentive.go | 14 +- x/btcstaking/README.md | 325 +- x/btcstaking/client/cli/query.go | 97 - x/btcstaking/keeper/genesis.go | 64 - x/btcstaking/keeper/genesis_test.go | 16 - x/btcstaking/keeper/grpc_query.go | 120 +- x/btcstaking/keeper/grpc_query_test.go | 453 +- x/btcstaking/keeper/incentive.go | 40 - .../keeper/voting_power_table_test.go | 165 - x/btcstaking/types/btcstaking.go | 35 - x/btcstaking/types/errors.go | 50 +- x/btcstaking/types/genesis.pb.go | 677 +- x/btcstaking/types/incentive.pb.go | 1238 ---- x/btcstaking/types/incentive_test.go | 189 - x/btcstaking/types/keys.go | 16 +- x/btcstaking/types/query.go | 5 +- x/btcstaking/types/query.pb.go | 5665 +++++----------- x/btcstaking/types/query.pb.gw.go | 408 -- x/finality/README.md | 78 +- x/finality/client/cli/query.go | 116 +- x/finality/keeper/genesis.go | 63 + x/finality/keeper/genesis_test.go | 20 + x/finality/keeper/grpc_query.go | 115 +- x/finality/keeper/grpc_query_test.go | 219 + x/finality/keeper/keeper.go | 2 +- x/finality/keeper/liveness.go | 2 +- x/finality/keeper/msg_server.go | 2 +- x/finality/keeper/msg_server_test.go | 18 +- x/finality/keeper/power_dist_change.go | 56 +- x/finality/keeper/power_dist_change_test.go | 39 +- .../keeper/power_table.go} | 34 +- x/finality/keeper/power_table_test.go | 171 +- x/finality/keeper/tallying.go | 8 +- x/finality/keeper/tallying_bench_test.go | 6 +- x/finality/keeper/tallying_test.go | 96 +- x/finality/keeper/votes_bench_test.go | 2 - x/finality/types/errors.go | 4 +- x/finality/types/expected_keepers.go | 9 +- x/finality/types/finality.pb.go | 1188 +++- x/finality/types/genesis.pb.go | 687 +- x/finality/types/keys.go | 2 + x/finality/types/mocked_keepers.go | 161 +- .../types/power_table.go} | 41 +- .../types/power_table_test.go} | 182 +- x/finality/types/query.pb.go | 5831 +++++++++++------ x/finality/types/query.pb.gw.go | 408 ++ x/incentive/keeper/btc_staking_gauge.go | 4 +- 59 files changed, 9578 insertions(+), 10070 deletions(-) delete mode 100644 proto/babylon/btcstaking/v1/incentive.proto delete mode 100644 x/btcstaking/keeper/incentive.go delete mode 100644 x/btcstaking/keeper/voting_power_table_test.go delete mode 100644 x/btcstaking/types/incentive.pb.go delete mode 100644 x/btcstaking/types/incentive_test.go rename x/{btcstaking/keeper/voting_power_table.go => finality/keeper/power_table.go} (82%) rename x/{btcstaking/types/incentive.go => finality/types/power_table.go} (82%) rename x/{btcstaking/types/btcstaking_test.go => finality/types/power_table_test.go} (60%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 963055e79..841eb0de4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,8 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### State Machine Breaking * [#224](https://github.com/babylonlabs-io/babylon/pull/224) Make injected checkpoint a standard tx -* [#216](https://github.com/babylonlabs-io/babylon/pull/216) move voting power distribution -update algorithm to `x/finality` +* [#217](https://github.com/babylonlabs-io/babylon/pull/217) Move voting power table to finality module * [#207](https://github.com/babylonlabs-io/babylon/pull/207) Rename total voting power to total bonded sat * [#204](https://github.com/babylonlabs-io/babylon/pull/204) Add babylon finality diff --git a/client/query/btcstaking.go b/client/query/btcstaking.go index 04250fd3d..1f10e3262 100644 --- a/client/query/btcstaking.go +++ b/client/query/btcstaking.go @@ -121,48 +121,3 @@ func (c *QueryClient) BTCDelegation(stakingTxHashHex string) (*btcstakingtypes.Q return resp, err } - -// ActiveFinalityProvidersAtHeight queries the BTCStaking module for all finality providers -// with non-zero voting power at a given height -func (c *QueryClient) ActiveFinalityProvidersAtHeight(height uint64, pagination *sdkquerytypes.PageRequest) (*btcstakingtypes.QueryActiveFinalityProvidersAtHeightResponse, error) { - var resp *btcstakingtypes.QueryActiveFinalityProvidersAtHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryActiveFinalityProvidersAtHeightRequest{ - Height: height, - Pagination: pagination, - } - resp, err = queryClient.ActiveFinalityProvidersAtHeight(ctx, req) - return err - }) - - return resp, err -} - -// FinalityProviderPowerAtHeight queries the BTCStaking module for the power of a finality provider at a given height -func (c *QueryClient) FinalityProviderPowerAtHeight(fpBtcPkHex string, height uint64) (*btcstakingtypes.QueryFinalityProviderPowerAtHeightResponse, error) { - var resp *btcstakingtypes.QueryFinalityProviderPowerAtHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fpBtcPkHex, - Height: height, - } - resp, err = queryClient.FinalityProviderPowerAtHeight(ctx, req) - return err - }) - - return resp, err -} - -func (c *QueryClient) ActivatedHeight() (*btcstakingtypes.QueryActivatedHeightResponse, error) { - var resp *btcstakingtypes.QueryActivatedHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryActivatedHeightRequest{} - resp, err = queryClient.ActivatedHeight(ctx, req) - return err - }) - - return resp, err -} diff --git a/client/query/finality.go b/client/query/finality.go index 2db05d281..504abeab4 100644 --- a/client/query/finality.go +++ b/client/query/finality.go @@ -19,6 +19,51 @@ func (c *QueryClient) QueryFinality(f func(ctx context.Context, queryClient fina return f(ctx, queryClient) } +// ActiveFinalityProvidersAtHeight queries the BTCStaking module for all finality providers +// with non-zero voting power at a given height +func (c *QueryClient) ActiveFinalityProvidersAtHeight(height uint64, pagination *sdkquerytypes.PageRequest) (*finalitytypes.QueryActiveFinalityProvidersAtHeightResponse, error) { + var resp *finalitytypes.QueryActiveFinalityProvidersAtHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryActiveFinalityProvidersAtHeightRequest{ + Height: height, + Pagination: pagination, + } + resp, err = queryClient.ActiveFinalityProvidersAtHeight(ctx, req) + return err + }) + + return resp, err +} + +// FinalityProviderPowerAtHeight queries the BTCStaking module for the power of a finality provider at a given height +func (c *QueryClient) FinalityProviderPowerAtHeight(fpBtcPkHex string, height uint64) (*finalitytypes.QueryFinalityProviderPowerAtHeightResponse, error) { + var resp *finalitytypes.QueryFinalityProviderPowerAtHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fpBtcPkHex, + Height: height, + } + resp, err = queryClient.FinalityProviderPowerAtHeight(ctx, req) + return err + }) + + return resp, err +} + +func (c *QueryClient) ActivatedHeight() (*finalitytypes.QueryActivatedHeightResponse, error) { + var resp *finalitytypes.QueryActivatedHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryActivatedHeightRequest{} + resp, err = queryClient.ActivatedHeight(ctx, req) + return err + }) + + return resp, err +} + // FinalityParams queries the finality module parameters func (c *QueryClient) FinalityParams() (*finalitytypes.Params, error) { var resp *finalitytypes.QueryParamsResponse diff --git a/proto/babylon/btcstaking/v1/genesis.proto b/proto/babylon/btcstaking/v1/genesis.proto index 203122d0b..c87c54d75 100644 --- a/proto/babylon/btcstaking/v1/genesis.proto +++ b/proto/babylon/btcstaking/v1/genesis.proto @@ -4,7 +4,6 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "babylon/btcstaking/v1/params.proto"; import "babylon/btcstaking/v1/btcstaking.proto"; -import "babylon/btcstaking/v1/incentive.proto"; import "babylon/btcstaking/v1/events.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; @@ -17,36 +16,12 @@ message GenesisState { repeated FinalityProvider finality_providers = 2; // btc_delegations all the btc delegations in the state. repeated BTCDelegation btc_delegations = 3; - // voting_powers the voting power of every finality provider at every block height. - repeated VotingPowerFP voting_powers = 4; // block_height_chains the block height of babylon and bitcoin. repeated BlockHeightBbnToBtc block_height_chains = 5; // btc_delegators contains all the btc delegators with the associated finality provider. repeated BTCDelegator btc_delegators = 6; // all the events and its indexes. repeated EventIndex events = 7; - // vp_dst_cache is the table of all providers voting power with the total at one specific block. - // TODO: remove this after not storing in the keeper store it anymore. - repeated VotingPowerDistCacheBlkHeight vp_dst_cache = 8; -} - -// VotingPowerFP contains the information about the voting power -// of an finality provider in a specific block height. -message VotingPowerFP { - // block_height is the height of the block the voting power was stored. - uint64 block_height = 1; - // fp_btc_pk the finality provider btc public key. - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // voting_power is the power of the finality provider at this specific block height. - uint64 voting_power = 3; -} - -// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height -message VotingPowerDistCacheBlkHeight { - // block_height is the height of the block the voting power distribution cached was stored. - uint64 block_height = 1; - // vp_distribution the finality providers distribution cache at that height. - VotingPowerDistCache vp_distribution = 2; } // BlockHeightBbnToBtc stores the btc <-> bbn block. diff --git a/proto/babylon/btcstaking/v1/incentive.proto b/proto/babylon/btcstaking/v1/incentive.proto deleted file mode 100644 index 3671d874c..000000000 --- a/proto/babylon/btcstaking/v1/incentive.proto +++ /dev/null @@ -1,62 +0,0 @@ -syntax = "proto3"; -package babylon.btcstaking.v1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; - -option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; - -// VotingPowerDistCache is the cache for voting power distribution of finality providers -// and their BTC delegations at a height -message VotingPowerDistCache { - option (gogoproto.goproto_getters) = false; - // total_sat is the total amount of bonded BTC stake (in Satoshi) of all the finality providers - // in the cache - uint64 total_bonded_sat = 1; - // finality_providers is a list of finality providers' voting power information - repeated FinalityProviderDistInfo finality_providers = 2; - // num_active_fps is the number of finality providers that have active BTC - // delegations as well as timestamped public randomness - uint32 num_active_fps = 3; -} - -// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations -message FinalityProviderDistInfo { - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // addr is the address to receive commission from delegations. - string addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // commission defines the commission rate of finality provider - string commission = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" - ]; - // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider - uint64 total_bonded_sat = 4; - // btc_dels is a list of BTC delegations' voting power information under this finality provider - repeated BTCDelDistInfo btc_dels = 5; - // is_timestamped indicates whether the finality provider - // has timestamped public randomness committed - // if no, it should not be assigned voting power - bool is_timestamped = 6; - // is_jailed indicates whether the finality provider - // is jailed, if so, it should not be assigned voting power - bool is_jailed = 7; - // is_slashed indicates whether the finality provider - // is slashed, if so, it should not be assigned voting power - bool is_slashed = 8; -} - -// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation -message BTCDelDistInfo { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // staker_addr is the address to receive rewards from BTC delegation. - string staker_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // staking_tx_hash is the staking tx hash of the BTC delegation - string staking_tx_hash = 3; - // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation - uint64 total_sat = 4; -} diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index 9442a1fef..896cf5b16 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -38,27 +38,6 @@ service Query { option (google.api.http).get = "/babylon/btcstaking/v1/btc_delegations/{status}"; } - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - rpc ActiveFinalityProvidersAtHeight(QueryActiveFinalityProvidersAtHeightRequest) returns (QueryActiveFinalityProvidersAtHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{height}"; - } - - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - rpc FinalityProviderPowerAtHeight(QueryFinalityProviderPowerAtHeightRequest) returns (QueryFinalityProviderPowerAtHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power/{height}"; - } - - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - rpc FinalityProviderCurrentPower(QueryFinalityProviderCurrentPowerRequest) returns (QueryFinalityProviderCurrentPowerResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power"; - } - - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - rpc ActivatedHeight(QueryActivatedHeightRequest) returns (QueryActivatedHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/activated_height"; - } - // FinalityProviderDelegations queries all BTC delegations of the given finality provider rpc FinalityProviderDelegations(QueryFinalityProviderDelegationsRequest) returns (QueryFinalityProviderDelegationsResponse) { option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/delegations"; @@ -140,92 +119,6 @@ message QueryBTCDelegationsResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// QueryFinalityProviderPowerAtHeightRequest is the request type for the -// Query/FinalityProviderPowerAtHeight RPC method. -message QueryFinalityProviderPowerAtHeightRequest { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - string fp_btc_pk_hex = 1; - - // height is used for querying the given finality provider's voting power at this height - uint64 height = 2; -} - -// QueryFinalityProviderPowerAtHeightResponse is the response type for the -// Query/FinalityProviderPowerAtHeight RPC method. -message QueryFinalityProviderPowerAtHeightResponse { - // voting_power is the voting power of the finality provider - uint64 voting_power = 1; -} - -// QueryFinalityProviderCurrentPowerRequest is the request type for the -// Query/FinalityProviderCurrentPower RPC method. -message QueryFinalityProviderCurrentPowerRequest { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - string fp_btc_pk_hex = 1; -} - -// QueryFinalityProviderCurrentPowerResponse is the response type for the -// Query/FinalityProviderCurrentPower RPC method. -message QueryFinalityProviderCurrentPowerResponse { - // height is the current height - uint64 height = 1; - // voting_power is the voting power of the finality provider - uint64 voting_power = 2; -} - -// QueryActiveFinalityProvidersAtHeightRequest is the request type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -message QueryActiveFinalityProvidersAtHeightRequest { - // height defines at which Babylon height to query the finality providers info. - uint64 height = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. -message ActiveFinalityProvidersAtHeightResponse { - // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider - // the PK follows encoding in BIP-340 spec - string btc_pk_hex = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // height is the queried Babylon height - uint64 height = 2; - // voting_power is the voting power of this finality provider at the given height - uint64 voting_power = 3; - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint64 slashed_babylon_height = 4; - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint32 slashed_btc_height = 5; - // jailed defines whether the finality provider is detected jailed - bool jailed = 6; -} - -// QueryActiveFinalityProvidersAtHeightResponse is the response type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -message QueryActiveFinalityProvidersAtHeightResponse { - // finality_providers contains all the queried finality providersn. - repeated ActiveFinalityProvidersAtHeightResponse finality_providers = 1; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. -message QueryActivatedHeightRequest {} - -// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. -message QueryActivatedHeightResponse { - uint64 height = 1; -} - // QueryFinalityProviderDelegationsRequest is the request type for the // Query/FinalityProviderDelegations RPC method. message QueryFinalityProviderDelegationsRequest { @@ -375,8 +268,6 @@ message FinalityProviderResponse { uint32 slashed_btc_height = 7; // height is the queried Babylon height uint64 height = 8; - // voting_power is the voting power of this finality provider at the given height - uint64 voting_power = 9; // jailed defines whether the finality provider is jailed - bool jailed = 10; + bool jailed = 9; } diff --git a/proto/babylon/finality/v1/finality.proto b/proto/babylon/finality/v1/finality.proto index 87216e454..c0e22ac6d 100644 --- a/proto/babylon/finality/v1/finality.proto +++ b/proto/babylon/finality/v1/finality.proto @@ -3,10 +3,66 @@ package babylon.finality.v1; option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; import "google/protobuf/timestamp.proto"; +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +message VotingPowerDistCache { + option (gogoproto.goproto_getters) = false; + // total_sat is the total amount of bonded BTC stake (in Satoshi) of all the finality providers + // in the cache + uint64 total_bonded_sat = 1; + // finality_providers is a list of finality providers' voting power information + repeated FinalityProviderDistInfo finality_providers = 2; + // num_active_fps is the number of finality providers that have active BTC + // delegations as well as timestamped public randomness + uint32 num_active_fps = 3; +} + +// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations +message FinalityProviderDistInfo { + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // addr is the address to receive commission from delegations. + string addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // commission defines the commission rate of finality provider + string commission = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; + // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider + uint64 total_bonded_sat = 4; + // btc_dels is a list of BTC delegations' voting power information under this finality provider + repeated BTCDelDistInfo btc_dels = 5; + // is_timestamped indicates whether the finality provider + // has timestamped public randomness committed + // if no, it should not be assigned voting power + bool is_timestamped = 6; + // is_jailed indicates whether the finality provider + // is jailed, if so, it should not be assigned voting power + bool is_jailed = 7; + // is_slashed indicates whether the finality provider + // is slashed, if so, it should not be assigned voting power + bool is_slashed = 8; +} + +// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation +message BTCDelDistInfo { + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // staking_tx_hash is the staking tx hash of the BTC delegation + string staking_tx_hash = 3; + // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation + uint64 total_sat = 4; +} + // IndexedBlock is the necessary metadata and finalization status of a block message IndexedBlock { // height is the height of the block diff --git a/proto/babylon/finality/v1/genesis.proto b/proto/babylon/finality/v1/genesis.proto index b1759675d..553684fad 100644 --- a/proto/babylon/finality/v1/genesis.proto +++ b/proto/babylon/finality/v1/genesis.proto @@ -27,6 +27,10 @@ message GenesisState { // missed_blocks represents a map between finality provider public key and their // missed blocks. repeated FinalityProviderMissedBlocks missed_blocks = 8 [(gogoproto.nullable) = false]; + // voting_powers the voting power of every finality provider at every block height. + repeated VotingPowerFP voting_powers = 9; + // vp_dst_cache is the table of all providers voting power with the total at one specific block. + repeated VotingPowerDistCacheBlkHeight vp_dst_cache = 10; } // VoteSig the vote of an finality provider @@ -83,3 +87,22 @@ message MissedBlock { // missed is the missed status. bool missed = 2; } + +// VotingPowerFP contains the information about the voting power +// of an finality provider in a specific block height. +message VotingPowerFP { + // block_height is the height of the block the voting power was stored. + uint64 block_height = 1; + // fp_btc_pk the finality provider btc public key. + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // voting_power is the power of the finality provider at this specific block height. + uint64 voting_power = 3; +} + +// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height +message VotingPowerDistCacheBlkHeight { + // block_height is the height of the block the voting power distribution cached was stored. + uint64 block_height = 1; + // vp_distribution the finality providers distribution cache at that height. + VotingPowerDistCache vp_distribution = 2; +} diff --git a/proto/babylon/finality/v1/query.proto b/proto/babylon/finality/v1/query.proto index f29b3643f..6030febe4 100644 --- a/proto/babylon/finality/v1/query.proto +++ b/proto/babylon/finality/v1/query.proto @@ -18,11 +18,31 @@ service Query { option (google.api.http).get = "/babylon/finality/v1/params"; } + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + rpc ActiveFinalityProvidersAtHeight(QueryActiveFinalityProvidersAtHeightRequest) returns (QueryActiveFinalityProvidersAtHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{height}"; + } + + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + rpc FinalityProviderPowerAtHeight(QueryFinalityProviderPowerAtHeightRequest) returns (QueryFinalityProviderPowerAtHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/power/{height}"; + } + + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + rpc FinalityProviderCurrentPower(QueryFinalityProviderCurrentPowerRequest) returns (QueryFinalityProviderCurrentPowerResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/power"; + } + + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + rpc ActivatedHeight(QueryActivatedHeightRequest) returns (QueryActivatedHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/activated_height"; + } + // ListPublicRandomness is a range query for public randomness of a given finality provider // NOTE: Babylon only has the knowledge of public randomness that is already revealed by // finality providers, i.e., the finality provider already provides a finality signature // at the corresponding height - // TODO: remove public randomness storage? rpc ListPublicRandomness(QueryListPublicRandomnessRequest) returns (QueryListPublicRandomnessResponse) { option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/public_randomness_list"; } @@ -77,6 +97,92 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryFinalityProviderPowerAtHeightRequest is the request type for the +// Query/FinalityProviderPowerAtHeight RPC method. +message QueryFinalityProviderPowerAtHeightRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + string fp_btc_pk_hex = 1; + + // height is used for querying the given finality provider's voting power at this height + uint64 height = 2; +} + +// QueryFinalityProviderPowerAtHeightResponse is the response type for the +// Query/FinalityProviderPowerAtHeight RPC method. +message QueryFinalityProviderPowerAtHeightResponse { + // voting_power is the voting power of the finality provider + uint64 voting_power = 1; +} + +// QueryFinalityProviderCurrentPowerRequest is the request type for the +// Query/FinalityProviderCurrentPower RPC method. +message QueryFinalityProviderCurrentPowerRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + string fp_btc_pk_hex = 1; +} + +// QueryFinalityProviderCurrentPowerResponse is the response type for the +// Query/FinalityProviderCurrentPower RPC method. +message QueryFinalityProviderCurrentPowerResponse { + // height is the current height + uint64 height = 1; + // voting_power is the voting power of the finality provider + uint64 voting_power = 2; +} + +// QueryActiveFinalityProvidersAtHeightRequest is the request type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +message QueryActiveFinalityProvidersAtHeightRequest { + // height defines at which Babylon height to query the finality providers info. + uint64 height = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. +message ActiveFinalityProvidersAtHeightResponse { + // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider + // the PK follows encoding in BIP-340 spec + string btc_pk_hex = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // height is the queried Babylon height + uint64 height = 2; + // voting_power is the voting power of this finality provider at the given height + uint64 voting_power = 3; + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint64 slashed_babylon_height = 4; + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint32 slashed_btc_height = 5; + // jailed defines whether the finality provider is detected jailed + bool jailed = 6; +} + +// QueryActiveFinalityProvidersAtHeightResponse is the response type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +message QueryActiveFinalityProvidersAtHeightResponse { + // finality_providers contains all the queried finality providersn. + repeated ActiveFinalityProvidersAtHeightResponse finality_providers = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. +message QueryActivatedHeightRequest {} + +// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. +message QueryActivatedHeightResponse { + uint64 height = 1; +} + // QueryListPublicRandomnessRequest is the request type for the // Query/ListPublicRandomness RPC method. message QueryListPublicRandomnessRequest { diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index 9b9f40b6e..0aeb4ebc2 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -261,15 +261,8 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - // get activated height - _, err = nonValidatorNode.QueryActivatedHeight() - s.ErrorContains(err, bstypes.ErrBTCStakingNotActivated.Error()) - fps := nonValidatorNode.QueryFinalityProviders() - s.Len(fps, 1) - s.Zero(fps[0].VotingPower) - /* - commit a number of public randomness since activatedHeight + commit a number of public randomness */ // commit public randomness list numPubRand := uint64(100) diff --git a/test/e2e/btc_staking_pre_approval_e2e_test.go b/test/e2e/btc_staking_pre_approval_e2e_test.go index 691731451..996ce1c8a 100644 --- a/test/e2e/btc_staking_pre_approval_e2e_test.go +++ b/test/e2e/btc_staking_pre_approval_e2e_test.go @@ -288,15 +288,8 @@ func (s *BTCStakingPreApprovalTestSuite) Test4CommitPublicRandomnessAndSubmitFin nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - // get activated height - _, err = nonValidatorNode.QueryActivatedHeight() - s.ErrorContains(err, bstypes.ErrBTCStakingNotActivated.Error()) - fps := nonValidatorNode.QueryFinalityProviders() - s.Len(fps, 1) - s.Zero(fps[0].VotingPower) - /* - commit a number of public randomness since activatedHeight + commit a number of public randomness */ // commit public randomness list numPubRand := uint64(100) diff --git a/test/e2e/configurer/chain/queries_btcstaking.go b/test/e2e/configurer/chain/queries_btcstaking.go index b7621230f..149b8a76b 100644 --- a/test/e2e/configurer/chain/queries_btcstaking.go +++ b/test/e2e/configurer/chain/queries_btcstaking.go @@ -45,12 +45,12 @@ func (n *NodeConfig) QueryFinalityProviders() []*bstypes.FinalityProviderRespons return resp.FinalityProviders } -func (n *NodeConfig) QueryActiveFinalityProvidersAtHeight(height uint64) []*bstypes.ActiveFinalityProvidersAtHeightResponse { - path := fmt.Sprintf("/babylon/btcstaking/v1/finality_providers/%d", height) +func (n *NodeConfig) QueryActiveFinalityProvidersAtHeight(height uint64) []*ftypes.ActiveFinalityProvidersAtHeightResponse { + path := fmt.Sprintf("/babylon/finality/v1/finality_providers/%d", height) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) - var resp bstypes.QueryActiveFinalityProvidersAtHeightResponse + var resp ftypes.QueryActiveFinalityProvidersAtHeightResponse err = util.Cdc.UnmarshalJSON(bz, &resp) require.NoError(n.t, err) @@ -106,12 +106,12 @@ func (n *NodeConfig) QueryActiveDelegations() []*bstypes.BTCDelegationResponse { } func (n *NodeConfig) QueryActivatedHeight() (uint64, error) { - bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/activated_height", url.Values{}) + bz, err := n.QueryGRPCGateway("/babylon/finality/v1/activated_height", url.Values{}) if err != nil { return 0, err } - var resp bstypes.QueryActivatedHeightResponse + var resp ftypes.QueryActivatedHeightResponse err = util.Cdc.UnmarshalJSON(bz, &resp) if err != nil { return 0, err @@ -121,7 +121,6 @@ func (n *NodeConfig) QueryActivatedHeight() (uint64, error) { } // TODO: pagination support -// TODO: remove public randomness storage? func (n *NodeConfig) QueryListPublicRandomness(fpBTCPK *bbn.BIP340PubKey) map[uint64]*bbn.SchnorrPubRand { path := fmt.Sprintf("/babylon/finality/v1/finality_providers/%s/public_randomness_list", fpBTCPK.MarshalHex()) bz, err := n.QueryGRPCGateway(path, url.Values{}) diff --git a/testutil/datagen/incentive.go b/testutil/datagen/incentive.go index 15e17bc81..262f3a479 100644 --- a/testutil/datagen/incentive.go +++ b/testutil/datagen/incentive.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" itypes "github.com/babylonlabs-io/babylon/x/incentive/types" ) @@ -77,26 +77,26 @@ func GenRandomGauge(r *rand.Rand) *itypes.Gauge { return itypes.NewGauge(coins...) } -func GenRandomBTCDelDistInfo(r *rand.Rand) (*bstypes.BTCDelDistInfo, error) { +func GenRandomBTCDelDistInfo(r *rand.Rand) (*ftypes.BTCDelDistInfo, error) { btcPK, err := GenRandomBIP340PubKey(r) if err != nil { return nil, err } - return &bstypes.BTCDelDistInfo{ + return &ftypes.BTCDelDistInfo{ BtcPk: btcPK, StakerAddr: GenRandomAccount().Address, TotalSat: RandomInt(r, 1000) + 1, }, nil } -func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderDistInfo, error) { +func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*ftypes.FinalityProviderDistInfo, error) { // create finality provider with random commission fp, err := GenRandomFinalityProvider(r) if err != nil { return nil, err } // create finality provider distribution info - fpDistInfo := bstypes.NewFinalityProviderDistInfo(fp) + fpDistInfo := ftypes.NewFinalityProviderDistInfo(fp) // add a random number of BTC delegation distribution info numBTCDels := RandomInt(r, 100) + 1 for i := uint64(0); i < numBTCDels; i++ { @@ -111,8 +111,8 @@ func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderD return fpDistInfo, nil } -func GenRandomVotingPowerDistCache(r *rand.Rand, maxFPs uint32) (*bstypes.VotingPowerDistCache, error) { - dc := bstypes.NewVotingPowerDistCache() +func GenRandomVotingPowerDistCache(r *rand.Rand, maxFPs uint32) (*ftypes.VotingPowerDistCache, error) { + dc := ftypes.NewVotingPowerDistCache() // a random number of finality providers numFps := RandomInt(r, 10) + 1 for i := uint64(0); i < numFps; i++ { diff --git a/x/btcstaking/README.md b/x/btcstaking/README.md index de878c840..b6bff33ae 100644 --- a/x/btcstaking/README.md +++ b/x/btcstaking/README.md @@ -19,8 +19,6 @@ providers and BTC delegations under them. This includes: - [Finality providers](#finality-providers) - [BTC delegations](#btc-delegations) - [BTC delegation index](#btc-delegation-index) - - [Voting power table](#voting-power-table) - - [Params](#params) - [Messages](#messages) - [MsgCreateFinalityProvider](#msgcreatefinalityprovider) - [MsgEditFinalityProvider](#msgeditfinalityprovider) @@ -31,6 +29,8 @@ providers and BTC delegations under them. This includes: - [MsgSelectiveSlashingEvidence](#msgselectiveslashingevidence) - [BeginBlocker](#beginblocker) - [Events](#events) + - [Finality provider events](#finality-provider-events) + - [Delegation events](#delegation-events) - [Queries](#queries) ## Concepts @@ -102,46 +102,52 @@ parameters. The BTC Staking module's parameters are represented as a `Params` // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - + // PARAMETERS COVERING STAKING // covenant_pks is the list of public keys held by the covenant committee // each PK follows encoding in BIP-340 spec on Bitcoin repeated bytes covenant_pks = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // covenant_quorum is the minimum number of signatures needed for the covenant // multisignature uint32 covenant_quorum = 2; - // slashing address is the address that the slashed BTC goes to - // the address is in string on Bitcoin - string slashing_address = 3; + // min_staking_value_sat is the minimum of satoshis locked in staking output + int64 min_staking_value_sat = 3; + // max_staking_value_sat is the maximum of satoshis locked in staking output + int64 max_staking_value_sat = 4; + // min_staking_time is the minimum lock time specified in staking output script + uint32 min_staking_time_blocks = 5; + // max_staking_time_blocks is the maximum lock time time specified in staking output script + uint32 max_staking_time_blocks = 6; + // PARAMETERS COVERING SLASHING + // slashing_pk_script is the pk_script expected in slashing output ie. the first + // output of slashing transaction + bytes slashing_pk_script = 7; // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified - // in Satoshi) needed for the pre-signed slashing tx - int64 min_slashing_tx_fee_sat = 4; - // min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators - string min_commission_rate = 5 [ - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; + // in Satoshi) needed for the pre-signed slashing tx. It covers both: + // staking slashing transaction and unbonding slashing transaction + int64 min_slashing_tx_fee_sat = 8; // slashing_rate determines the portion of the staked amount to be slashed, - // expressed as a decimal (e.g., 0.5 for 50%). - string slashing_rate = 6 [ + // expressed as a decimal (e.g., 0.5 for 50%). Maximal precion is 2 decimal + // places + string slashing_rate = 9 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - uint32 max_active_finality_providers = 7; + // PARAMETERS COVERING UNBONDING // min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks - uint32 min_unbonding_time = 8; - - // min_unbonding_rate is the minimum amount of BTC that are required in unbonding - // output, expressed as a fraction of staking output - // example: if min_unbonding_rate=0.9, then the unbonding output value - // must be at least 90% of staking output, for staking request to be considered - // valid - string min_unbonding_rate = 9 [ - (cosmos_proto.scalar) = "cosmos.Dec", + uint32 min_unbonding_time_blocks = 10; + // unbonding_fee exact fee required for unbonding transaction + int64 unbonding_fee_sat = 11; + // PARAMETERS COVERING FINALITY PROVIDERS + // min_commission_rate is the chain-wide minimum commission rate that a finality provider + // can charge their delegators expressed as a decimal (e.g., 0.5 for 50%). Maximal precion + // is 2 decimal places + string min_commission_rate = 12 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + // base gas fee for delegation creation + uint64 delegation_creation_base_gas_fee = 13; } ``` @@ -157,29 +163,31 @@ finality provider. ```protobuf // FinalityProvider defines a finality provider message FinalityProvider { - // addr is the bech32 address identifier of the finality provider. - string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // description defines the description terms for the finality provider. - cosmos.staking.v1beta1.Description description = 2; - // commission defines the commission rate of the finality provider. - string commission = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" - ]; - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of the btc_pk, where the BTC - // private key signs the bech32 bbn addr of the finality provider. - ProofOfPossessionBTC pop = 5; - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint64 slashed_babylon_height = 6; - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint32 slashed_btc_height = 7; + // addr is the bech32 address identifier of the finality provider. + string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // description defines the description terms for the finality provider. + cosmos.staking.v1beta1.Description description = 2; + // commission defines the commission rate of the finality provider. + string commission = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of the btc_pk, where the BTC + // private key signs the bech32 bbn addr of the finality provider. + ProofOfPossessionBTC pop = 5; + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint64 slashed_babylon_height = 6; + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint32 slashed_btc_height = 7; + // jailed defines whether the finality provider is jailed + bool jailed = 8; } ``` @@ -197,80 +205,92 @@ submit a staking transaction to Bitcoin. ```protobuf // BTCDelegation defines a BTC delegation message BTCDelegation { - // staker_addr is the address to receive rewards from BTC delegation. - string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossessionBTC pop = 3; - // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that - // this BTC delegation delegates to - // If there is more than 1 PKs, then this means the delegation is restaked - // to multiple finality providers - repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // start_height is the start BTC height of the BTC delegation - // it is the start BTC height of the timelock - uint32 start_height = 5; - // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - uint32 end_height = 6; - // total_sat is the total amount of BTC stakes in this delegation - // quantified in satoshi - uint64 total_sat = 7; - // staking_tx is the staking tx - bytes staking_tx = 8; - // staking_output_idx is the index of the staking output in the staking tx - uint32 staking_output_idx = 9; - // slashing_tx is the slashing tx - // It is partially signed by SK corresponding to btc_pk, but not signed by - // finality provider or covenant yet. - bytes slashing_tx = 10 [ (gogoproto.customtype) = "BTCSlashingTx" ]; - // delegator_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the staking tx output. - bytes delegator_sig = 11 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // covenant_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_sigs = 12; - // unbonding_time describes how long the funds will be locked either in unbonding output - // or slashing change output - uint32 unbonding_time = 13; - // btc_undelegation is the information about the early unbonding path of the BTC delegation - BTCUndelegation btc_undelegation = 14; - // version of the params used to validate the delegation - uint32 params_version = 15; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of babylon_pk and btc_pk + ProofOfPossessionBTC pop = 3; + // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that + // this BTC delegation delegates to + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple finality providers + repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staking_time is the number of blocks for which the delegation is locked on BTC chain + uint32 staking_time = 5; + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + uint32 start_height = 6; + // end_height is the end height of the BTC delegation + // it is calculated by end_height = start_height + staking_time + uint32 end_height = 7; + // total_sat is the total amount of BTC stakes in this delegation + // quantified in satoshi + uint64 total_sat = 8; + // staking_tx is the staking tx + bytes staking_tx = 9; + // staking_output_idx is the index of the staking output in the staking tx + uint32 staking_output_idx = 10; + // slashing_tx is the slashing tx + // It is partially signed by SK corresponding to btc_pk, but not signed by + // finality provider or covenant yet. + bytes slashing_tx = 11 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + // delegator_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the staking tx output. + bytes delegator_sig = 12 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + // covenant_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + repeated CovenantAdaptorSignatures covenant_sigs = 13; + // unbonding_time describes how long the funds will be locked either in unbonding output + // or slashing change output + uint32 unbonding_time = 14; + // btc_undelegation is the information about the early unbonding path of the BTC delegation + BTCUndelegation btc_undelegation = 15; + // version of the params used to validate the delegation + uint32 params_version = 16; +} + +// DelegatorUnbondingInfo contains the information about transaction which spent +// the staking output. It contains: +// - spend_stake_tx: the transaction which spent the staking output +// - spend_stake_tx_inclusion_block_hash: the block hash of the block in which +// spend_stake_tx was included +// - spend_stake_tx_sig_inclusion_index: the index of spend_stake_tx in the block +message DelegatorUnbondingInfo { + // spend_stake_tx is the transaction which spent the staking output. It is + // filled only if spend_stake_tx is different than unbonding_tx registered + // on the Babylon chain. + bytes spend_stake_tx = 1; } // BTCUndelegation contains the information about the early unbonding path of the BTC delegation message BTCUndelegation { - // unbonding_tx is the transaction which will transfer the funds from staking - // output to unbonding output. Unbonding output will usually have lower timelock - // than staking output. - bytes unbonding_tx = 1; - // slashing_tx is the slashing tx for unbonding transactions - // It is partially signed by SK corresponding to btc_pk, but not signed by - // finality provider or covenant yet. - bytes slashing_tx = 2 [ (gogoproto.customtype) = "BTCSlashingTx" ]; - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock - bytes delegator_unbonding_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // delegator_slashing_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the unbonding tx output. - bytes delegator_slashing_sig = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_slashing_sigs = 5; - // covenant_unbonding_sig_list is the list of signatures on the unbonding tx - // by covenant members - // It must be provided after processing undelegate message by Babylon - repeated SignatureInfo covenant_unbonding_sig_list = 6; + // unbonding_tx is the transaction which will transfer the funds from staking + // output to unbonding output. Unbonding output will usually have lower timelock + // than staking output. + bytes unbonding_tx = 1; + // slashing_tx is the slashing tx for unbonding transactions + // It is partially signed by SK corresponding to btc_pk, but not signed by + // finality provider or covenant yet. + bytes slashing_tx = 2 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + // delegator_slashing_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the unbonding tx output. + bytes delegator_slashing_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + repeated CovenantAdaptorSignatures covenant_slashing_sigs = 4; + // covenant_unbonding_sig_list is the list of signatures on the unbonding tx + // by covenant members + // It must be provided after processing undelegate message by Babylon + repeated SignatureInfo covenant_unbonding_sig_list = 5; + // delegator_unbonding_info is the information about transaction which spent + // the staking output + DelegatorUnbondingInfo delegator_unbonding_info = 6; } ``` @@ -290,58 +310,6 @@ message BTCDelegatorDelegationIndex { } ``` -### Voting power table - -The [voting power table management](./keeper/voting_power_table.go) maintains the -voting power table of all finality providers at each height of the Babylon -chain. The key is the block height concatenated with the finality provider's -Bitcoin secp256k1 public key in BIP-340 format, and the value is the finality -provider's voting power quantified in Satoshis. -Voting power is assigned to top `N` (defined in parameters) finality providers -that have BTC-timestamped public randomness for the height, ranked by the total -delegated value. - -### Params - -The [parameter managemnt](./keeper/params.go) maintains the parameters for the BTC -staking module. - -```protobuf -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; - - // covenant_pks is the list of public keys held by the covenant committee - // each PK follows encoding in BIP-340 spec on Bitcoin - repeated bytes covenant_pks = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // covenant_quorum is the minimum number of signatures needed for the covenant - // multisignature - uint32 covenant_quorum = 2; - // slashing address is the address that the slashed BTC goes to - // the address is in string on Bitcoin - string slashing_address = 3; - // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified - // in Satoshi) needed for the pre-signed slashing tx - int64 min_slashing_tx_fee_sat = 4; - // min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators - string min_commission_rate = 5 [ - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // slashing_rate determines the portion of the staked amount to be slashed, - // expressed as a decimal (e.g., 0.5 for 50%). - string slashing_rate = 6 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - uint32 max_active_finality_providers = 7; - // min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks - uint32 min_unbonding_time = 8; -} -``` - ## Messages The BTC Staking module handles the following messages from finality providers, @@ -696,20 +664,7 @@ submit it to Babylon. ## BeginBlocker -Upon `BeginBlock`, the BTC Staking module will execute the following: - -1. Index the current BTC tip height. This will be used for determining the - status of BTC delegations. -2. Record the voting power table at the current height, by reconciling the - voting power table at the last height with all events that affect voting - power distribution (including newly active BTC delegations, newly unbonded - BTC delegations, and slashed finality providers). - Note that the voting power is assigned to a finality provider if it (1) has - BTC-timestamped public randomness, and (2) it is ranked at top `N` by the - total delegated value. -3. If the BTC Staking protocol is activated, i.e., there exists at least 1 - active BTC delegation, then record the reward distribution w.r.t. the active - finality providers and active BTC delegations. +Upon `BeginBlock`, the BTC Staking module will index the current BTC tip height. This will be used for determining the status of BTC delegations. The logic is defined at [x/btcstaking/abci.go](./abci.go). diff --git a/x/btcstaking/client/cli/query.go b/x/btcstaking/client/cli/query.go index 7f3b19126..4466d29ed 100644 --- a/x/btcstaking/client/cli/query.go +++ b/x/btcstaking/client/cli/query.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strconv" "github.com/cosmos/cosmos-sdk/client/flags" @@ -26,9 +25,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdFinalityProvider()) cmd.AddCommand(CmdFinalityProviders()) cmd.AddCommand(CmdBTCDelegations()) - cmd.AddCommand(CmdFinalityProvidersAtHeight()) - cmd.AddCommand(CmdFinalityProviderPowerAtHeight()) - cmd.AddCommand(CmdActivatedHeight()) cmd.AddCommand(CmdFinalityProviderDelegations()) cmd.AddCommand(CmdDelegation()) @@ -160,99 +156,6 @@ func CmdBTCDelegations() *cobra.Command { return cmd } -func CmdFinalityProviderPowerAtHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "finality-provider-power-at-height [fp_btc_pk_hex] [height]", - Short: "get the voting power of a given finality provider at a given height", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - height, err := strconv.ParseUint(args[1], 10, 64) - if err != nil { - return err - } - res, err := queryClient.FinalityProviderPowerAtHeight(cmd.Context(), &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: args[0], - Height: height, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdActivatedHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "activated-height", - Short: "get activated height, i.e., the first height where there exists 1 finality provider with voting power", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.ActivatedHeight(cmd.Context(), &types.QueryActivatedHeightRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdFinalityProvidersAtHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "finality-providers-at-height [height]", - Short: "retrieve all finality providers at a given babylon height", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - height, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - res, err := queryClient.ActiveFinalityProvidersAtHeight(cmd.Context(), &types.QueryActiveFinalityProvidersAtHeightRequest{ - Height: height, - Pagination: pageReq, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "finality-providers-at-height") - - return cmd -} - func CmdFinalityProviderDelegations() *cobra.Command { cmd := &cobra.Command{ Use: "finality-provider-delegations [fp_pk_hex]", diff --git a/x/btcstaking/keeper/genesis.go b/x/btcstaking/keeper/genesis.go index d33e7309e..faebc7ee2 100644 --- a/x/btcstaking/keeper/genesis.go +++ b/x/btcstaking/keeper/genesis.go @@ -5,7 +5,6 @@ import ( "fmt" "math" - btcstk "github.com/babylonlabs-io/babylon/btcstaking" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,10 +28,6 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { k.setBTCDelegation(ctx, btcDel) } - for _, fpVP := range gs.VotingPowers { - k.SetVotingPower(ctx, *fpVP.FpBtcPk, fpVP.BlockHeight, fpVP.VotingPower) - } - for _, blocks := range gs.BlockHeightChains { k.setBlockHeightChains(ctx, blocks) } @@ -52,10 +47,6 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { } } - for _, vpCache := range gs.VpDstCache { - k.SetVotingPowerDistCache(ctx, vpCache.BlockHeight, vpCache.VpDistribution) - } - return nil } @@ -71,11 +62,6 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - vpFps, err := k.fpVotingPowers(ctx) - if err != nil { - return nil, err - } - btcDels, err := k.btcDelegators(ctx) if err != nil { return nil, err @@ -86,20 +72,13 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - vpsCache, err := k.votingPowersDistCacheBlkHeight(ctx) - if err != nil { - return nil, err - } - return &types.GenesisState{ Params: k.GetAllParams(ctx), FinalityProviders: fps, BtcDelegations: dels, - VotingPowers: vpFps, BlockHeightChains: k.blockHeightChains(ctx), BtcDelegators: btcDels, Events: evts, - VpDstCache: vpsCache, }, nil } @@ -135,30 +114,6 @@ func (k Keeper) btcDelegations(ctx context.Context) ([]*types.BTCDelegation, err return dels, nil } -// fpVotingPowers gets the voting power of a given finality provider at a given Babylon height. -func (k Keeper) fpVotingPowers(ctx context.Context) ([]*types.VotingPowerFP, error) { - iter := k.votingPowerStore(ctx).Iterator(nil, nil) - defer iter.Close() - - vpFps := make([]*types.VotingPowerFP, 0) - - for ; iter.Valid(); iter.Next() { - blkHeight, fpBTCPK, err := btcstk.ParseBlkHeightAndPubKeyFromStoreKey(iter.Key()) - if err != nil { - return nil, err - } - - vp := sdk.BigEndianToUint64(iter.Value()) - vpFps = append(vpFps, &types.VotingPowerFP{ - BlockHeight: blkHeight, - FpBtcPk: fpBTCPK, - VotingPower: vp, - }) - } - - return vpFps, nil -} - func (k Keeper) blockHeightChains(ctx context.Context) []*types.BlockHeightBbnToBtc { iter := k.btcHeightStore(ctx).Iterator(nil, nil) defer iter.Close() @@ -232,25 +187,6 @@ func (k Keeper) eventIdxs( return evts, nil } -func (k Keeper) votingPowersDistCacheBlkHeight(ctx context.Context) ([]*types.VotingPowerDistCacheBlkHeight, error) { - vps := make([]*types.VotingPowerDistCacheBlkHeight, 0) - iter := k.votingPowerDistCacheStore(ctx).Iterator(nil, nil) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - var dc types.VotingPowerDistCache - if err := dc.Unmarshal(iter.Value()); err != nil { - return nil, err - } - vps = append(vps, &types.VotingPowerDistCacheBlkHeight{ - BlockHeight: sdk.BigEndianToUint64(iter.Key()), - VpDistribution: &dc, - }) - } - - return vps, nil -} - func (k Keeper) setBlockHeightChains(ctx context.Context, blocks *types.BlockHeightBbnToBtc) { store := k.btcHeightStore(ctx) store.Set(sdk.Uint64ToBigEndian(blocks.BlockHeightBbn), sdk.Uint64ToBigEndian(uint64(blocks.BlockHeightBtc))) diff --git a/x/btcstaking/keeper/genesis_test.go b/x/btcstaking/keeper/genesis_test.go index d9998ecbe..bc8e7d5de 100644 --- a/x/btcstaking/keeper/genesis_test.go +++ b/x/btcstaking/keeper/genesis_test.go @@ -28,7 +28,6 @@ func TestExportGenesis(t *testing.T) { BlockHeightBbn: 1, BlockHeightBtc: 0, }) - vpFps := make(map[string]*types.VotingPowerFP, 0) btcDelegations := make([]*types.BTCDelegation, 0) eventsIdx := make(map[uint64]*types.EventIndex, 0) btcDelegatorIndex := make(map[string]*types.BTCDelegator, 0) @@ -56,15 +55,6 @@ func TestExportGenesis(t *testing.T) { int(numDelegations), params.CovenantQuorum, ) - vp := uint64(stakingValue) - - // sets voting power - k.SetVotingPower(ctx, *fp.BtcPk, blkHeight, vp) - vpFps[fp.BtcPk.MarshalHex()] = &types.VotingPowerFP{ - BlockHeight: blkHeight, - FpBtcPk: fp.BtcPk, - VotingPower: vp, - } for _, del := range delegations { totalDelegations++ @@ -149,12 +139,6 @@ func TestExportGenesis(t *testing.T) { } require.Equal(t, correctDels, len(btcDelegations)) - // voting powers - for _, gsFpVp := range gs.VotingPowers { - vp := vpFps[gsFpVp.FpBtcPk.MarshalHex()] - require.Equal(t, gsFpVp, vp) - } - // chains height require.Equal(t, chainsHeight, gs.BlockHeightChains) diff --git a/x/btcstaking/keeper/grpc_query.go b/x/btcstaking/keeper/grpc_query.go index d34f76acc..1f3f45f3d 100644 --- a/x/btcstaking/keeper/grpc_query.go +++ b/x/btcstaking/keeper/grpc_query.go @@ -34,8 +34,7 @@ func (k Keeper) FinalityProviders(c context.Context, req *types.QueryFinalityPro return err } - votingPower := k.GetVotingPower(ctx, key, currBlockHeight) - resp := types.NewFinalityProviderResponse(&fp, currBlockHeight, votingPower) + resp := types.NewFinalityProviderResponse(&fp, currBlockHeight) fpResp = append(fpResp, resp) return nil }) @@ -74,8 +73,7 @@ func (k Keeper) FinalityProvider(c context.Context, req *types.QueryFinalityProv } currBlockHeight := uint64(ctx.BlockHeight()) - votingPower := k.GetVotingPower(ctx, key, currBlockHeight) - fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight, votingPower) + fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight) return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil } @@ -120,105 +118,6 @@ func (k Keeper) BTCDelegations(ctx context.Context, req *types.QueryBTCDelegatio }, nil } -// FinalityProviderPowerAtHeight returns the voting power of the specified finality provider -// at the provided Babylon height -func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.QueryFinalityProviderPowerAtHeightRequest) (*types.QueryFinalityProviderPowerAtHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) - } - - if !k.HasFinalityProvider(ctx, *fpBTCPK) { - return nil, types.ErrFpNotFound - } - - store := k.votingPowerBbnBlockHeightStore(ctx, req.Height) - iter := store.ReverseIterator(nil, nil) - defer iter.Close() - - if !iter.Valid() { - return nil, types.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", req.Height) - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - power := k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height) - - return &types.QueryFinalityProviderPowerAtHeightResponse{VotingPower: power}, nil -} - -// FinalityProviderCurrentPower returns the voting power of the specified finality provider -// at the current height -func (k Keeper) FinalityProviderCurrentPower(ctx context.Context, req *types.QueryFinalityProviderCurrentPowerRequest) (*types.QueryFinalityProviderCurrentPowerResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) - } - - height, power := k.GetCurrentVotingPower(ctx, *fpBTCPK) - - return &types.QueryFinalityProviderCurrentPowerResponse{Height: height, VotingPower: power}, nil -} - -// ActiveFinalityProvidersAtHeight returns the active finality providers at the provided height -func (k Keeper) ActiveFinalityProvidersAtHeight(ctx context.Context, req *types.QueryActiveFinalityProvidersAtHeightRequest) (*types.QueryActiveFinalityProvidersAtHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - store := k.votingPowerBbnBlockHeightStore(sdkCtx, req.Height) - - var finalityProvidersWithMeta []*types.FinalityProviderWithMeta - pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { - finalityProvider, err := k.GetFinalityProvider(sdkCtx, key) - if err != nil { - return err - } - - votingPower := k.GetVotingPower(sdkCtx, key, req.Height) - if votingPower > 0 { - finalityProviderWithMeta := types.FinalityProviderWithMeta{ - BtcPk: finalityProvider.BtcPk, - Height: req.Height, - VotingPower: votingPower, - SlashedBabylonHeight: finalityProvider.SlashedBabylonHeight, - SlashedBtcHeight: finalityProvider.SlashedBtcHeight, - } - finalityProvidersWithMeta = append(finalityProvidersWithMeta, &finalityProviderWithMeta) - } - - return nil - }) - if err != nil { - return nil, err - } - - return &types.QueryActiveFinalityProvidersAtHeightResponse{FinalityProviders: convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta), Pagination: pageRes}, nil -} - -// ActivatedHeight returns the Babylon height in which the BTC Staking protocol was enabled -// TODO: Requires investigation on whether we can enable the BTC staking protocol at genesis -func (k Keeper) ActivatedHeight(ctx context.Context, req *types.QueryActivatedHeightRequest) (*types.QueryActivatedHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - activatedHeight, err := k.GetBTCStakingActivatedHeight(sdkCtx) - if err != nil { - return nil, err - } - return &types.QueryActivatedHeightResponse{Height: activatedHeight}, nil -} - // FinalityProviderDelegations returns all the delegations of the provided finality provider filtered by the provided status. func (k Keeper) FinalityProviderDelegations(ctx context.Context, req *types.QueryFinalityProviderDelegationsRequest) (*types.QueryFinalityProviderDelegationsResponse, error) { if req == nil { @@ -302,18 +201,3 @@ func (k Keeper) BTCDelegation(ctx context.Context, req *types.QueryBTCDelegation BtcDelegation: types.NewBTCDelegationResponse(btcDel, status), }, nil } - -func convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta []*types.FinalityProviderWithMeta) []*types.ActiveFinalityProvidersAtHeightResponse { - var activeFinalityProvidersAtHeightResponse []*types.ActiveFinalityProvidersAtHeightResponse - for _, fpWithMeta := range finalityProvidersWithMeta { - activeFinalityProvidersAtHeightResponse = append(activeFinalityProvidersAtHeightResponse, &types.ActiveFinalityProvidersAtHeightResponse{ - BtcPkHex: fpWithMeta.BtcPk, - Height: fpWithMeta.Height, - VotingPower: fpWithMeta.VotingPower, - SlashedBabylonHeight: fpWithMeta.SlashedBabylonHeight, - SlashedBtcHeight: fpWithMeta.SlashedBtcHeight, - Jailed: fpWithMeta.Jailed, - }) - } - return activeFinalityProvidersAtHeightResponse -} diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index 66beb91c4..eae10fff8 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -26,31 +26,6 @@ import ( var net = &chaincfg.SimNetParams -func FuzzActivatedHeight(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, nil) - ctx = sdk.UnwrapSDKContext(ctx) - - // not activated yet - _, err := keeper.GetBTCStakingActivatedHeight(ctx) - require.Error(t, err) - - randomActivatedHeight := datagen.RandomInt(r, 100) + 1 - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomActivatedHeight, uint64(10)) - - // now it's activated - resp, err := keeper.ActivatedHeight(ctx, &types.QueryActivatedHeightRequest{}) - require.NoError(t, err) - require.Equal(t, randomActivatedHeight, resp.Height) - }) -} - func FuzzFinalityProviders(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -167,7 +142,7 @@ func FuzzFinalityProvider(f *testing.F) { }) } -func FuzzPendingBTCDelegations(f *testing.F) { +func FuzzFinalityProviderDelegations(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) @@ -195,189 +170,95 @@ func FuzzPendingBTCDelegations(f *testing.F) { // this is already covered in FuzzGeneratingValidStakingSlashingTx slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - // Generate a random number of finality providers - numFps := datagen.RandomInt(r, 5) + 1 - fps := []*types.FinalityProvider{} - for i := uint64(0); i < numFps; i++ { - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - AddFinalityProvider(t, ctx, *keeper, fp) - fps = append(fps, fp) - } + // Generate a finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + AddFinalityProvider(t, ctx, *keeper, fp) - // Generate a random number of BTC delegations under each finality provider startHeight := uint32(datagen.RandomInt(r, 100)) + 1 - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 stakingTime := endHeight - startHeight + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() + // Generate a random number of BTC delegations under this finality provider numBTCDels := datagen.RandomInt(r, 10) + 1 - pendingBtcDelsMap := make(map[string]*types.BTCDelegation) - for _, fp := range fps { - for j := uint64(0); j < numBTCDels; j++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - // 0.5 chance that the delegation is created via pre-approval flow - if r.Intn(2) == 0 { - startHeight, endHeight = 0, 0 - } - btcDel, err := datagen.GenRandomBTCDelegation( - r, - t, - net, - []bbn.BIP340PubKey{*fp.BtcPk}, - delSK, - covenantSKs, - covenantPKs, - covenantQuorum, - slashingPkScript, - stakingTime, startHeight, endHeight, 10000, - slashingRate, - slashingChangeLockTime, - ) - require.NoError(t, err) - if datagen.RandomInt(r, 2) == 1 { - // remove covenant sig in random BTC delegations to make them inactive - btcDel.CovenantSigs = nil - pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel - } - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) - - txHash := btcDel.MustGetStakingTxHash().String() - delView, err := keeper.BTCDelegation(ctx, &types.QueryBTCDelegationRequest{ - StakingTxHashHex: txHash, - }) - require.NoError(t, err) - require.NotNil(t, delView) - } + expectedBtcDelsMap := make(map[string]*types.BTCDelegation) + for j := uint64(0); j < numBTCDels; j++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + btcDel, err := datagen.GenRandomBTCDelegation( + r, + t, + net, + []bbn.BIP340PubKey{*fp.BtcPk}, + delSK, + covenantSKs, + covenantPKs, + covenantQuorum, + slashingPkScript, + stakingTime, startHeight, endHeight, 10000, + slashingRate, + slashingChangeLockTime, + ) + require.NoError(t, err) + expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel + err = keeper.AddBTCDelegation(ctx, btcDel) + require.NoError(t, err) } + // Test nil request + resp, err := keeper.FinalityProviderDelegations(ctx, nil) + require.Nil(t, resp) + require.Error(t, err) + babylonHeight := datagen.RandomInt(r, 10) + 1 ctx = datagen.WithCtxHeight(ctx, babylonHeight) + keeper.IndexBTCHeight(ctx) - // querying paginated BTC delegations and assert // Generate a page request with a limit and a nil key - if len(pendingBtcDelsMap) == 0 { - return - } - limit := datagen.RandomInt(r, len(pendingBtcDelsMap)) + 1 + // query a page of BTC delegations and assert consistency + limit := datagen.RandomInt(r, len(expectedBtcDelsMap)) + 1 + + // FinalityProviderDelegations loads status, which calls GetTipInfo + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() + + keeper.IndexBTCHeight(ctx) + pagination := constructRequestWithLimit(r, limit) - req := &types.QueryBTCDelegationsRequest{ - Status: types.BTCDelegationStatus_PENDING, + // Generate the initial query + req := types.QueryFinalityProviderDelegationsRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), Pagination: pagination, } + // Construct a mapping from the finality providers found to a boolean value + // Will be used later to evaluate whether all the finality providers were returned + btcDelsFound := make(map[string]bool, 0) + for i := uint64(0); i < numBTCDels; i += limit { - resp, err := keeper.BTCDelegations(ctx, req) + resp, err = keeper.FinalityProviderDelegations(ctx, &req) require.NoError(t, err) require.NotNil(t, resp) - for _, btcDel := range resp.BtcDelegations { - _, ok := pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] + for _, btcDels := range resp.BtcDelegatorDelegations { + require.Len(t, btcDels.Dels, 1) + btcDel := btcDels.Dels[0] + require.Equal(t, fp.BtcPk, &btcDel.FpBtcPkList[0]) + // Check if the pk exists in the map + _, ok := expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] require.True(t, ok) - require.Equal(t, stakingTime, btcDel.StakingTime) + btcDelsFound[btcDel.BtcPk.MarshalHex()] = true } // Construct the next page request - pagination.Key = resp.Pagination.NextKey - } - }) -} - -func FuzzFinalityProviderPowerAtHeight(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, nil) - - // random finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - // add this finality provider - AddFinalityProvider(t, ctx, *keeper, fp) - // set random voting power at random height - randomHeight := datagen.RandomInt(r, 100) + 1 - randomPower := datagen.RandomInt(r, 100) + 1 - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) - - // happy case - req1 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Height: randomHeight, - } - resp, err := keeper.FinalityProviderPowerAtHeight(ctx, req1) - require.NoError(t, err) - require.Equal(t, randomPower, resp.VotingPower) - - // case where the voting power store is not updated in - // the given height - requestHeight := randomHeight + datagen.RandomInt(r, 10) + 1 - req2 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Height: requestHeight, - } - _, err = keeper.FinalityProviderPowerAtHeight(ctx, req2) - require.ErrorIs(t, err, types.ErrVotingPowerTableNotUpdated) - - // case where the given fp pk does not exist - randPk, err := datagen.GenRandomBIP340PubKey(r) - require.NoError(t, err) - req3 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: randPk.MarshalHex(), - Height: randomHeight, - } - _, err = keeper.FinalityProviderPowerAtHeight(ctx, req3) - require.ErrorIs(t, err, types.ErrFpNotFound) - }) -} - -func FuzzFinalityProviderCurrentVotingPower(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, nil) - - // random finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - // add this finality provider - AddFinalityProvider(t, ctx, *keeper, fp) - // set random voting power at random height - randomHeight := datagen.RandomInt(r, 100) + 1 - ctx = datagen.WithCtxHeight(ctx, randomHeight) - randomPower := datagen.RandomInt(r, 100) + 1 - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) - - // assert voting power at current height - req := &types.QueryFinalityProviderCurrentPowerRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + req = types.QueryFinalityProviderDelegationsRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Pagination: pagination, + } } - resp, err := keeper.FinalityProviderCurrentPower(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 = datagen.WithCtxHeight(ctx, randomHeight+1) - resp, err = keeper.FinalityProviderCurrentPower(ctx, req) - require.NoError(t, err) - require.Equal(t, randomHeight, resp.Height) - require.Equal(t, randomPower, resp.VotingPower) + require.Equal(t, len(btcDelsFound), len(expectedBtcDelsMap)) - // test the case when the finality provider has 0 voting power - ctx = datagen.WithCtxHeight(ctx, randomHeight+2) - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight+2, 0) - resp, err = keeper.FinalityProviderCurrentPower(ctx, req) - require.NoError(t, err) - require.Equal(t, randomHeight+2, resp.Height) - require.Equal(t, uint64(0), resp.VotingPower) }) } -func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { +func FuzzPendingBTCDelegations(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) @@ -386,7 +267,6 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { // Setup keeper and context btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 10}).AnyTimes() btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) @@ -406,10 +286,9 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { // this is already covered in FuzzGeneratingValidStakingSlashingTx slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - // Generate a random batch of finality providers - var fps []*types.FinalityProvider - numFpsWithVotingPower := datagen.RandomInt(r, 10) + 1 - numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + // Generate a random number of finality providers + numFps := datagen.RandomInt(r, 5) + 1 + fps := []*types.FinalityProvider{} for i := uint64(0); i < numFps; i++ { fp, err := datagen.GenRandomFinalityProvider(r) require.NoError(t, err) @@ -417,202 +296,80 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { fps = append(fps, fp) } - // For numFpsWithVotingPower finality providers, generate a random number of BTC delegations - numBTCDels := datagen.RandomInt(r, 10) + 1 - babylonHeight := datagen.RandomInt(r, 10) + 1 - fpsWithVotingPowerMap := make(map[string]*types.FinalityProvider) - for i := uint64(0); i < numFpsWithVotingPower; i++ { - fpBTCPK := fps[i].BtcPk - fpsWithVotingPowerMap[fpBTCPK.MarshalHex()] = fps[i] + // Generate a random number of BTC delegations under each finality provider + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - var totalVotingPower uint64 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + stakingTime := endHeight - startHeight + numBTCDels := datagen.RandomInt(r, 10) + 1 + pendingBtcDelsMap := make(map[string]*types.BTCDelegation) + for _, fp := range fps { for j := uint64(0); j < numBTCDels; j++ { delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) - startHeight, endHeight := uint32(1), uint32(1000) - stakingTime := endHeight - startHeight + // 0.5 chance that the delegation is created via pre-approval flow + if r.Intn(2) == 0 { + startHeight, endHeight = 0, 0 + } btcDel, err := datagen.GenRandomBTCDelegation( r, t, net, - []bbn.BIP340PubKey{*fpBTCPK}, + []bbn.BIP340PubKey{*fp.BtcPk}, delSK, covenantSKs, covenantPKs, covenantQuorum, slashingPkScript, - stakingTime, 1, 1000, 10000, + stakingTime, startHeight, endHeight, 10000, slashingRate, slashingChangeLockTime, ) require.NoError(t, err) + if datagen.RandomInt(r, 2) == 1 { + // remove covenant sig in random BTC delegations to make them inactive + btcDel.CovenantSigs = nil + pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel + } err = keeper.AddBTCDelegation(ctx, btcDel) require.NoError(t, err) - totalVotingPower += btcDel.TotalSat - } - - keeper.SetVotingPower(ctx, fpBTCPK.MustMarshal(), babylonHeight, totalVotingPower) - } - // Test nil request - resp, err := keeper.ActiveFinalityProvidersAtHeight(ctx, nil) - if resp != nil { - t.Errorf("Nil input led to a non-nil response") - } - if err == nil { - t.Errorf("Nil input led to a nil error") - } - - // Generate a page request with a limit and a nil key - limit := datagen.RandomInt(r, int(numFpsWithVotingPower)) + 1 - pagination := constructRequestWithLimit(r, limit) - // Generate the initial query - req := types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} - // Construct a mapping from the finality providers found to a boolean value - // Will be used later to evaluate whether all the finality providers were returned - fpsFound := make(map[string]bool, 0) - - for i := uint64(0); i < numFpsWithVotingPower; i += limit { - resp, err = keeper.ActiveFinalityProvidersAtHeight(ctx, &req) - if err != nil { - t.Errorf("Valid request led to an error %s", err) - } - if resp == nil { - t.Fatalf("Valid request led to a nil response") - } - - for _, fp := range resp.FinalityProviders { - // Check if the pk exists in the map - if _, ok := fpsWithVotingPowerMap[fp.BtcPkHex.MarshalHex()]; !ok { - t.Fatalf("rpc returned a finality provider that was not created") - } - fpsFound[fp.BtcPkHex.MarshalHex()] = true + txHash := btcDel.MustGetStakingTxHash().String() + delView, err := keeper.BTCDelegation(ctx, &types.QueryBTCDelegationRequest{ + StakingTxHashHex: txHash, + }) + require.NoError(t, err) + require.NotNil(t, delView) } - - // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) - req = types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} - } - - if len(fpsFound) != len(fpsWithVotingPowerMap) { - t.Errorf("Some finality providers were missed. Got %d while %d were expected", len(fpsFound), len(fpsWithVotingPowerMap)) - } - }) -} - -func FuzzFinalityProviderDelegations(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // Setup keeper and context - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) - - // covenant and slashing addr - covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, net) - require.NoError(t, err) - slashingPkScript, err := txscript.PayToAddrScript(slashingAddress) - require.NoError(t, err) - slashingChangeLockTime := uint16(101) - - // Generate a slashing rate in the range [0.1, 0.50] i.e., 10-50%. - // NOTE - if the rate is higher or lower, it may produce slashing or change outputs - // with value below the dust threshold, causing test failure. - // Our goal is not to test failure due to such extreme cases here; - // this is already covered in FuzzGeneratingValidStakingSlashingTx - slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - - // Generate a finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - AddFinalityProvider(t, ctx, *keeper, fp) - - startHeight := uint32(datagen.RandomInt(r, 100)) + 1 - endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 - stakingTime := endHeight - startHeight - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - // Generate a random number of BTC delegations under this finality provider - numBTCDels := datagen.RandomInt(r, 10) + 1 - expectedBtcDelsMap := make(map[string]*types.BTCDelegation) - for j := uint64(0); j < numBTCDels; j++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( - r, - t, - net, - []bbn.BIP340PubKey{*fp.BtcPk}, - delSK, - covenantSKs, - covenantPKs, - covenantQuorum, - slashingPkScript, - stakingTime, startHeight, endHeight, 10000, - slashingRate, - slashingChangeLockTime, - ) - require.NoError(t, err) - expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) } - // Test nil request - resp, err := keeper.FinalityProviderDelegations(ctx, nil) - require.Nil(t, resp) - require.Error(t, err) - babylonHeight := datagen.RandomInt(r, 10) + 1 ctx = datagen.WithCtxHeight(ctx, babylonHeight) - keeper.IndexBTCHeight(ctx) + // querying paginated BTC delegations and assert // Generate a page request with a limit and a nil key - // query a page of BTC delegations and assert consistency - limit := datagen.RandomInt(r, len(expectedBtcDelsMap)) + 1 - - // FinalityProviderDelegations loads status, which calls GetTipInfo - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - - keeper.IndexBTCHeight(ctx) - + if len(pendingBtcDelsMap) == 0 { + return + } + limit := datagen.RandomInt(r, len(pendingBtcDelsMap)) + 1 pagination := constructRequestWithLimit(r, limit) - // Generate the initial query - req := types.QueryFinalityProviderDelegationsRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), + req := &types.QueryBTCDelegationsRequest{ + Status: types.BTCDelegationStatus_PENDING, Pagination: pagination, } - // Construct a mapping from the finality providers found to a boolean value - // Will be used later to evaluate whether all the finality providers were returned - btcDelsFound := make(map[string]bool, 0) - for i := uint64(0); i < numBTCDels; i += limit { - resp, err = keeper.FinalityProviderDelegations(ctx, &req) + resp, err := keeper.BTCDelegations(ctx, req) require.NoError(t, err) require.NotNil(t, resp) - for _, btcDels := range resp.BtcDelegatorDelegations { - require.Len(t, btcDels.Dels, 1) - btcDel := btcDels.Dels[0] - require.Equal(t, fp.BtcPk, &btcDel.FpBtcPkList[0]) - // Check if the pk exists in the map - _, ok := expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] + for _, btcDel := range resp.BtcDelegations { + _, ok := pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] require.True(t, ok) - btcDelsFound[btcDel.BtcPk.MarshalHex()] = true + require.Equal(t, stakingTime, btcDel.StakingTime) } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) - req = types.QueryFinalityProviderDelegationsRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Pagination: pagination, - } + pagination.Key = resp.Pagination.NextKey } - require.Equal(t, len(btcDelsFound), len(expectedBtcDelsMap)) - }) } diff --git a/x/btcstaking/keeper/incentive.go b/x/btcstaking/keeper/incentive.go deleted file mode 100644 index 9219b10ff..000000000 --- a/x/btcstaking/keeper/incentive.go +++ /dev/null @@ -1,40 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/store/prefix" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) SetVotingPowerDistCache(ctx context.Context, height uint64, dc *types.VotingPowerDistCache) { - store := k.votingPowerDistCacheStore(ctx) - store.Set(sdk.Uint64ToBigEndian(height), k.cdc.MustMarshal(dc)) -} - -func (k Keeper) GetVotingPowerDistCache(ctx context.Context, height uint64) *types.VotingPowerDistCache { - store := k.votingPowerDistCacheStore(ctx) - rdcBytes := store.Get(sdk.Uint64ToBigEndian(height)) - if len(rdcBytes) == 0 { - return nil - } - var dc types.VotingPowerDistCache - k.cdc.MustUnmarshal(rdcBytes, &dc) - return &dc -} - -func (k Keeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { - store := k.votingPowerDistCacheStore(ctx) - store.Delete(sdk.Uint64ToBigEndian(height)) -} - -// votingPowerDistCacheStore returns the KVStore of the voting power distribution cache -// prefix: VotingPowerDistCacheKey -// key: Babylon block height -// value: VotingPowerDistCache -func (k Keeper) votingPowerDistCacheStore(ctx context.Context) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return prefix.NewStore(storeAdapter, types.VotingPowerDistCacheKey) -} diff --git a/x/btcstaking/keeper/voting_power_table_test.go b/x/btcstaking/keeper/voting_power_table_test.go deleted file mode 100644 index 914c7ce86..000000000 --- a/x/btcstaking/keeper/voting_power_table_test.go +++ /dev/null @@ -1,165 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "testing" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" - "github.com/babylonlabs-io/babylon/testutil/datagen" - btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" -) - -func FuzzVotingPowerTable(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := testutil.NewHelper(t, btclcKeeper, btccKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - h.NoError(err) - - // generate a random batch of finality providers, and commit pub rand list with timestamp - fps := []*types.FinalityProvider{} - numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 - numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) - for i := uint64(0); i < numFps; i++ { - fpSK, _, fp := h.CreateFinalityProvider(r) - h.CommitPubRandList(r, fpSK, fp, 1, 100, true) - fps = append(fps, fp) - } - - // for the first numFpsWithVotingPower finality providers, generate a random number of BTC delegations - numBTCDels := datagen.RandomInt(r, 10) + 1 - stakingValue := datagen.RandomInt(r, 100000) + 100000 - for i := uint64(0); i < numFpsWithVotingPower; i++ { - for j := uint64(0); j < numBTCDels; j++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - h.NoError(err) - stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( - r, - delSK, - fps[i].BtcPk.MustToBTCPK(), - changeAddress.EncodeAddress(), - int64(stakingValue), - 1000, - 0, - 0, - true, - ) - h.NoError(err) - h.CreateCovenantSigs(r, covenantSKs, delMsg, del) - h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) - } - } - - /* - assert the first numFpsWithVotingPower finality providers have voting power - */ - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - err = h.FinalityKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - - for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - require.Equal(t, numBTCDels*stakingValue, power) - } - for i := numFpsWithVotingPower; i < numFps; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - require.Zero(t, power) - } - - // also, get voting power table and assert consistency - powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) - require.NotNil(t, powerTable) - for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - require.Equal(t, powerTable[fps[i].BtcPk.MarshalHex()], power) - } - // the activation height should be the current Babylon height as well - activatedHeight, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) - require.NoError(t, err) - require.Equal(t, babylonHeight, activatedHeight) - - /* - slash a random finality provider and move on - then assert the slashed finality provider does not have voting power - */ - // move to next Babylon height - h.BTCLightClientKeeper = btclcKeeper - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - // slash a random finality provider - slashedIdx := datagen.RandomInt(r, int(numFpsWithVotingPower)) - slashedFp := fps[slashedIdx] - err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, slashedFp.BtcPk.MustMarshal()) - require.NoError(t, err) - // index height and record power table - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - err = h.FinalityKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - - // check if the slashed finality provider's voting power becomes zero - for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - if i == slashedIdx { - require.Zero(t, power) - } else { - require.Equal(t, numBTCDels*stakingValue, power) - } - } - for i := numFpsWithVotingPower; i < numFps; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - require.Zero(t, power) - } - - // also, get voting power table and assert consistency - powerTable = h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) - require.NotNil(t, powerTable) - for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) - if i == slashedIdx { - require.Zero(t, power) - } - require.Equal(t, powerTable[fps[i].BtcPk.MarshalHex()], power) - } - - /* - move to 999th BTC block, then assert none of finality providers has voting power (since end height - w < BTC height) - */ - // replace the old mocked keeper - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 999}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - - for _, fp := range fps { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight) - require.Zero(t, power) - } - - // the activation height should be same as before - activatedHeight2, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) - require.NoError(t, err) - require.Equal(t, activatedHeight, activatedHeight2) - }) -} diff --git a/x/btcstaking/types/btcstaking.go b/x/btcstaking/types/btcstaking.go index 2453c5f2a..5a0fe1b6c 100644 --- a/x/btcstaking/types/btcstaking.go +++ b/x/btcstaking/types/btcstaking.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "sort" "cosmossdk.io/math" @@ -42,40 +41,6 @@ func (fp *FinalityProvider) ValidateBasic() error { return nil } -// SortFinalityProvidersWithZeroedVotingPower sorts the finality providers slice, -// from higher to lower voting power. In the following cases, the voting power -// is treated as zero: -// 1. IsTimestamped is false -// 2. IsJailed is true -func SortFinalityProvidersWithZeroedVotingPower(fps []*FinalityProviderDistInfo) { - sort.SliceStable(fps, func(i, j int) bool { - iShouldBeZeroed := fps[i].IsJailed || !fps[i].IsTimestamped - jShouldBeZeroed := fps[j].IsJailed || !fps[j].IsTimestamped - - if iShouldBeZeroed && !jShouldBeZeroed { - return false - } - - if !iShouldBeZeroed && jShouldBeZeroed { - return true - } - - iPkHex, jPkHex := fps[i].BtcPk.MarshalHex(), fps[j].BtcPk.MarshalHex() - - if iShouldBeZeroed && jShouldBeZeroed { - // Both have zeroed voting power, compare BTC public keys - return iPkHex < jPkHex - } - - // both voting power the same, compare BTC public keys - if fps[i].TotalBondedSat == fps[j].TotalBondedSat { - return iPkHex < jPkHex - } - - return fps[i].TotalBondedSat > fps[j].TotalBondedSat - }) -} - func ExistsDup(btcPKs []bbn.BIP340PubKey) bool { seen := make(map[string]struct{}) diff --git a/x/btcstaking/types/errors.go b/x/btcstaking/types/errors.go index aa9f81779..88c973707 100644 --- a/x/btcstaking/types/errors.go +++ b/x/btcstaking/types/errors.go @@ -6,31 +6,27 @@ import ( // x/btcstaking module sentinel errors var ( - ErrFpNotFound = errorsmod.Register(ModuleName, 1100, "the finality provider is not found") - ErrBTCDelegatorNotFound = errorsmod.Register(ModuleName, 1101, "the BTC delegator is not found") - ErrBTCDelegationNotFound = errorsmod.Register(ModuleName, 1102, "the BTC delegation is not found") - ErrFpRegistered = errorsmod.Register(ModuleName, 1103, "the finality provider has already been registered") - ErrFpAlreadySlashed = errorsmod.Register(ModuleName, 1104, "the finality provider has already been slashed") - ErrBTCStakingNotActivated = errorsmod.Register(ModuleName, 1106, "the BTC staking protocol is not activated yet") - ErrBTCHeightNotFound = errorsmod.Register(ModuleName, 1107, "the BTC height is not found") - ErrReusedStakingTx = errorsmod.Register(ModuleName, 1108, "the BTC staking tx is already used") - ErrInvalidCovenantPK = errorsmod.Register(ModuleName, 1109, "the BTC staking tx specifies a wrong covenant PK") - ErrInvalidStakingTx = errorsmod.Register(ModuleName, 1110, "the BTC staking tx is not valid") - ErrInvalidSlashingTx = errorsmod.Register(ModuleName, 1111, "the BTC slashing tx is not valid") - ErrInvalidCovenantSig = errorsmod.Register(ModuleName, 1112, "the covenant signature is not valid") - ErrCommissionLTMinRate = errorsmod.Register(ModuleName, 1113, "commission cannot be less than min rate") - ErrCommissionGTMaxRate = errorsmod.Register(ModuleName, 1114, "commission cannot be more than one") - ErrInvalidDelegationState = errorsmod.Register(ModuleName, 1115, "Unexpected delegation state") - ErrInvalidUnbondingTx = errorsmod.Register(ModuleName, 1116, "the BTC unbonding tx is not valid") - ErrRewardDistCacheNotFound = errorsmod.Register(ModuleName, 1117, "the reward distribution cache is not found") - ErrEmptyFpList = errorsmod.Register(ModuleName, 1118, "the finality provider list is empty") - ErrInvalidProofOfPossession = errorsmod.Register(ModuleName, 1119, "the proof of possession is not valid") - ErrDuplicatedFp = errorsmod.Register(ModuleName, 1120, "the staking request contains duplicated finality provider public key") - ErrInvalidBTCUndelegateReq = errorsmod.Register(ModuleName, 1121, "invalid undelegation request") - ErrVotingPowerTableNotUpdated = errorsmod.Register(ModuleName, 1122, "voting power table has not been updated") - ErrVotingPowerDistCacheNotFound = errorsmod.Register(ModuleName, 1123, "the voting power distribution cache is not found") - ErrParamsNotFound = errorsmod.Register(ModuleName, 1124, "the parameters are not found") - ErrFpAlreadyJailed = errorsmod.Register(ModuleName, 1125, "the finality provider has already been jailed") - ErrFpNotJailed = errorsmod.Register(ModuleName, 1126, "the finality provider is not jailed") - ErrDuplicatedCovenantSig = errorsmod.Register(ModuleName, 1127, "the covenant signature is already submitted") + ErrFpNotFound = errorsmod.Register(ModuleName, 1100, "the finality provider is not found") + ErrBTCDelegatorNotFound = errorsmod.Register(ModuleName, 1101, "the BTC delegator is not found") + ErrBTCDelegationNotFound = errorsmod.Register(ModuleName, 1102, "the BTC delegation is not found") + ErrFpRegistered = errorsmod.Register(ModuleName, 1103, "the finality provider has already been registered") + ErrFpAlreadySlashed = errorsmod.Register(ModuleName, 1104, "the finality provider has already been slashed") + ErrBTCHeightNotFound = errorsmod.Register(ModuleName, 1105, "the BTC height is not found") + ErrReusedStakingTx = errorsmod.Register(ModuleName, 1106, "the BTC staking tx is already used") + ErrInvalidCovenantPK = errorsmod.Register(ModuleName, 1107, "the BTC staking tx specifies a wrong covenant PK") + ErrInvalidStakingTx = errorsmod.Register(ModuleName, 1108, "the BTC staking tx is not valid") + ErrInvalidSlashingTx = errorsmod.Register(ModuleName, 1109, "the BTC slashing tx is not valid") + ErrInvalidCovenantSig = errorsmod.Register(ModuleName, 1110, "the covenant signature is not valid") + ErrCommissionLTMinRate = errorsmod.Register(ModuleName, 1111, "commission cannot be less than min rate") + ErrCommissionGTMaxRate = errorsmod.Register(ModuleName, 1112, "commission cannot be more than one") + ErrInvalidDelegationState = errorsmod.Register(ModuleName, 1113, "Unexpected delegation state") + ErrInvalidUnbondingTx = errorsmod.Register(ModuleName, 1114, "the BTC unbonding tx is not valid") + ErrEmptyFpList = errorsmod.Register(ModuleName, 1115, "the finality provider list is empty") + ErrInvalidProofOfPossession = errorsmod.Register(ModuleName, 1116, "the proof of possession is not valid") + ErrDuplicatedFp = errorsmod.Register(ModuleName, 1117, "the staking request contains duplicated finality provider public key") + ErrInvalidBTCUndelegateReq = errorsmod.Register(ModuleName, 1118, "invalid undelegation request") + ErrParamsNotFound = errorsmod.Register(ModuleName, 1119, "the parameters are not found") + ErrFpAlreadyJailed = errorsmod.Register(ModuleName, 1120, "the finality provider has already been jailed") + ErrFpNotJailed = errorsmod.Register(ModuleName, 1121, "the finality provider is not jailed") + ErrDuplicatedCovenantSig = errorsmod.Register(ModuleName, 1122, "the covenant signature is already submitted") ) diff --git a/x/btcstaking/types/genesis.pb.go b/x/btcstaking/types/genesis.pb.go index 0f7efa606..e02787029 100644 --- a/x/btcstaking/types/genesis.pb.go +++ b/x/btcstaking/types/genesis.pb.go @@ -32,17 +32,12 @@ type GenesisState struct { FinalityProviders []*FinalityProvider `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` // btc_delegations all the btc delegations in the state. BtcDelegations []*BTCDelegation `protobuf:"bytes,3,rep,name=btc_delegations,json=btcDelegations,proto3" json:"btc_delegations,omitempty"` - // voting_powers the voting power of every finality provider at every block height. - VotingPowers []*VotingPowerFP `protobuf:"bytes,4,rep,name=voting_powers,json=votingPowers,proto3" json:"voting_powers,omitempty"` // block_height_chains the block height of babylon and bitcoin. BlockHeightChains []*BlockHeightBbnToBtc `protobuf:"bytes,5,rep,name=block_height_chains,json=blockHeightChains,proto3" json:"block_height_chains,omitempty"` // btc_delegators contains all the btc delegators with the associated finality provider. BtcDelegators []*BTCDelegator `protobuf:"bytes,6,rep,name=btc_delegators,json=btcDelegators,proto3" json:"btc_delegators,omitempty"` // all the events and its indexes. Events []*EventIndex `protobuf:"bytes,7,rep,name=events,proto3" json:"events,omitempty"` - // vp_dst_cache is the table of all providers voting power with the total at one specific block. - // TODO: remove this after not storing in the keeper store it anymore. - VpDstCache []*VotingPowerDistCacheBlkHeight `protobuf:"bytes,8,rep,name=vp_dst_cache,json=vpDstCache,proto3" json:"vp_dst_cache,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -99,13 +94,6 @@ func (m *GenesisState) GetBtcDelegations() []*BTCDelegation { return nil } -func (m *GenesisState) GetVotingPowers() []*VotingPowerFP { - if m != nil { - return m.VotingPowers - } - return nil -} - func (m *GenesisState) GetBlockHeightChains() []*BlockHeightBbnToBtc { if m != nil { return m.BlockHeightChains @@ -127,126 +115,6 @@ func (m *GenesisState) GetEvents() []*EventIndex { return nil } -func (m *GenesisState) GetVpDstCache() []*VotingPowerDistCacheBlkHeight { - if m != nil { - return m.VpDstCache - } - return nil -} - -// VotingPowerFP contains the information about the voting power -// of an finality provider in a specific block height. -type VotingPowerFP struct { - // block_height is the height of the block the voting power was stored. - BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // fp_btc_pk the finality provider btc public key. - FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` - // voting_power is the power of the finality provider at this specific block height. - VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` -} - -func (m *VotingPowerFP) Reset() { *m = VotingPowerFP{} } -func (m *VotingPowerFP) String() string { return proto.CompactTextString(m) } -func (*VotingPowerFP) ProtoMessage() {} -func (*VotingPowerFP) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{1} -} -func (m *VotingPowerFP) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerFP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerFP.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 *VotingPowerFP) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerFP.Merge(m, src) -} -func (m *VotingPowerFP) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerFP) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerFP.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerFP proto.InternalMessageInfo - -func (m *VotingPowerFP) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight - } - return 0 -} - -func (m *VotingPowerFP) GetVotingPower() uint64 { - if m != nil { - return m.VotingPower - } - return 0 -} - -// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height -type VotingPowerDistCacheBlkHeight struct { - // block_height is the height of the block the voting power distribution cached was stored. - BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // vp_distribution the finality providers distribution cache at that height. - VpDistribution *VotingPowerDistCache `protobuf:"bytes,2,opt,name=vp_distribution,json=vpDistribution,proto3" json:"vp_distribution,omitempty"` -} - -func (m *VotingPowerDistCacheBlkHeight) Reset() { *m = VotingPowerDistCacheBlkHeight{} } -func (m *VotingPowerDistCacheBlkHeight) String() string { return proto.CompactTextString(m) } -func (*VotingPowerDistCacheBlkHeight) ProtoMessage() {} -func (*VotingPowerDistCacheBlkHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{2} -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerDistCacheBlkHeight.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 *VotingPowerDistCacheBlkHeight) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerDistCacheBlkHeight.Merge(m, src) -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerDistCacheBlkHeight) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerDistCacheBlkHeight.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerDistCacheBlkHeight proto.InternalMessageInfo - -func (m *VotingPowerDistCacheBlkHeight) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight - } - return 0 -} - -func (m *VotingPowerDistCacheBlkHeight) GetVpDistribution() *VotingPowerDistCache { - if m != nil { - return m.VpDistribution - } - return nil -} - // BlockHeightBbnToBtc stores the btc <-> bbn block. type BlockHeightBbnToBtc struct { // block_height_bbn is the height of the block in the babylon chain. @@ -259,7 +127,7 @@ func (m *BlockHeightBbnToBtc) Reset() { *m = BlockHeightBbnToBtc{} } func (m *BlockHeightBbnToBtc) String() string { return proto.CompactTextString(m) } func (*BlockHeightBbnToBtc) ProtoMessage() {} func (*BlockHeightBbnToBtc) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{3} + return fileDescriptor_85d7b95fa5620238, []int{1} } func (m *BlockHeightBbnToBtc) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -316,7 +184,7 @@ func (m *BTCDelegator) Reset() { *m = BTCDelegator{} } func (m *BTCDelegator) String() string { return proto.CompactTextString(m) } func (*BTCDelegator) ProtoMessage() {} func (*BTCDelegator) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{4} + return fileDescriptor_85d7b95fa5620238, []int{2} } func (m *BTCDelegator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -366,7 +234,7 @@ func (m *EventIndex) Reset() { *m = EventIndex{} } func (m *EventIndex) String() string { return proto.CompactTextString(m) } func (*EventIndex) ProtoMessage() {} func (*EventIndex) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{5} + return fileDescriptor_85d7b95fa5620238, []int{3} } func (m *EventIndex) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,8 +286,6 @@ func (m *EventIndex) GetEvent() *EventPowerDistUpdate { func init() { proto.RegisterType((*GenesisState)(nil), "babylon.btcstaking.v1.GenesisState") - proto.RegisterType((*VotingPowerFP)(nil), "babylon.btcstaking.v1.VotingPowerFP") - proto.RegisterType((*VotingPowerDistCacheBlkHeight)(nil), "babylon.btcstaking.v1.VotingPowerDistCacheBlkHeight") proto.RegisterType((*BlockHeightBbnToBtc)(nil), "babylon.btcstaking.v1.BlockHeightBbnToBtc") proto.RegisterType((*BTCDelegator)(nil), "babylon.btcstaking.v1.BTCDelegator") proto.RegisterType((*EventIndex)(nil), "babylon.btcstaking.v1.EventIndex") @@ -430,51 +296,42 @@ func init() { } var fileDescriptor_85d7b95fa5620238 = []byte{ - // 697 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x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0xfe, 0xbb, 0x92, 0xdb, 0xa2, - 0xaf, 0xea, 0xb0, 0x92, 0xdb, 0xca, 0xbb, 0x59, 0x50, 0xc9, 0xc7, 0x0c, 0xb6, 0x41, 0x81, 0x38, - 0x27, 0x82, 0x5b, 0x6e, 0xb5, 0xa6, 0x08, 0x66, 0xf6, 0x0e, 0x93, 0x94, 0xc5, 0xe5, 0xff, 0xe8, - 0x56, 0x3b, 0x00, 0x38, 0xd8, 0xbb, 0xc0, 0x16, 0xfe, 0x12, 0xbb, 0xe0, 0x60, 0x4f, 0x70, 0x95, - 0xf7, 0x12, 0x00, 0xd9, 0x3b, 0x81, 0x4b, 0xd9, 0x08, 0x8a, 0x89, 0x9d, 0xa9, 0xe7, 0x09, 0x1f, - 0x83, 0x39, 0xf1, 0xca, 0x44, 0x77, 0xe3, 0x63, 0x20, 0x4e, 0xbb, 0x4c, 0xc1, 0x9b, 0xc0, 0xb1, - 0x38, 0x36, 0x92, 0x4a, 0xed, 0xd5, 0xe7, 0xb3, 0xba, 0x74, 0x7a, 0x56, 0x97, 0xbe, 0x9f, 0xd5, - 0xa5, 0x0f, 0xe7, 0xf5, 0x99, 0xd3, 0xf3, 0xfa, 0xcc, 0x97, 0xf3, 0xfa, 0xcc, 0xe1, 0x14, 0x3e, - 0x4f, 0xf2, 0x7f, 0x05, 0x61, 0x1a, 0x95, 0xc4, 0x2f, 0x61, 0xfb, 0x67, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xbe, 0x5e, 0x58, 0xd0, 0xfd, 0x06, 0x00, 0x00, + // 556 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x4f, 0x6f, 0xd3, 0x3c, + 0x1c, 0xc7, 0x9b, 0x76, 0xeb, 0x9e, 0xc7, 0xed, 0xca, 0xe6, 0x81, 0x14, 0x55, 0x22, 0x94, 0x0e, + 0x41, 0x05, 0x22, 0x61, 0xdd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x5f, 0x83, 0x2b, 0x48, + 0xe2, 0x8e, 0x4f, 0x42, 0x12, 0x78, 0x92, 0x72, 0x26, 0xf4, 0x82, 0x92, 0xde, 0x5a, 0x22, 0xb5, + 0xdb, 0x87, 0xad, 0x5f, 0xb0, 0x5b, 0x41, 0x12, 0x67, 0xaf, 0x02, 0x9e, 0x80, 0x1d, 0x14, 0x72, + 0xdc, 0xef, 0xf4, 0x08, 0x0d, 0x7a, 0xb2, 0x83, 0x7b, 0x1e, 0x65, 0x42, 0x5f, 0x57, 0xca, 0xbb, + 0xcb, 0x94, 0xd3, 0x89, 0x17, 0x6a, 0xc0, 0x46, 0xac, 0xcd, 0x6d, 0x89, 0xdd, 0x6d, 0x94, 0x7d, + 0x3c, 0x54, 0x12, 0xf8, 0x12, 0x54, 0x66, 0xa2, 0xf2, 0x58, 0xe8, 0x45, 0xa5, 0xdd, 0xfd, 0x6b, + 0x52, 0x1e, 0xbb, 0x9b, 0x59, 0x50, 0x1e, 0x0b, 0xf8, 0x18, 0x14, 0x93, 0x35, 0xe9, 0x1b, 0xca, + 0x71, 0x73, 0x89, 0xe3, 0xe9, 0x14, 0x3a, 0x62, 0x3e, 0x19, 0xba, 0xe9, 0x40, 0x9d, 0x82, 0x9d, + 0x05, 0x81, 0x61, 0x03, 0x6c, 0xcd, 0x35, 0x47, 0x88, 0xe9, 0x5a, 0x4d, 0x6b, 0xac, 0xb9, 0x15, + 0x34, 0x87, 0xff, 0x49, 0x4a, 0xac, 0xe7, 0x6b, 0x5a, 0x63, 0x73, 0x9e, 0x94, 0xb8, 0xfe, 0x21, + 0x0f, 0xca, 0xb3, 0x2d, 0x60, 0x0b, 0x14, 0xa8, 0x3f, 0x54, 0xde, 0x52, 0xb3, 0xb9, 0x42, 0xef, + 0x6c, 0x37, 0x49, 0x89, 0xe9, 0x38, 0x6c, 0x83, 0xff, 0xbb, 0xd1, 0xf4, 0xd8, 0x4e, 0xd4, 0x57, + 0x27, 0x97, 0xed, 0x47, 0xdf, 0xbe, 0xdf, 0x38, 0x08, 0xa8, 0xec, 0x9d, 0x21, 0x13, 0xf3, 0x53, + 0x2b, 0x35, 0x87, 0x1e, 0x12, 0xf7, 0x29, 0xbf, 0x78, 0xb5, 0xe4, 0x28, 0x22, 0xc2, 0xb4, 0x8f, + 0x9c, 0xfd, 0x83, 0x07, 0xce, 0x19, 0x7a, 0x45, 0x46, 0xee, 0x46, 0x37, 0xb2, 0x25, 0x76, 0xfa, + 0xf0, 0x18, 0x00, 0x9f, 0x84, 0x17, 0xda, 0xc2, 0x3f, 0x6a, 0xff, 0xf3, 0x49, 0xa8, 0xbc, 0xf5, + 0x8f, 0x1a, 0x00, 0xd9, 0x1a, 0xe0, 0x56, 0xf6, 0x0b, 0xd6, 0x92, 0x3a, 0x2b, 0xff, 0x4f, 0xf8, + 0x04, 0xac, 0xab, 0x25, 0xaa, 0x74, 0xa5, 0xe6, 0xbd, 0xcb, 0x96, 0xee, 0xf0, 0xf7, 0x24, 0x6e, + 0x51, 0x21, 0xdf, 0x45, 0xbe, 0x27, 0x89, 0x9b, 0x4c, 0xda, 0x6f, 0x3e, 0x8f, 0x0d, 0xed, 0x7c, + 0x6c, 0x68, 0x3f, 0xc6, 0x86, 0xf6, 0x69, 0x62, 0xe4, 0xce, 0x27, 0x46, 0xee, 0xeb, 0xc4, 0xc8, + 0x9d, 0xac, 0xd0, 0x73, 0x38, 0x7b, 0x53, 0xa8, 0xd2, 0xa8, 0xa8, 0xae, 0x89, 0xfd, 0x9f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x54, 0x96, 0xa0, 0xb9, 0xea, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -497,20 +354,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.VpDstCache) > 0 { - for iNdEx := len(m.VpDstCache) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VpDstCache[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } if len(m.Events) > 0 { for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { { @@ -553,20 +396,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if len(m.VotingPowers) > 0 { - for iNdEx := len(m.VotingPowers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VotingPowers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } if len(m.BtcDelegations) > 0 { for iNdEx := len(m.BtcDelegations) - 1; iNdEx >= 0; iNdEx-- { { @@ -612,91 +441,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *VotingPowerFP) 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 *VotingPowerFP) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerFP) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x18 - } - if m.FpBtcPk != nil { - { - size := m.FpBtcPk.Size() - i -= size - if _, err := m.FpBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BlockHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *VotingPowerDistCacheBlkHeight) 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 *VotingPowerDistCacheBlkHeight) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerDistCacheBlkHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VpDistribution != nil { - { - size, err := m.VpDistribution.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BlockHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *BlockHeightBbnToBtc) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -869,12 +613,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.VotingPowers) > 0 { - for _, e := range m.VotingPowers { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } if len(m.BlockHeightChains) > 0 { for _, e := range m.BlockHeightChains { l = e.Size() @@ -893,47 +631,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.VpDstCache) > 0 { - for _, e := range m.VpDstCache { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - -func (m *VotingPowerFP) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeight != 0 { - n += 1 + sovGenesis(uint64(m.BlockHeight)) - } - if m.FpBtcPk != nil { - l = m.FpBtcPk.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.VotingPower != 0 { - n += 1 + sovGenesis(uint64(m.VotingPower)) - } - return n -} - -func (m *VotingPowerDistCacheBlkHeight) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeight != 0 { - n += 1 + sovGenesis(uint64(m.BlockHeight)) - } - if m.VpDistribution != nil { - l = m.VpDistribution.Size() - n += 1 + l + sovGenesis(uint64(l)) - } return n } @@ -1129,40 +826,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPowers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VotingPowers = append(m.VotingPowers, &VotingPowerFP{}) - if err := m.VotingPowers[len(m.VotingPowers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlockHeightChains", wireType) @@ -1265,268 +928,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VpDstCache", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VpDstCache = append(m.VpDstCache, &VotingPowerDistCacheBlkHeight{}) - if err := m.VpDstCache[len(m.VpDstCache)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VotingPowerFP) 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 ErrIntOverflowGenesis - } - 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: VotingPowerFP: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerFP: 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 ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.FpBtcPk = &v - if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - 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 ErrIntOverflowGenesis - } - 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 := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VotingPowerDistCacheBlkHeight) 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 ErrIntOverflowGenesis - } - 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: VotingPowerDistCacheBlkHeight: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerDistCacheBlkHeight: 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 ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VpDistribution", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.VpDistribution == nil { - m.VpDistribution = &VotingPowerDistCache{} - } - if err := m.VpDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/incentive.pb.go b/x/btcstaking/types/incentive.pb.go deleted file mode 100644 index 557cd62c0..000000000 --- a/x/btcstaking/types/incentive.pb.go +++ /dev/null @@ -1,1238 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: babylon/btcstaking/v1/incentive.proto - -package types - -import ( - cosmossdk_io_math "cosmossdk.io/math" - fmt "fmt" - github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// VotingPowerDistCache is the cache for voting power distribution of finality providers -// and their BTC delegations at a height -type VotingPowerDistCache struct { - // total_sat is the total amount of bonded BTC stake (in Satoshi) of all the finality providers - // in the cache - TotalBondedSat uint64 `protobuf:"varint,1,opt,name=total_bonded_sat,json=totalBondedSat,proto3" json:"total_bonded_sat,omitempty"` - // finality_providers is a list of finality providers' voting power information - FinalityProviders []*FinalityProviderDistInfo `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` - // num_active_fps is the number of finality providers that have active BTC - // delegations as well as timestamped public randomness - NumActiveFps uint32 `protobuf:"varint,3,opt,name=num_active_fps,json=numActiveFps,proto3" json:"num_active_fps,omitempty"` -} - -func (m *VotingPowerDistCache) Reset() { *m = VotingPowerDistCache{} } -func (m *VotingPowerDistCache) String() string { return proto.CompactTextString(m) } -func (*VotingPowerDistCache) ProtoMessage() {} -func (*VotingPowerDistCache) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{0} -} -func (m *VotingPowerDistCache) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerDistCache.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 *VotingPowerDistCache) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerDistCache.Merge(m, src) -} -func (m *VotingPowerDistCache) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerDistCache) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerDistCache.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerDistCache proto.InternalMessageInfo - -// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations -type FinalityProviderDistInfo struct { - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // addr is the address to receive commission from delegations. - Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` - // commission defines the commission rate of finality provider - Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` - // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider - TotalBondedSat uint64 `protobuf:"varint,4,opt,name=total_bonded_sat,json=totalBondedSat,proto3" json:"total_bonded_sat,omitempty"` - // btc_dels is a list of BTC delegations' voting power information under this finality provider - BtcDels []*BTCDelDistInfo `protobuf:"bytes,5,rep,name=btc_dels,json=btcDels,proto3" json:"btc_dels,omitempty"` - // is_timestamped indicates whether the finality provider - // has timestamped public randomness committed - // if no, it should not be assigned voting power - IsTimestamped bool `protobuf:"varint,6,opt,name=is_timestamped,json=isTimestamped,proto3" json:"is_timestamped,omitempty"` - // is_jailed indicates whether the finality provider - // is jailed, if so, it should not be assigned voting power - IsJailed bool `protobuf:"varint,7,opt,name=is_jailed,json=isJailed,proto3" json:"is_jailed,omitempty"` - // is_slashed indicates whether the finality provider - // is slashed, if so, it should not be assigned voting power - IsSlashed bool `protobuf:"varint,8,opt,name=is_slashed,json=isSlashed,proto3" json:"is_slashed,omitempty"` -} - -func (m *FinalityProviderDistInfo) Reset() { *m = FinalityProviderDistInfo{} } -func (m *FinalityProviderDistInfo) String() string { return proto.CompactTextString(m) } -func (*FinalityProviderDistInfo) ProtoMessage() {} -func (*FinalityProviderDistInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{1} -} -func (m *FinalityProviderDistInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FinalityProviderDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FinalityProviderDistInfo.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 *FinalityProviderDistInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_FinalityProviderDistInfo.Merge(m, src) -} -func (m *FinalityProviderDistInfo) XXX_Size() int { - return m.Size() -} -func (m *FinalityProviderDistInfo) XXX_DiscardUnknown() { - xxx_messageInfo_FinalityProviderDistInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_FinalityProviderDistInfo proto.InternalMessageInfo - -func (m *FinalityProviderDistInfo) GetAddr() string { - if m != nil { - return m.Addr - } - return "" -} - -func (m *FinalityProviderDistInfo) GetTotalBondedSat() uint64 { - if m != nil { - return m.TotalBondedSat - } - return 0 -} - -func (m *FinalityProviderDistInfo) GetBtcDels() []*BTCDelDistInfo { - if m != nil { - return m.BtcDels - } - return nil -} - -func (m *FinalityProviderDistInfo) GetIsTimestamped() bool { - if m != nil { - return m.IsTimestamped - } - return false -} - -func (m *FinalityProviderDistInfo) GetIsJailed() bool { - if m != nil { - return m.IsJailed - } - return false -} - -func (m *FinalityProviderDistInfo) GetIsSlashed() bool { - if m != nil { - return m.IsSlashed - } - return false -} - -// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation -type BTCDelDistInfo struct { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // staker_addr is the address to receive rewards from BTC delegation. - StakerAddr string `protobuf:"bytes,2,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` - // staking_tx_hash is the staking tx hash of the BTC delegation - StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` - // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation - TotalSat uint64 `protobuf:"varint,4,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` -} - -func (m *BTCDelDistInfo) Reset() { *m = BTCDelDistInfo{} } -func (m *BTCDelDistInfo) String() string { return proto.CompactTextString(m) } -func (*BTCDelDistInfo) ProtoMessage() {} -func (*BTCDelDistInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{2} -} -func (m *BTCDelDistInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCDelDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelDistInfo.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 *BTCDelDistInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelDistInfo.Merge(m, src) -} -func (m *BTCDelDistInfo) XXX_Size() int { - return m.Size() -} -func (m *BTCDelDistInfo) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelDistInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCDelDistInfo proto.InternalMessageInfo - -func (m *BTCDelDistInfo) GetStakerAddr() string { - if m != nil { - return m.StakerAddr - } - return "" -} - -func (m *BTCDelDistInfo) GetStakingTxHash() string { - if m != nil { - return m.StakingTxHash - } - return "" -} - -func (m *BTCDelDistInfo) GetTotalSat() uint64 { - if m != nil { - return m.TotalSat - } - return 0 -} - -func init() { - proto.RegisterType((*VotingPowerDistCache)(nil), "babylon.btcstaking.v1.VotingPowerDistCache") - proto.RegisterType((*FinalityProviderDistInfo)(nil), "babylon.btcstaking.v1.FinalityProviderDistInfo") - proto.RegisterType((*BTCDelDistInfo)(nil), "babylon.btcstaking.v1.BTCDelDistInfo") -} - -func init() { - proto.RegisterFile("babylon/btcstaking/v1/incentive.proto", fileDescriptor_ac354c3bd6d7a66b) -} - -var fileDescriptor_ac354c3bd6d7a66b = []byte{ - // 606 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x4f, 0x13, 0x41, - 0x18, 0xc6, 0xbb, 0x50, 0xa0, 0x1d, 0xa0, 0xea, 0x06, 0x93, 0x15, 0x62, 0x69, 0x88, 0x98, 0x1e, - 0xec, 0xae, 0x08, 0x07, 0xf5, 0x24, 0x4b, 0x43, 0xc4, 0xbf, 0xcd, 0x96, 0x78, 0xf0, 0xe0, 0x66, - 0x76, 0x66, 0xba, 0x3b, 0x76, 0x77, 0xa6, 0xd9, 0x77, 0x5a, 0xe9, 0x37, 0xf0, 0xe8, 0x47, 0xf0, - 0x43, 0x90, 0xf8, 0x15, 0x3c, 0x78, 0x20, 0x9c, 0x0c, 0x07, 0xa2, 0xf0, 0x45, 0xcc, 0xce, 0xae, - 0x82, 0x06, 0x12, 0x0e, 0xde, 0x3a, 0xcf, 0xfb, 0xcc, 0xfb, 0xce, 0xf3, 0xfe, 0xd2, 0x45, 0xab, - 0x01, 0x0e, 0xc6, 0xb1, 0x14, 0x4e, 0xa0, 0x08, 0x28, 0xdc, 0xe7, 0x22, 0x74, 0x46, 0x6b, 0x0e, - 0x17, 0x84, 0x09, 0xc5, 0x47, 0xcc, 0x1e, 0xa4, 0x52, 0x49, 0xf3, 0x66, 0x61, 0xb3, 0xcf, 0x6c, - 0xf6, 0x68, 0x6d, 0x71, 0x21, 0x94, 0xa1, 0xd4, 0x0e, 0x27, 0xfb, 0x95, 0x9b, 0x17, 0x6f, 0x11, - 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, 0x47, 0x68, 0x36, 0x0b, - 0xcb, 0x52, 0xff, 0x4a, 0xd8, 0x50, 0x6e, 0xce, 0x44, 0xf3, 0x2e, 0xba, 0x56, 0xec, 0xc9, 0x57, - 0x7b, 0x7e, 0x84, 0x21, 0xca, 0x09, 0x7a, 0xf3, 0x85, 0xbc, 0xbb, 0xf7, 0x14, 0x43, 0x94, 0xad, - 0x20, 0xa7, 0x72, 0x86, 0xa3, 0xa2, 0x85, 0x2e, 0x56, 0xee, 0xab, 0xaf, 0x27, 0x75, 0xe3, 0xe0, - 0xa4, 0x6e, 0xfc, 0x38, 0xa9, 0x1b, 0x9f, 0x4e, 0xeb, 0xa5, 0x83, 0xd3, 0x7a, 0xe9, 0xfb, 0x69, - 0xbd, 0xf4, 0xf6, 0x0a, 0xb1, 0xf6, 0xce, 0x7f, 0x11, 0x74, 0xc6, 0x60, 0x5a, 0xff, 0x87, 0xd7, - 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xc9, 0x06, 0x18, 0x34, 0x04, 0x00, 0x00, -} - -func (m *VotingPowerDistCache) 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 *VotingPowerDistCache) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NumActiveFps != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.NumActiveFps)) - i-- - dAtA[i] = 0x18 - } - if len(m.FinalityProviders) > 0 { - for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.TotalBondedSat != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.TotalBondedSat)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *FinalityProviderDistInfo) 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 *FinalityProviderDistInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FinalityProviderDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsSlashed { - i-- - if m.IsSlashed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } - if m.IsJailed { - i-- - if m.IsJailed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x38 - } - if m.IsTimestamped { - i-- - if m.IsTimestamped { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - if len(m.BtcDels) > 0 { - for iNdEx := len(m.BtcDels) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BtcDels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.TotalBondedSat != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.TotalBondedSat)) - i-- - dAtA[i] = 0x20 - } - if m.Commission != nil { - { - size := m.Commission.Size() - i -= size - if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Addr) > 0 { - i -= len(m.Addr) - copy(dAtA[i:], m.Addr) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.Addr))) - i-- - dAtA[i] = 0x12 - } - if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BTCDelDistInfo) 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 *BTCDelDistInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCDelDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TotalSat != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.TotalSat)) - i-- - dAtA[i] = 0x20 - } - if len(m.StakingTxHash) > 0 { - i -= len(m.StakingTxHash) - copy(dAtA[i:], m.StakingTxHash) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.StakingTxHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.StakerAddr) > 0 { - i -= len(m.StakerAddr) - copy(dAtA[i:], m.StakerAddr) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.StakerAddr))) - i-- - dAtA[i] = 0x12 - } - if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintIncentive(dAtA []byte, offset int, v uint64) int { - offset -= sovIncentive(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *VotingPowerDistCache) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TotalBondedSat != 0 { - n += 1 + sovIncentive(uint64(m.TotalBondedSat)) - } - if len(m.FinalityProviders) > 0 { - for _, e := range m.FinalityProviders { - l = e.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - } - if m.NumActiveFps != 0 { - n += 1 + sovIncentive(uint64(m.NumActiveFps)) - } - return n -} - -func (m *FinalityProviderDistInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.Addr) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - if m.Commission != nil { - l = m.Commission.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - if m.TotalBondedSat != 0 { - n += 1 + sovIncentive(uint64(m.TotalBondedSat)) - } - if len(m.BtcDels) > 0 { - for _, e := range m.BtcDels { - l = e.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - } - if m.IsTimestamped { - n += 2 - } - if m.IsJailed { - n += 2 - } - if m.IsSlashed { - n += 2 - } - return n -} - -func (m *BTCDelDistInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.StakerAddr) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.StakingTxHash) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - if m.TotalSat != 0 { - n += 1 + sovIncentive(uint64(m.TotalSat)) - } - return n -} - -func sovIncentive(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozIncentive(x uint64) (n int) { - return sovIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *VotingPowerDistCache) 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 ErrIntOverflowIncentive - } - 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: VotingPowerDistCache: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerDistCache: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalBondedSat", wireType) - } - m.TotalBondedSat = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalBondedSat |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderDistInfo{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumActiveFps", wireType) - } - m.NumActiveFps = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumActiveFps |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FinalityProviderDistInfo) 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 ErrIntOverflowIncentive - } - 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: FinalityProviderDistInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FinalityProviderDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.LegacyDec - m.Commission = &v - if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalBondedSat", wireType) - } - m.TotalBondedSat = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalBondedSat |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcDels", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BtcDels = append(m.BtcDels, &BTCDelDistInfo{}) - if err := m.BtcDels[len(m.BtcDels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsTimestamped", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsTimestamped = bool(v != 0) - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsJailed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsJailed = bool(v != 0) - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsSlashed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsSlashed = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BTCDelDistInfo) 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 ErrIntOverflowIncentive - } - 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: BTCDelDistInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BTCDelDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakerAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakingTxHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) - } - m.TotalSat = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalSat |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipIncentive(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthIncentive - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupIncentive - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthIncentive - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthIncentive = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowIncentive = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupIncentive = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/btcstaking/types/incentive_test.go b/x/btcstaking/types/incentive_test.go deleted file mode 100644 index d70995b62..000000000 --- a/x/btcstaking/types/incentive_test.go +++ /dev/null @@ -1,189 +0,0 @@ -package types - -import ( - "testing" - - "github.com/btcsuite/btcd/btcec/v2" - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/types" -) - -var ( - fpPrivKey1, _ = btcec.NewPrivateKey() - fpPrivKey2, _ = btcec.NewPrivateKey() - fpPubKey1 = types.NewBIP340PubKeyFromBTCPK(fpPrivKey1.PubKey()) - fpPubKey2 = types.NewBIP340PubKeyFromBTCPK(fpPrivKey2.PubKey()) -) - -func TestVotingPowerDistCache(t *testing.T) { - tests := []struct { - desc string - maxActiveFPs uint32 - numActiveFps uint32 - numInactiveFps uint32 - totalVotingPower uint64 - prevDistCache *VotingPowerDistCache - fps []*FinalityProviderDistInfo - }{ - { - desc: "all not timestamped", - maxActiveFPs: 80, - numActiveFps: 0, - numInactiveFps: 2, - totalVotingPower: 0, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: false, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 2000, - IsTimestamped: false, - }, - }, - }, - { - desc: "all timestamped", - maxActiveFPs: 80, - numActiveFps: 2, - numInactiveFps: 0, - totalVotingPower: 3000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 2000, - IsTimestamped: true, - }, - }, - }, - { - desc: "partly timestamped", - maxActiveFPs: 80, - numActiveFps: 1, - numInactiveFps: 1, - totalVotingPower: 1000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 2000, - IsTimestamped: false, - }, - }, - }, - { - desc: "small max active fps", - maxActiveFPs: 1, - numActiveFps: 1, - numInactiveFps: 1, - totalVotingPower: 2000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 2000, - IsTimestamped: true, - }, - }, - }, - { - desc: "one got jailed", - maxActiveFPs: 80, - numActiveFps: 1, - numInactiveFps: 0, - totalVotingPower: 1000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 2000, - IsTimestamped: true, - IsJailed: true, - }, - }, - }, - { - desc: "one got slashed", - maxActiveFPs: 80, - numActiveFps: 1, - numInactiveFps: 0, - totalVotingPower: 1000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalBondedSat: 0, // a jailed fp cannot accept delegation - IsTimestamped: true, - IsSlashed: true, - }, - }, - }, - { - desc: "previous one got unjailed", - maxActiveFPs: 80, - numActiveFps: 1, - numInactiveFps: 0, - totalVotingPower: 1000, - prevDistCache: NewVotingPowerDistCacheWithFinalityProviders( - []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - IsJailed: true, - }}), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalBondedSat: 1000, - IsTimestamped: true, - IsJailed: false, - }, - }, - }, - } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - dc := NewVotingPowerDistCacheWithFinalityProviders(tc.fps) - dc.ApplyActiveFinalityProviders(tc.maxActiveFPs) - require.Equal(t, tc.totalVotingPower, dc.TotalBondedSat) - require.Equal(t, tc.numActiveFps, dc.NumActiveFps) - - newActiveFps := dc.FindNewActiveFinalityProviders(tc.prevDistCache) - require.Equal(t, tc.numActiveFps, uint32(len(newActiveFps))) - - newInactiveFps := dc.FindNewInactiveFinalityProviders(tc.prevDistCache) - require.Equal(t, tc.numInactiveFps, uint32(len(newInactiveFps))) - }) - } -} diff --git a/x/btcstaking/types/keys.go b/x/btcstaking/types/keys.go index 099e808cd..93defdfbc 100644 --- a/x/btcstaking/types/keys.go +++ b/x/btcstaking/types/keys.go @@ -15,12 +15,12 @@ const ( ) var ( - ParamsKey = []byte{0x01} // key prefix for the parameters - FinalityProviderKey = []byte{0x02} // key prefix for the finality providers - BTCDelegatorKey = []byte{0x03} // key prefix for the BTC delegators - BTCDelegationKey = []byte{0x04} // key prefix for the BTC delegations - VotingPowerKey = []byte{0x05} // key prefix for the voting power - BTCHeightKey = []byte{0x06} // key prefix for the BTC heights - VotingPowerDistCacheKey = []byte{0x07} // key prefix for voting power distribution cache - PowerDistUpdateKey = []byte{0x08} // key prefix for power distribution update events + ParamsKey = []byte{0x01} // key prefix for the parameters + FinalityProviderKey = []byte{0x02} // key prefix for the finality providers + BTCDelegatorKey = []byte{0x03} // key prefix for the BTC delegators + BTCDelegationKey = []byte{0x04} // key prefix for the BTC delegations + // 0x05 was used for something else in the past + BTCHeightKey = []byte{0x06} // key prefix for the BTC heights + // 0x07 was used for something else in the past + PowerDistUpdateKey = []byte{0x08} // key prefix for power distribution update events ) diff --git a/x/btcstaking/types/query.go b/x/btcstaking/types/query.go index be17f52d7..35a706399 100644 --- a/x/btcstaking/types/query.go +++ b/x/btcstaking/types/query.go @@ -69,8 +69,8 @@ func (ud *BTCUndelegation) ToResponse() (resp *BTCUndelegationResponse) { return resp } -// NewFinalityProviderResponse creates a new finality provider response based on the finaliny provider and his voting power. -func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight, votingPower uint64) *FinalityProviderResponse { +// NewFinalityProviderResponse creates a new finality provider response based on the finality provider +func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight uint64) *FinalityProviderResponse { return &FinalityProviderResponse{ Description: f.Description, Commission: f.Commission, @@ -81,6 +81,5 @@ func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight, votingPowe SlashedBtcHeight: f.SlashedBtcHeight, Jailed: f.Jailed, Height: bbnBlockHeight, - VotingPower: votingPower, } } diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index 19e54f6e9..8ed1ef4bc 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -515,33 +515,31 @@ func (m *QueryBTCDelegationsResponse) GetPagination() *query.PageResponse { return nil } -// QueryFinalityProviderPowerAtHeightRequest is the request type for the -// Query/FinalityProviderPowerAtHeight RPC method. -type QueryFinalityProviderPowerAtHeightRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that +// QueryFinalityProviderDelegationsRequest is the request type for the +// Query/FinalityProviderDelegations RPC method. +type QueryFinalityProviderDelegationsRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality providerthat // this BTC delegation delegates to // the PK follows encoding in BIP-340 spec FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // height is used for querying the given finality provider's voting power at this height - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryFinalityProviderPowerAtHeightRequest) Reset() { - *m = QueryFinalityProviderPowerAtHeightRequest{} -} -func (m *QueryFinalityProviderPowerAtHeightRequest) String() string { - return proto.CompactTextString(m) +func (m *QueryFinalityProviderDelegationsRequest) Reset() { + *m = QueryFinalityProviderDelegationsRequest{} } -func (*QueryFinalityProviderPowerAtHeightRequest) ProtoMessage() {} -func (*QueryFinalityProviderPowerAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderDelegationsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderDelegationsRequest) ProtoMessage() {} +func (*QueryFinalityProviderDelegationsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{10} } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -551,55 +549,55 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, determ return b[:n], nil } } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Merge(m, src) +func (m *QueryFinalityProviderDelegationsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Merge(m, src) } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Size() int { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderDelegationsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderDelegationsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderDelegationsRequest proto.InternalMessageInfo -func (m *QueryFinalityProviderPowerAtHeightRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderDelegationsRequest) GetFpBtcPkHex() string { if m != nil { return m.FpBtcPkHex } return "" } -func (m *QueryFinalityProviderPowerAtHeightRequest) GetHeight() uint64 { +func (m *QueryFinalityProviderDelegationsRequest) GetPagination() *query.PageRequest { if m != nil { - return m.Height + return m.Pagination } - return 0 + return nil } -// QueryFinalityProviderPowerAtHeightResponse is the response type for the -// Query/FinalityProviderPowerAtHeight RPC method. -type QueryFinalityProviderPowerAtHeightResponse struct { - // voting_power is the voting power of the finality provider - VotingPower uint64 `protobuf:"varint,1,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +// QueryFinalityProviderDelegationsResponse is the response type for the +// Query/FinalityProviderDelegations RPC method. +type QueryFinalityProviderDelegationsResponse struct { + // btc_delegator_delegations contains all the queried BTC delegations. + BtcDelegatorDelegations []*BTCDelegatorDelegationsResponse `protobuf:"bytes,1,rep,name=btc_delegator_delegations,json=btcDelegatorDelegations,proto3" json:"btc_delegator_delegations,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryFinalityProviderPowerAtHeightResponse) Reset() { - *m = QueryFinalityProviderPowerAtHeightResponse{} -} -func (m *QueryFinalityProviderPowerAtHeightResponse) String() string { - return proto.CompactTextString(m) +func (m *QueryFinalityProviderDelegationsResponse) Reset() { + *m = QueryFinalityProviderDelegationsResponse{} } -func (*QueryFinalityProviderPowerAtHeightResponse) ProtoMessage() {} -func (*QueryFinalityProviderPowerAtHeightResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderDelegationsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderDelegationsResponse) ProtoMessage() {} +func (*QueryFinalityProviderDelegationsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{11} } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -609,48 +607,51 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deter return b[:n], nil } } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Merge(m, src) +func (m *QueryFinalityProviderDelegationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Merge(m, src) } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Size() int { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderDelegationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderDelegationsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderDelegationsResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderPowerAtHeightResponse) GetVotingPower() uint64 { +func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegationsResponse { if m != nil { - return m.VotingPower + return m.BtcDelegatorDelegations } - return 0 + return nil } -// QueryFinalityProviderCurrentPowerRequest is the request type for the -// Query/FinalityProviderCurrentPower RPC method. -type QueryFinalityProviderCurrentPowerRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +func (m *QueryFinalityProviderDelegationsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryFinalityProviderCurrentPowerRequest) Reset() { - *m = QueryFinalityProviderCurrentPowerRequest{} +// QueryBTCDelegationRequest is the request type to retrieve a BTC delegation by +// staking tx hash +type QueryBTCDelegationRequest struct { + // Hash of staking transaction in btc format + StakingTxHashHex string `protobuf:"bytes,1,opt,name=staking_tx_hash_hex,json=stakingTxHashHex,proto3" json:"staking_tx_hash_hex,omitempty"` } -func (m *QueryFinalityProviderCurrentPowerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderCurrentPowerRequest) ProtoMessage() {} -func (*QueryFinalityProviderCurrentPowerRequest) Descriptor() ([]byte, []int) { + +func (m *QueryBTCDelegationRequest) Reset() { *m = QueryBTCDelegationRequest{} } +func (m *QueryBTCDelegationRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBTCDelegationRequest) ProtoMessage() {} +func (*QueryBTCDelegationRequest) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{12} } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryBTCDelegationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBTCDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBTCDelegationRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -660,50 +661,44 @@ func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, determi return b[:n], nil } } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Merge(m, src) +func (m *QueryBTCDelegationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCDelegationRequest.Merge(m, src) } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Size() int { +func (m *QueryBTCDelegationRequest) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.DiscardUnknown(m) +func (m *QueryBTCDelegationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCDelegationRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryBTCDelegationRequest proto.InternalMessageInfo -func (m *QueryFinalityProviderCurrentPowerRequest) GetFpBtcPkHex() string { +func (m *QueryBTCDelegationRequest) GetStakingTxHashHex() string { if m != nil { - return m.FpBtcPkHex + return m.StakingTxHashHex } return "" } -// QueryFinalityProviderCurrentPowerResponse is the response type for the -// Query/FinalityProviderCurrentPower RPC method. -type QueryFinalityProviderCurrentPowerResponse 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 finality provider - VotingPower uint64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +// QueryBTCDelegationResponse is response type matching QueryBTCDelegationRequest +// and containing BTC delegation information +type QueryBTCDelegationResponse struct { + // BTCDelegation represents the client needed information of an BTCDelegation. + BtcDelegation *BTCDelegationResponse `protobuf:"bytes,1,opt,name=btc_delegation,json=btcDelegation,proto3" json:"btc_delegation,omitempty"` } -func (m *QueryFinalityProviderCurrentPowerResponse) Reset() { - *m = QueryFinalityProviderCurrentPowerResponse{} -} -func (m *QueryFinalityProviderCurrentPowerResponse) String() string { - return proto.CompactTextString(m) -} -func (*QueryFinalityProviderCurrentPowerResponse) ProtoMessage() {} -func (*QueryFinalityProviderCurrentPowerResponse) Descriptor() ([]byte, []int) { +func (m *QueryBTCDelegationResponse) Reset() { *m = QueryBTCDelegationResponse{} } +func (m *QueryBTCDelegationResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBTCDelegationResponse) ProtoMessage() {} +func (*QueryBTCDelegationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{13} } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBTCDelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -713,57 +708,85 @@ func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, determ return b[:n], nil } } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Merge(m, src) +func (m *QueryBTCDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCDelegationResponse.Merge(m, src) } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Size() int { +func (m *QueryBTCDelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.DiscardUnknown(m) +func (m *QueryBTCDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCDelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse proto.InternalMessageInfo - -func (m *QueryFinalityProviderCurrentPowerResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} +var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderCurrentPowerResponse) GetVotingPower() uint64 { +func (m *QueryBTCDelegationResponse) GetBtcDelegation() *BTCDelegationResponse { if m != nil { - return m.VotingPower + return m.BtcDelegation } - return 0 + return nil } -// QueryActiveFinalityProvidersAtHeightRequest is the request type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -type QueryActiveFinalityProvidersAtHeightRequest struct { - // height defines at which Babylon height to query the finality providers info. - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// BTCDelegationResponse is the client needed information from a BTCDelegation with the current status based on parameters. +type BTCDelegationResponse struct { + // staker_addr is the address to receive rewards from BTC delegation. + StakerAddr string `protobuf:"bytes,1,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that + // this BTC delegation delegates to + FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + // staking_time is the number of blocks for which the delegation is locked on BTC chain + StakingTime uint32 `protobuf:"varint,4,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + StartHeight uint32 `protobuf:"varint,5,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // end_height is the end height of the BTC delegation + // it is the end BTC height of the timelock - w + EndHeight uint32 `protobuf:"varint,6,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + // total_sat is the total amount of BTC stakes in this delegation + // quantified in satoshi + TotalSat uint64 `protobuf:"varint,7,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` + // staking_tx_hex is the hex string of staking tx + StakingTxHex string `protobuf:"bytes,8,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` + // slashing_tx_hex is the hex string of slashing tx + SlashingTxHex string `protobuf:"bytes,9,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` + // delegator_slash_sig_hex is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk) as string hex. + // It will be a part of the witness for the staking tx output. + DelegatorSlashSigHex string `protobuf:"bytes,10,opt,name=delegator_slash_sig_hex,json=delegatorSlashSigHex,proto3" json:"delegator_slash_sig_hex,omitempty"` + // covenant_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,11,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` + // staking_output_idx is the index of the staking output in the staking tx + StakingOutputIdx uint32 `protobuf:"varint,12,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` + // whether this delegation is active + Active bool `protobuf:"varint,13,opt,name=active,proto3" json:"active,omitempty"` + // descriptive status of current delegation. + StatusDesc string `protobuf:"bytes,14,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` + // unbonding_time used in unbonding output timelock path and in slashing transactions + // change outputs + UnbondingTime uint32 `protobuf:"varint,15,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + // undelegation_response is the undelegation info of this delegation. + UndelegationResponse *BTCUndelegationResponse `protobuf:"bytes,16,opt,name=undelegation_response,json=undelegationResponse,proto3" json:"undelegation_response,omitempty"` + // params version used to validate delegation + ParamsVersion uint32 `protobuf:"varint,17,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` } -func (m *QueryActiveFinalityProvidersAtHeightRequest) Reset() { - *m = QueryActiveFinalityProvidersAtHeightRequest{} -} -func (m *QueryActiveFinalityProvidersAtHeightRequest) String() string { - return proto.CompactTextString(m) -} -func (*QueryActiveFinalityProvidersAtHeightRequest) ProtoMessage() {} -func (*QueryActiveFinalityProvidersAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *BTCDelegationResponse) Reset() { *m = BTCDelegationResponse{} } +func (m *BTCDelegationResponse) String() string { return proto.CompactTextString(m) } +func (*BTCDelegationResponse) ProtoMessage() {} +func (*BTCDelegationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{14} } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *BTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCDelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -773,199 +796,143 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, dete return b[:n], nil } } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Merge(m, src) +func (m *BTCDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegationResponse.Merge(m, src) } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Size() int { +func (m *BTCDelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.DiscardUnknown(m) +func (m *BTCDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_BTCDelegationResponse proto.InternalMessageInfo -func (m *QueryActiveFinalityProvidersAtHeightRequest) GetHeight() uint64 { +func (m *BTCDelegationResponse) GetStakerAddr() string { if m != nil { - return m.Height + return m.StakerAddr } - return 0 + return "" } -func (m *QueryActiveFinalityProvidersAtHeightRequest) GetPagination() *query.PageRequest { +func (m *BTCDelegationResponse) GetStakingTime() uint32 { if m != nil { - return m.Pagination + return m.StakingTime } - return nil -} - -// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. -type ActiveFinalityProvidersAtHeightResponse struct { - // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider - // the PK follows encoding in BIP-340 spec - BtcPkHex *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk_hex,json=btcPkHex,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk_hex,omitempty"` - // height is the queried Babylon height - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` - // voting_power is the voting power of this finality provider at the given height - VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBabylonHeight uint64 `protobuf:"varint,4,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint32 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` - // jailed defines whether the finality provider is detected jailed - Jailed bool `protobuf:"varint,6,opt,name=jailed,proto3" json:"jailed,omitempty"` + return 0 } -func (m *ActiveFinalityProvidersAtHeightResponse) Reset() { - *m = ActiveFinalityProvidersAtHeightResponse{} -} -func (m *ActiveFinalityProvidersAtHeightResponse) String() string { return proto.CompactTextString(m) } -func (*ActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} -func (*ActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{15} -} -func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.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 *BTCDelegationResponse) GetStartHeight() uint32 { + if m != nil { + return m.StartHeight } + return 0 } -func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.Merge(m, src) -} -func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Size() int { - return m.Size() -} -func (m *ActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo -func (m *ActiveFinalityProvidersAtHeightResponse) GetHeight() uint64 { +func (m *BTCDelegationResponse) GetEndHeight() uint32 { if m != nil { - return m.Height + return m.EndHeight } return 0 } -func (m *ActiveFinalityProvidersAtHeightResponse) GetVotingPower() uint64 { +func (m *BTCDelegationResponse) GetTotalSat() uint64 { if m != nil { - return m.VotingPower + return m.TotalSat } return 0 } -func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBabylonHeight() uint64 { +func (m *BTCDelegationResponse) GetStakingTxHex() string { if m != nil { - return m.SlashedBabylonHeight + return m.StakingTxHex } - return 0 + return "" } -func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBtcHeight() uint32 { +func (m *BTCDelegationResponse) GetSlashingTxHex() string { if m != nil { - return m.SlashedBtcHeight + return m.SlashingTxHex } - return 0 + return "" } -func (m *ActiveFinalityProvidersAtHeightResponse) GetJailed() bool { +func (m *BTCDelegationResponse) GetDelegatorSlashSigHex() string { if m != nil { - return m.Jailed + return m.DelegatorSlashSigHex } - return false + return "" } -// QueryActiveFinalityProvidersAtHeightResponse is the response type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -type QueryActiveFinalityProvidersAtHeightResponse struct { - // finality_providers contains all the queried finality providersn. - FinalityProviders []*ActiveFinalityProvidersAtHeightResponse `protobuf:"bytes,1,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *BTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { + if m != nil { + return m.CovenantSigs + } + return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) Reset() { - *m = QueryActiveFinalityProvidersAtHeightResponse{} +func (m *BTCDelegationResponse) GetStakingOutputIdx() uint32 { + if m != nil { + return m.StakingOutputIdx + } + return 0 } -func (m *QueryActiveFinalityProvidersAtHeightResponse) String() string { - return proto.CompactTextString(m) + +func (m *BTCDelegationResponse) GetActive() bool { + if m != nil { + return m.Active + } + return false } -func (*QueryActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} -func (*QueryActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{16} -} -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.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 *BTCDelegationResponse) GetStatusDesc() string { + if m != nil { + return m.StatusDesc } -} -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Merge(m, src) -} -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) + return "" } -var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo +func (m *BTCDelegationResponse) GetUnbondingTime() uint32 { + if m != nil { + return m.UnbondingTime + } + return 0 +} -func (m *QueryActiveFinalityProvidersAtHeightResponse) GetFinalityProviders() []*ActiveFinalityProvidersAtHeightResponse { +func (m *BTCDelegationResponse) GetUndelegationResponse() *BTCUndelegationResponse { if m != nil { - return m.FinalityProviders + return m.UndelegationResponse } return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) GetPagination() *query.PageResponse { +func (m *BTCDelegationResponse) GetParamsVersion() uint32 { if m != nil { - return m.Pagination + return m.ParamsVersion } - return nil + return 0 } -// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. -type QueryActivatedHeightRequest struct { +// DelegatorUnbondingInfoResponse provides all necessary info about transaction +// which spent the staking output +type DelegatorUnbondingInfoResponse struct { + // spend_stake_tx_hex is the transaction which spent the staking output. It is + // filled only if the spend_stake_tx_hex is different than the unbonding_tx_hex + SpendStakeTxHex string `protobuf:"bytes,1,opt,name=spend_stake_tx_hex,json=spendStakeTxHex,proto3" json:"spend_stake_tx_hex,omitempty"` } -func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeightRequest{} } -func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryActivatedHeightRequest) ProtoMessage() {} -func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{17} +func (m *DelegatorUnbondingInfoResponse) Reset() { *m = DelegatorUnbondingInfoResponse{} } +func (m *DelegatorUnbondingInfoResponse) String() string { return proto.CompactTextString(m) } +func (*DelegatorUnbondingInfoResponse) ProtoMessage() {} +func (*DelegatorUnbondingInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{15} } -func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *DelegatorUnbondingInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DelegatorUnbondingInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActivatedHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_DelegatorUnbondingInfoResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -975,35 +942,62 @@ func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryActivatedHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActivatedHeightRequest.Merge(m, src) +func (m *DelegatorUnbondingInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorUnbondingInfoResponse.Merge(m, src) } -func (m *QueryActivatedHeightRequest) XXX_Size() int { +func (m *DelegatorUnbondingInfoResponse) XXX_Size() int { return m.Size() } -func (m *QueryActivatedHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActivatedHeightRequest.DiscardUnknown(m) +func (m *DelegatorUnbondingInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorUnbondingInfoResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActivatedHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_DelegatorUnbondingInfoResponse proto.InternalMessageInfo -// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. -type QueryActivatedHeightResponse struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +func (m *DelegatorUnbondingInfoResponse) GetSpendStakeTxHex() string { + if m != nil { + return m.SpendStakeTxHex + } + return "" } -func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeightResponse{} } -func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryActivatedHeightResponse) ProtoMessage() {} -func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{18} +// BTCUndelegationResponse provides all necessary info about the undeleagation +type BTCUndelegationResponse struct { + // unbonding_tx is the transaction which will transfer the funds from staking + // output to unbonding output. Unbonding output will usually have lower timelock + // than staking output. The unbonding tx as string hex. + UnbondingTxHex string `protobuf:"bytes,1,opt,name=unbonding_tx_hex,json=unbondingTxHex,proto3" json:"unbonding_tx_hex,omitempty"` + // covenant_unbonding_sig_list is the list of signatures on the unbonding tx + // by covenant members + CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,2,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` + // slashingTxHex is the hex string of slashing tx + SlashingTxHex string `protobuf:"bytes,3,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` + // delegator_slashing_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the unbonding tx output. + // The delegator slashing sig as string hex. + DelegatorSlashingSigHex string `protobuf:"bytes,4,opt,name=delegator_slashing_sig_hex,json=delegatorSlashingSigHex,proto3" json:"delegator_slashing_sig_hex,omitempty"` + // covenant_slashing_sigs is a list of adaptor signatures on the + // unbonding slashing tx by each covenant member + // It will be a part of the witness for the staking tx output. + CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,5,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` + // btc_undelegation_info contains all necessary info about the transaction + // which spent the staking output + DelegatorUnbondingInfoResponse *DelegatorUnbondingInfoResponse `protobuf:"bytes,6,opt,name=delegator_unbonding_info_response,json=delegatorUnbondingInfoResponse,proto3" json:"delegator_unbonding_info_response,omitempty"` +} + +func (m *BTCUndelegationResponse) Reset() { *m = BTCUndelegationResponse{} } +func (m *BTCUndelegationResponse) String() string { return proto.CompactTextString(m) } +func (*BTCUndelegationResponse) ProtoMessage() {} +func (*BTCUndelegationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{16} } -func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *BTCUndelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCUndelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActivatedHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCUndelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1013,50 +1007,77 @@ func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryActivatedHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActivatedHeightResponse.Merge(m, src) +func (m *BTCUndelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCUndelegationResponse.Merge(m, src) } -func (m *QueryActivatedHeightResponse) XXX_Size() int { +func (m *BTCUndelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryActivatedHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActivatedHeightResponse.DiscardUnknown(m) +func (m *BTCUndelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCUndelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActivatedHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_BTCUndelegationResponse proto.InternalMessageInfo -func (m *QueryActivatedHeightResponse) GetHeight() uint64 { +func (m *BTCUndelegationResponse) GetUnbondingTxHex() string { if m != nil { - return m.Height + return m.UnbondingTxHex } - return 0 + return "" } -// QueryFinalityProviderDelegationsRequest is the request type for the -// Query/FinalityProviderDelegations RPC method. -type QueryFinalityProviderDelegationsRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality providerthat - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *BTCUndelegationResponse) GetCovenantUnbondingSigList() []*SignatureInfo { + if m != nil { + return m.CovenantUnbondingSigList + } + return nil } -func (m *QueryFinalityProviderDelegationsRequest) Reset() { - *m = QueryFinalityProviderDelegationsRequest{} +func (m *BTCUndelegationResponse) GetSlashingTxHex() string { + if m != nil { + return m.SlashingTxHex + } + return "" } -func (m *QueryFinalityProviderDelegationsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderDelegationsRequest) ProtoMessage() {} -func (*QueryFinalityProviderDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{19} + +func (m *BTCUndelegationResponse) GetDelegatorSlashingSigHex() string { + if m != nil { + return m.DelegatorSlashingSigHex + } + return "" } -func (m *QueryFinalityProviderDelegationsRequest) XXX_Unmarshal(b []byte) error { + +func (m *BTCUndelegationResponse) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { + if m != nil { + return m.CovenantSlashingSigs + } + return nil +} + +func (m *BTCUndelegationResponse) GetDelegatorUnbondingInfoResponse() *DelegatorUnbondingInfoResponse { + if m != nil { + return m.DelegatorUnbondingInfoResponse + } + return nil +} + +// BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. +type BTCDelegatorDelegationsResponse struct { + Dels []*BTCDelegationResponse `protobuf:"bytes,1,rep,name=dels,proto3" json:"dels,omitempty"` +} + +func (m *BTCDelegatorDelegationsResponse) Reset() { *m = BTCDelegatorDelegationsResponse{} } +func (m *BTCDelegatorDelegationsResponse) String() string { return proto.CompactTextString(m) } +func (*BTCDelegatorDelegationsResponse) ProtoMessage() {} +func (*BTCDelegatorDelegationsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{17} +} +func (m *BTCDelegatorDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderDelegationsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCDelegatorDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCDelegatorDelegationsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1066,55 +1087,65 @@ func (m *QueryFinalityProviderDelegationsRequest) XXX_Marshal(b []byte, determin return b[:n], nil } } -func (m *QueryFinalityProviderDelegationsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Merge(m, src) +func (m *BTCDelegatorDelegationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegatorDelegationsResponse.Merge(m, src) } -func (m *QueryFinalityProviderDelegationsRequest) XXX_Size() int { +func (m *BTCDelegatorDelegationsResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderDelegationsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderDelegationsRequest.DiscardUnknown(m) +func (m *BTCDelegatorDelegationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegatorDelegationsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderDelegationsRequest proto.InternalMessageInfo - -func (m *QueryFinalityProviderDelegationsRequest) GetFpBtcPkHex() string { - if m != nil { - return m.FpBtcPkHex - } - return "" -} +var xxx_messageInfo_BTCDelegatorDelegationsResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderDelegationsRequest) GetPagination() *query.PageRequest { +func (m *BTCDelegatorDelegationsResponse) GetDels() []*BTCDelegationResponse { if m != nil { - return m.Pagination + return m.Dels } return nil } -// QueryFinalityProviderDelegationsResponse is the response type for the -// Query/FinalityProviderDelegations RPC method. -type QueryFinalityProviderDelegationsResponse struct { - // btc_delegator_delegations contains all the queried BTC delegations. - BtcDelegatorDelegations []*BTCDelegatorDelegationsResponse `protobuf:"bytes,1,rep,name=btc_delegator_delegations,json=btcDelegatorDelegations,proto3" json:"btc_delegator_delegations,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// FinalityProviderResponse defines a finality provider with voting power information. +type FinalityProviderResponse struct { + // description defines the description terms for the finality provider. + Description *types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + // commission defines the commission rate of the finality provider. + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` + // addr is the address to receive commission from delegations. + Addr string `protobuf:"bytes,3,opt,name=addr,proto3" json:"addr,omitempty"` + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // pop is the proof of possession of the BTC_PK by the fp addr. + // Essentially is the signature where the BTC SK sigs the fp addr. + Pop *ProofOfPossessionBTC `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBabylonHeight uint64 `protobuf:"varint,6,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + // height is the queried Babylon height + Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` + // jailed defines whether the finality provider is jailed + Jailed bool `protobuf:"varint,9,opt,name=jailed,proto3" json:"jailed,omitempty"` } -func (m *QueryFinalityProviderDelegationsResponse) Reset() { - *m = QueryFinalityProviderDelegationsResponse{} -} -func (m *QueryFinalityProviderDelegationsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderDelegationsResponse) ProtoMessage() {} -func (*QueryFinalityProviderDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{20} +func (m *FinalityProviderResponse) Reset() { *m = FinalityProviderResponse{} } +func (m *FinalityProviderResponse) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderResponse) ProtoMessage() {} +func (*FinalityProviderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{18} } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Unmarshal(b []byte) error { +func (m *FinalityProviderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *FinalityProviderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_FinalityProviderResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1124,1307 +1155,908 @@ func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, determi return b[:n], nil } } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Merge(m, src) +func (m *FinalityProviderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderResponse.Merge(m, src) } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Size() int { +func (m *FinalityProviderResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderDelegationsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderDelegationsResponse.DiscardUnknown(m) +func (m *FinalityProviderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderDelegationsResponse proto.InternalMessageInfo +var xxx_messageInfo_FinalityProviderResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegationsResponse { +func (m *FinalityProviderResponse) GetDescription() *types.Description { if m != nil { - return m.BtcDelegatorDelegations + return m.Description } return nil } -func (m *QueryFinalityProviderDelegationsResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryBTCDelegationRequest is the request type to retrieve a BTC delegation by -// staking tx hash -type QueryBTCDelegationRequest struct { - // Hash of staking transaction in btc format - StakingTxHashHex string `protobuf:"bytes,1,opt,name=staking_tx_hash_hex,json=stakingTxHashHex,proto3" json:"staking_tx_hash_hex,omitempty"` -} - -func (m *QueryBTCDelegationRequest) Reset() { *m = QueryBTCDelegationRequest{} } -func (m *QueryBTCDelegationRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBTCDelegationRequest) ProtoMessage() {} -func (*QueryBTCDelegationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{21} -} -func (m *QueryBTCDelegationRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBTCDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBTCDelegationRequest.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 *QueryBTCDelegationRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCDelegationRequest.Merge(m, src) -} -func (m *QueryBTCDelegationRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryBTCDelegationRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCDelegationRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBTCDelegationRequest proto.InternalMessageInfo - -func (m *QueryBTCDelegationRequest) GetStakingTxHashHex() string { +func (m *FinalityProviderResponse) GetAddr() string { if m != nil { - return m.StakingTxHashHex + return m.Addr } return "" } -// QueryBTCDelegationResponse is response type matching QueryBTCDelegationRequest -// and containing BTC delegation information -type QueryBTCDelegationResponse struct { - // BTCDelegation represents the client needed information of an BTCDelegation. - BtcDelegation *BTCDelegationResponse `protobuf:"bytes,1,opt,name=btc_delegation,json=btcDelegation,proto3" json:"btc_delegation,omitempty"` -} - -func (m *QueryBTCDelegationResponse) Reset() { *m = QueryBTCDelegationResponse{} } -func (m *QueryBTCDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBTCDelegationResponse) ProtoMessage() {} -func (*QueryBTCDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{22} -} -func (m *QueryBTCDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBTCDelegationResponse.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 *QueryBTCDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCDelegationResponse.Merge(m, src) -} -func (m *QueryBTCDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryBTCDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo - -func (m *QueryBTCDelegationResponse) GetBtcDelegation() *BTCDelegationResponse { +func (m *FinalityProviderResponse) GetPop() *ProofOfPossessionBTC { if m != nil { - return m.BtcDelegation + return m.Pop } return nil } -// BTCDelegationResponse is the client needed information from a BTCDelegation with the current status based on parameters. -type BTCDelegationResponse struct { - // staker_addr is the address to receive rewards from BTC delegation. - StakerAddr string `protobuf:"bytes,1,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that - // this BTC delegation delegates to - FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` - // staking_time is the number of blocks for which the delegation is locked on BTC chain - StakingTime uint32 `protobuf:"varint,4,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` - // start_height is the start BTC height of the BTC delegation - // it is the start BTC height of the timelock - StartHeight uint32 `protobuf:"varint,5,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - EndHeight uint32 `protobuf:"varint,6,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` - // total_sat is the total amount of BTC stakes in this delegation - // quantified in satoshi - TotalSat uint64 `protobuf:"varint,7,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` - // staking_tx_hex is the hex string of staking tx - StakingTxHex string `protobuf:"bytes,8,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` - // slashing_tx_hex is the hex string of slashing tx - SlashingTxHex string `protobuf:"bytes,9,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` - // delegator_slash_sig_hex is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk) as string hex. - // It will be a part of the witness for the staking tx output. - DelegatorSlashSigHex string `protobuf:"bytes,10,opt,name=delegator_slash_sig_hex,json=delegatorSlashSigHex,proto3" json:"delegator_slash_sig_hex,omitempty"` - // covenant_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,11,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` - // staking_output_idx is the index of the staking output in the staking tx - StakingOutputIdx uint32 `protobuf:"varint,12,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` - // whether this delegation is active - Active bool `protobuf:"varint,13,opt,name=active,proto3" json:"active,omitempty"` - // descriptive status of current delegation. - StatusDesc string `protobuf:"bytes,14,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` - // unbonding_time used in unbonding output timelock path and in slashing transactions - // change outputs - UnbondingTime uint32 `protobuf:"varint,15,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` - // undelegation_response is the undelegation info of this delegation. - UndelegationResponse *BTCUndelegationResponse `protobuf:"bytes,16,opt,name=undelegation_response,json=undelegationResponse,proto3" json:"undelegation_response,omitempty"` - // params version used to validate delegation - ParamsVersion uint32 `protobuf:"varint,17,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` -} - -func (m *BTCDelegationResponse) Reset() { *m = BTCDelegationResponse{} } -func (m *BTCDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*BTCDelegationResponse) ProtoMessage() {} -func (*BTCDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{23} -} -func (m *BTCDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelegationResponse.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 *BTCDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelegationResponse.Merge(m, src) -} -func (m *BTCDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *BTCDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCDelegationResponse proto.InternalMessageInfo - -func (m *BTCDelegationResponse) GetStakerAddr() string { - if m != nil { - return m.StakerAddr - } - return "" -} - -func (m *BTCDelegationResponse) GetStakingTime() uint32 { +func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { if m != nil { - return m.StakingTime + return m.SlashedBabylonHeight } return 0 } -func (m *BTCDelegationResponse) GetStartHeight() uint32 { +func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint32 { if m != nil { - return m.StartHeight + return m.SlashedBtcHeight } return 0 } -func (m *BTCDelegationResponse) GetEndHeight() uint32 { +func (m *FinalityProviderResponse) GetHeight() uint64 { if m != nil { - return m.EndHeight + return m.Height } return 0 } -func (m *BTCDelegationResponse) GetTotalSat() uint64 { +func (m *FinalityProviderResponse) GetJailed() bool { if m != nil { - return m.TotalSat + return m.Jailed } - return 0 + return false } -func (m *BTCDelegationResponse) GetStakingTxHex() string { - if m != nil { - return m.StakingTxHex - } - return "" +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btcstaking.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btcstaking.v1.QueryParamsResponse") + proto.RegisterType((*QueryParamsByVersionRequest)(nil), "babylon.btcstaking.v1.QueryParamsByVersionRequest") + proto.RegisterType((*QueryParamsByVersionResponse)(nil), "babylon.btcstaking.v1.QueryParamsByVersionResponse") + proto.RegisterType((*QueryFinalityProvidersRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersRequest") + proto.RegisterType((*QueryFinalityProvidersResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersResponse") + proto.RegisterType((*QueryFinalityProviderRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderRequest") + proto.RegisterType((*QueryFinalityProviderResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderResponse") + proto.RegisterType((*QueryBTCDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsRequest") + proto.RegisterType((*QueryBTCDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsResponse") + proto.RegisterType((*QueryFinalityProviderDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsRequest") + proto.RegisterType((*QueryFinalityProviderDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsResponse") + proto.RegisterType((*QueryBTCDelegationRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationRequest") + proto.RegisterType((*QueryBTCDelegationResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationResponse") + proto.RegisterType((*BTCDelegationResponse)(nil), "babylon.btcstaking.v1.BTCDelegationResponse") + proto.RegisterType((*DelegatorUnbondingInfoResponse)(nil), "babylon.btcstaking.v1.DelegatorUnbondingInfoResponse") + proto.RegisterType((*BTCUndelegationResponse)(nil), "babylon.btcstaking.v1.BTCUndelegationResponse") + proto.RegisterType((*BTCDelegatorDelegationsResponse)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationsResponse") + proto.RegisterType((*FinalityProviderResponse)(nil), "babylon.btcstaking.v1.FinalityProviderResponse") } -func (m *BTCDelegationResponse) GetSlashingTxHex() string { - if m != nil { - return m.SlashingTxHex - } - return "" -} +func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } -func (m *BTCDelegationResponse) GetDelegatorSlashSigHex() string { - if m != nil { - return m.DelegatorSlashSigHex - } - return "" +var fileDescriptor_74d49d26f7429697 = []byte{ + // 1673 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4b, 0x6f, 0xdb, 0xca, + 0x15, 0x36, 0x6d, 0x59, 0xb1, 0x8f, 0x2c, 0xd9, 0x9e, 0xeb, 0xd8, 0x8c, 0x7c, 0x2d, 0x3b, 0x6a, + 0x6e, 0xe2, 0x3c, 0x2c, 0xc6, 0x8f, 0xf4, 0xb6, 0x08, 0x6e, 0xdb, 0xc8, 0xce, 0xab, 0x89, 0x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c9, 0xa9, 0x53, 0x56, 0x5e, 0x76, 0x2d, 0x3b, 0x87, 0x47, 0x55, 0xd0, 0x1f, 0x25, 0xc8, + 0x75, 0xef, 0x7d, 0x68, 0xf5, 0xb8, 0xec, 0xfa, 0xae, 0xb3, 0xf9, 0xb5, 0x41, 0x4c, 0x44, 0x39, + 0x5f, 0xb3, 0x72, 0x56, 0x91, 0xa2, 0x24, 0xfe, 0xd5, 0x14, 0xdf, 0x82, 0x94, 0x97, 0xfc, 0x43, + 0xe7, 0x10, 0xfd, 0x5b, 0x82, 0xf9, 0x63, 0x76, 0x2a, 0xf4, 0xbd, 0x41, 0xd0, 0xed, 0x53, 0xcc, + 0xf7, 0xcf, 0x6c, 0x2f, 0x2a, 0xdb, 0x66, 0x95, 0x3d, 0x44, 0xf7, 0xcf, 0x7e, 0x51, 0xb1, 0xc2, + 0xd1, 0x9f, 0x25, 0xc8, 0x76, 0x61, 0x88, 0x6e, 0x9f, 0x1a, 0xee, 0xa0, 0xa6, 0xd5, 0x01, 0x2c, + 0x44, 0x15, 0x9b, 0xac, 0x8a, 0x6f, 0xd0, 0xdd, 0x53, 0xdd, 0x0f, 0xbb, 0x9e, 0xde, 0x2d, 0xef, + 0xb0, 0xfc, 0xa3, 0xb7, 0x9f, 0x0a, 0xd2, 0xbb, 0x4f, 0x05, 0xe9, 0x1f, 0x9f, 0x0a, 0xd2, 0x6f, + 0x3f, 0x17, 0x86, 0xde, 0x7d, 0x2e, 0x0c, 0xfd, 0xfd, 0x73, 0x61, 0xe8, 0xa7, 0xa7, 0x18, 0x2a, + 0x9d, 0x78, 0x44, 0x36, 0x61, 0x6a, 0x69, 0xf6, 0xa7, 0xe2, 0xfa, 0xff, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xd4, 0x91, 0x2b, 0x9a, 0x9e, 0x15, 0x00, 0x00, } -func (m *BTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { - if m != nil { - return m.CovenantSigs - } - return nil -} +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn -func (m *BTCDelegationResponse) GetStakingOutputIdx() uint32 { - if m != nil { - return m.StakingOutputIdx - } - return 0 -} +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 -func (m *BTCDelegationResponse) GetActive() bool { - if m != nil { - return m.Active - } - return false +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ParamsByVersion queries the parameters of the module for a specific version of past params. + ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) + // FinalityProviders queries all finality providers + FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) + // FinalityProvider info about one finality provider + FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) + // BTCDelegations queries all BTC delegations under a given status + BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) + // FinalityProviderDelegations queries all BTC delegations of the given finality provider + FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) + // BTCDelegation retrieves delegation by corresponding staking tx hash + BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) } -func (m *BTCDelegationResponse) GetStatusDesc() string { - if m != nil { - return m.StatusDesc - } - return "" +type queryClient struct { + cc grpc1.ClientConn } -func (m *BTCDelegationResponse) GetUnbondingTime() uint32 { - if m != nil { - return m.UnbondingTime - } - return 0 +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} } -func (m *BTCDelegationResponse) GetUndelegationResponse() *BTCUndelegationResponse { - if m != nil { - return m.UndelegationResponse +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err } - return nil + return out, nil } -func (m *BTCDelegationResponse) GetParamsVersion() uint32 { - if m != nil { - return m.ParamsVersion +func (c *queryClient) ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) { + out := new(QueryParamsByVersionResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ParamsByVersion", in, out, opts...) + if err != nil { + return nil, err } - return 0 + return out, nil } -// DelegatorUnbondingInfoResponse provides all necessary info about transaction -// which spent the staking output -type DelegatorUnbondingInfoResponse struct { - // spend_stake_tx_hex is the transaction which spent the staking output. It is - // filled only if the spend_stake_tx_hex is different than the unbonding_tx_hex - SpendStakeTxHex string `protobuf:"bytes,1,opt,name=spend_stake_tx_hex,json=spendStakeTxHex,proto3" json:"spend_stake_tx_hex,omitempty"` +func (c *queryClient) FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) { + out := new(QueryFinalityProvidersResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *DelegatorUnbondingInfoResponse) Reset() { *m = DelegatorUnbondingInfoResponse{} } -func (m *DelegatorUnbondingInfoResponse) String() string { return proto.CompactTextString(m) } -func (*DelegatorUnbondingInfoResponse) ProtoMessage() {} -func (*DelegatorUnbondingInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{24} -} -func (m *DelegatorUnbondingInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegatorUnbondingInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegatorUnbondingInfoResponse.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 (c *queryClient) FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { + out := new(QueryFinalityProviderResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProvider", in, out, opts...) + if err != nil { + return nil, err } + return out, nil } -func (m *DelegatorUnbondingInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegatorUnbondingInfoResponse.Merge(m, src) -} -func (m *DelegatorUnbondingInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *DelegatorUnbondingInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DelegatorUnbondingInfoResponse.DiscardUnknown(m) + +func (c *queryClient) BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) { + out := new(QueryBTCDelegationsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegations", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -var xxx_messageInfo_DelegatorUnbondingInfoResponse proto.InternalMessageInfo +func (c *queryClient) FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) { + out := new(QueryFinalityProviderDelegationsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} -func (m *DelegatorUnbondingInfoResponse) GetSpendStakeTxHex() string { - if m != nil { - return m.SpendStakeTxHex +func (c *queryClient) BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) { + out := new(QueryBTCDelegationResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegation", in, out, opts...) + if err != nil { + return nil, err } - return "" + return out, nil } -// BTCUndelegationResponse provides all necessary info about the undeleagation -type BTCUndelegationResponse struct { - // unbonding_tx is the transaction which will transfer the funds from staking - // output to unbonding output. Unbonding output will usually have lower timelock - // than staking output. The unbonding tx as string hex. - UnbondingTxHex string `protobuf:"bytes,1,opt,name=unbonding_tx_hex,json=unbondingTxHex,proto3" json:"unbonding_tx_hex,omitempty"` - // covenant_unbonding_sig_list is the list of signatures on the unbonding tx - // by covenant members - CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,2,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` - // slashingTxHex is the hex string of slashing tx - SlashingTxHex string `protobuf:"bytes,3,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` - // delegator_slashing_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the unbonding tx output. - // The delegator slashing sig as string hex. - DelegatorSlashingSigHex string `protobuf:"bytes,4,opt,name=delegator_slashing_sig_hex,json=delegatorSlashingSigHex,proto3" json:"delegator_slashing_sig_hex,omitempty"` - // covenant_slashing_sigs is a list of adaptor signatures on the - // unbonding slashing tx by each covenant member - // It will be a part of the witness for the staking tx output. - CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,5,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` - // btc_undelegation_info contains all necessary info about the transaction - // which spent the staking output - DelegatorUnbondingInfoResponse *DelegatorUnbondingInfoResponse `protobuf:"bytes,6,opt,name=delegator_unbonding_info_response,json=delegatorUnbondingInfoResponse,proto3" json:"delegator_unbonding_info_response,omitempty"` +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ParamsByVersion queries the parameters of the module for a specific version of past params. + ParamsByVersion(context.Context, *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) + // FinalityProviders queries all finality providers + FinalityProviders(context.Context, *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) + // FinalityProvider info about one finality provider + FinalityProvider(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) + // BTCDelegations queries all BTC delegations under a given status + BTCDelegations(context.Context, *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) + // FinalityProviderDelegations queries all BTC delegations of the given finality provider + FinalityProviderDelegations(context.Context, *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) + // BTCDelegation retrieves delegation by corresponding staking tx hash + BTCDelegation(context.Context, *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) } -func (m *BTCUndelegationResponse) Reset() { *m = BTCUndelegationResponse{} } -func (m *BTCUndelegationResponse) String() string { return proto.CompactTextString(m) } -func (*BTCUndelegationResponse) ProtoMessage() {} -func (*BTCUndelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{25} +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { } -func (m *BTCUndelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (m *BTCUndelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCUndelegationResponse.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 (*UnimplementedQueryServer) ParamsByVersion(ctx context.Context, req *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ParamsByVersion not implemented") } -func (m *BTCUndelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCUndelegationResponse.Merge(m, src) +func (*UnimplementedQueryServer) FinalityProviders(ctx context.Context, req *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviders not implemented") } -func (m *BTCUndelegationResponse) XXX_Size() int { - return m.Size() +func (*UnimplementedQueryServer) FinalityProvider(ctx context.Context, req *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProvider not implemented") } -func (m *BTCUndelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCUndelegationResponse.DiscardUnknown(m) +func (*UnimplementedQueryServer) BTCDelegations(ctx context.Context, req *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BTCDelegations not implemented") } - -var xxx_messageInfo_BTCUndelegationResponse proto.InternalMessageInfo - -func (m *BTCUndelegationResponse) GetUnbondingTxHex() string { - if m != nil { - return m.UnbondingTxHex - } - return "" +func (*UnimplementedQueryServer) FinalityProviderDelegations(ctx context.Context, req *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderDelegations not implemented") } - -func (m *BTCUndelegationResponse) GetCovenantUnbondingSigList() []*SignatureInfo { - if m != nil { - return m.CovenantUnbondingSigList - } - return nil +func (*UnimplementedQueryServer) BTCDelegation(ctx context.Context, req *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BTCDelegation not implemented") } -func (m *BTCUndelegationResponse) GetSlashingTxHex() string { - if m != nil { - return m.SlashingTxHex - } - return "" +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *BTCUndelegationResponse) GetDelegatorSlashingSigHex() string { - if m != nil { - return m.DelegatorSlashingSigHex +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err } - return "" -} - -func (m *BTCUndelegationResponse) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { - if m != nil { - return m.CovenantSlashingSigs + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) } - return nil -} - -func (m *BTCUndelegationResponse) GetDelegatorUnbondingInfoResponse() *DelegatorUnbondingInfoResponse { - if m != nil { - return m.DelegatorUnbondingInfoResponse + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/Params", } - return nil + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) } -// BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. -type BTCDelegatorDelegationsResponse struct { - Dels []*BTCDelegationResponse `protobuf:"bytes,1,rep,name=dels,proto3" json:"dels,omitempty"` -} - -func (m *BTCDelegatorDelegationsResponse) Reset() { *m = BTCDelegatorDelegationsResponse{} } -func (m *BTCDelegatorDelegationsResponse) String() string { return proto.CompactTextString(m) } -func (*BTCDelegatorDelegationsResponse) ProtoMessage() {} -func (*BTCDelegatorDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{26} -} -func (m *BTCDelegatorDelegationsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCDelegatorDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelegatorDelegationsResponse.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 _Query_ParamsByVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsByVersionRequest) + if err := dec(in); err != nil { + return nil, err } -} -func (m *BTCDelegatorDelegationsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelegatorDelegationsResponse.Merge(m, src) -} -func (m *BTCDelegatorDelegationsResponse) XXX_Size() int { - return m.Size() -} -func (m *BTCDelegatorDelegationsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelegatorDelegationsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCDelegatorDelegationsResponse proto.InternalMessageInfo - -func (m *BTCDelegatorDelegationsResponse) GetDels() []*BTCDelegationResponse { - if m != nil { - return m.Dels + if interceptor == nil { + return srv.(QueryServer).ParamsByVersion(ctx, in) } - return nil -} - -// FinalityProviderResponse defines a finality provider with voting power information. -type FinalityProviderResponse struct { - // description defines the description terms for the finality provider. - Description *types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` - // commission defines the commission rate of the finality provider. - Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` - // addr is the address to receive commission from delegations. - Addr string `protobuf:"bytes,3,opt,name=addr,proto3" json:"addr,omitempty"` - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // pop is the proof of possession of the BTC_PK by the fp addr. - // Essentially is the signature where the BTC SK sigs the fp addr. - Pop *ProofOfPossessionBTC `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBabylonHeight uint64 `protobuf:"varint,6,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` - // height is the queried Babylon height - Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` - // voting_power is the voting power of this finality provider at the given height - VotingPower uint64 `protobuf:"varint,9,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` - // jailed defines whether the finality provider is jailed - Jailed bool `protobuf:"varint,10,opt,name=jailed,proto3" json:"jailed,omitempty"` -} - -func (m *FinalityProviderResponse) Reset() { *m = FinalityProviderResponse{} } -func (m *FinalityProviderResponse) String() string { return proto.CompactTextString(m) } -func (*FinalityProviderResponse) ProtoMessage() {} -func (*FinalityProviderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{27} -} -func (m *FinalityProviderResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FinalityProviderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FinalityProviderResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/ParamsByVersion", } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ParamsByVersion(ctx, req.(*QueryParamsByVersionRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_FinalityProviderResponse.Merge(m, src) -} -func (m *FinalityProviderResponse) XXX_Size() int { - return m.Size() -} -func (m *FinalityProviderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_FinalityProviderResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_FinalityProviderResponse proto.InternalMessageInfo -func (m *FinalityProviderResponse) GetDescription() *types.Description { - if m != nil { - return m.Description +func _Query_FinalityProviders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProvidersRequest) + if err := dec(in); err != nil { + return nil, err } - return nil + if interceptor == nil { + return srv.(QueryServer).FinalityProviders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviders(ctx, req.(*QueryFinalityProvidersRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetAddr() string { - if m != nil { - return m.Addr +func _Query_FinalityProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderRequest) + if err := dec(in); err != nil { + return nil, err } - return "" + if interceptor == nil { + return srv.(QueryServer).FinalityProvider(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/FinalityProvider", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProvider(ctx, req.(*QueryFinalityProviderRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetPop() *ProofOfPossessionBTC { - if m != nil { - return m.Pop +func _Query_BTCDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBTCDelegationsRequest) + if err := dec(in); err != nil { + return nil, err } - return nil + if interceptor == nil { + return srv.(QueryServer).BTCDelegations(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/BTCDelegations", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BTCDelegations(ctx, req.(*QueryBTCDelegationsRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { - if m != nil { - return m.SlashedBabylonHeight +func _Query_FinalityProviderDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderDelegationsRequest) + if err := dec(in); err != nil { + return nil, err } - return 0 + if interceptor == nil { + return srv.(QueryServer).FinalityProviderDelegations(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviderDelegations(ctx, req.(*QueryFinalityProviderDelegationsRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint32 { - if m != nil { - return m.SlashedBtcHeight +func _Query_BTCDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBTCDelegationRequest) + if err := dec(in); err != nil { + return nil, err } - return 0 + if interceptor == nil { + return srv.(QueryServer).BTCDelegation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/BTCDelegation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BTCDelegation(ctx, req.(*QueryBTCDelegationRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "babylon.btcstaking.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "ParamsByVersion", + Handler: _Query_ParamsByVersion_Handler, + }, + { + MethodName: "FinalityProviders", + Handler: _Query_FinalityProviders_Handler, + }, + { + MethodName: "FinalityProvider", + Handler: _Query_FinalityProvider_Handler, + }, + { + MethodName: "BTCDelegations", + Handler: _Query_BTCDelegations_Handler, + }, + { + MethodName: "FinalityProviderDelegations", + Handler: _Query_FinalityProviderDelegations_Handler, + }, + { + MethodName: "BTCDelegation", + Handler: _Query_BTCDelegation_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "babylon/btcstaking/v1/query.proto", } -func (m *FinalityProviderResponse) GetVotingPower() uint64 { - if m != nil { - return m.VotingPower +func (m *QueryParamsRequest) 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 0 + return dAtA[:n], nil } -func (m *FinalityProviderResponse) GetJailed() bool { - if m != nil { - return m.Jailed - } - return false -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btcstaking.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btcstaking.v1.QueryParamsResponse") - proto.RegisterType((*QueryParamsByVersionRequest)(nil), "babylon.btcstaking.v1.QueryParamsByVersionRequest") - proto.RegisterType((*QueryParamsByVersionResponse)(nil), "babylon.btcstaking.v1.QueryParamsByVersionResponse") - proto.RegisterType((*QueryFinalityProvidersRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersRequest") - proto.RegisterType((*QueryFinalityProvidersResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersResponse") - proto.RegisterType((*QueryFinalityProviderRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderRequest") - proto.RegisterType((*QueryFinalityProviderResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderResponse") - proto.RegisterType((*QueryBTCDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsRequest") - proto.RegisterType((*QueryBTCDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsResponse") - proto.RegisterType((*QueryFinalityProviderPowerAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderPowerAtHeightRequest") - proto.RegisterType((*QueryFinalityProviderPowerAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderPowerAtHeightResponse") - proto.RegisterType((*QueryFinalityProviderCurrentPowerRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderCurrentPowerRequest") - proto.RegisterType((*QueryFinalityProviderCurrentPowerResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderCurrentPowerResponse") - proto.RegisterType((*QueryActiveFinalityProvidersAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryActiveFinalityProvidersAtHeightRequest") - proto.RegisterType((*ActiveFinalityProvidersAtHeightResponse)(nil), "babylon.btcstaking.v1.ActiveFinalityProvidersAtHeightResponse") - proto.RegisterType((*QueryActiveFinalityProvidersAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryActiveFinalityProvidersAtHeightResponse") - proto.RegisterType((*QueryActivatedHeightRequest)(nil), "babylon.btcstaking.v1.QueryActivatedHeightRequest") - proto.RegisterType((*QueryActivatedHeightResponse)(nil), "babylon.btcstaking.v1.QueryActivatedHeightResponse") - proto.RegisterType((*QueryFinalityProviderDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsRequest") - proto.RegisterType((*QueryFinalityProviderDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsResponse") - proto.RegisterType((*QueryBTCDelegationRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationRequest") - proto.RegisterType((*QueryBTCDelegationResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationResponse") - proto.RegisterType((*BTCDelegationResponse)(nil), "babylon.btcstaking.v1.BTCDelegationResponse") - proto.RegisterType((*DelegatorUnbondingInfoResponse)(nil), "babylon.btcstaking.v1.DelegatorUnbondingInfoResponse") - proto.RegisterType((*BTCUndelegationResponse)(nil), "babylon.btcstaking.v1.BTCUndelegationResponse") - proto.RegisterType((*BTCDelegatorDelegationsResponse)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationsResponse") - proto.RegisterType((*FinalityProviderResponse)(nil), "babylon.btcstaking.v1.FinalityProviderResponse") +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } - -var fileDescriptor_74d49d26f7429697 = []byte{ - // 1995 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0x0f, 0x6d, 0x47, 0x89, 0x9f, 0xfc, 0x39, 0xeb, 0x24, 0x8a, 0x1c, 0xcb, 0x09, 0x9b, 0x4d, - 0x9c, 0x0f, 0x8b, 0xb1, 0xe3, 0xec, 0xb6, 0x0d, 0x76, 0x13, 0xcb, 0xde, 0x4d, 0xb2, 0xbb, 0x6e, - 0x54, 0x2a, 0xd9, 0x43, 0xbf, 0x04, 0x8a, 0x1c, 0x51, 0x6c, 0x24, 0x52, 0x21, 0x47, 0xae, 0x8d, - 0xc0, 0x40, 0xd1, 0x43, 0x6f, 0x05, 0x0a, 0xb4, 0xff, 0xc2, 0x02, 0x05, 0x7a, 0x29, 0xd0, 0x3d, - 0xb4, 0x87, 0xde, 0xb7, 0xb7, 0x45, 0x7a, 0x29, 0xf6, 0x10, 0x14, 0x49, 0xb1, 0x05, 0x0a, 0xf4, - 0x5a, 0x14, 0x3d, 0x15, 0x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0xf0, 0x62, 0x0b, 0xbd, 0x78, 0x8f, 0xdc, 0x1d, 0xaa, 0x38, 0x62, 0x6d, 0xec, 0x9e, 0xc2, - 0x1c, 0x14, 0xbe, 0xf3, 0xc5, 0xeb, 0x9c, 0xf4, 0xe5, 0xeb, 0x9c, 0xf4, 0xb7, 0xd7, 0x39, 0xe9, - 0x97, 0x6f, 0x72, 0x27, 0xbe, 0x7c, 0x93, 0x3b, 0xf1, 0xd7, 0x37, 0xb9, 0x13, 0xdf, 0x1b, 0xe2, - 0xd2, 0xb7, 0x17, 0xd5, 0x88, 0x37, 0xc0, 0x4a, 0x0a, 0xff, 0x6f, 0xbc, 0xfd, 0xbf, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x8b, 0x3f, 0xa6, 0x89, 0xb9, 0x1d, 0x00, 0x00, +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ParamsByVersion queries the parameters of the module for a specific version of past params. - ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) - // FinalityProviders queries all finality providers - FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) - // FinalityProvider info about one finality provider - FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) - // BTCDelegations queries all BTC delegations under a given status - BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) - // FinalityProviderDelegations queries all BTC delegations of the given finality provider - FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) - // BTCDelegation retrieves delegation by corresponding staking tx hash - BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) +func (m *QueryParamsResponse) 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 } -type queryClient struct { - cc grpc1.ClientConn +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/Params", in, out, opts...) +func (m *QueryParamsByVersionRequest) 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 out, nil + return dAtA[:n], nil } -func (c *queryClient) ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) { - out := new(QueryParamsByVersionResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ParamsByVersion", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *QueryParamsByVersionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *queryClient) FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) { - out := new(QueryFinalityProvidersResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviders", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryParamsByVersionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Version != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 } - return out, nil + return len(dAtA) - i, nil } -func (c *queryClient) FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { - out := new(QueryFinalityProviderResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProvider", in, out, opts...) +func (m *QueryParamsByVersionResponse) 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 out, nil + return dAtA[:n], nil } -func (c *queryClient) BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) { - out := new(QueryBTCDelegationsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegations", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *QueryParamsByVersionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *queryClient) ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) { - out := new(QueryActiveFinalityProvidersAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ActiveFinalityProvidersAtHeight", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryParamsByVersionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return out, nil + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (c *queryClient) FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) { - out := new(QueryFinalityProviderPowerAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderPowerAtHeight", in, out, opts...) +func (m *QueryFinalityProvidersRequest) 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 out, nil + return dAtA[:n], nil } -func (c *queryClient) FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) { - out := new(QueryFinalityProviderCurrentPowerResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryFinalityProvidersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFinalityProvidersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return out, nil + return len(dAtA) - i, 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...) +func (m *QueryFinalityProvidersResponse) 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 out, nil + return dAtA[:n], nil } -func (c *queryClient) FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) { - out := new(QueryFinalityProviderDelegationsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryFinalityProvidersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFinalityProvidersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return out, nil + if len(m.FinalityProviders) > 0 { + for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil } -func (c *queryClient) BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) { - out := new(QueryBTCDelegationResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegation", in, out, opts...) +func (m *QueryFinalityProviderRequest) 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 out, nil + return dAtA[:n], nil } -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ParamsByVersion queries the parameters of the module for a specific version of past params. - ParamsByVersion(context.Context, *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) - // FinalityProviders queries all finality providers - FinalityProviders(context.Context, *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) - // FinalityProvider info about one finality provider - FinalityProvider(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) - // BTCDelegations queries all BTC delegations under a given status - BTCDelegations(context.Context, *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - ActiveFinalityProvidersAtHeight(context.Context, *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - FinalityProviderPowerAtHeight(context.Context, *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - FinalityProviderCurrentPower(context.Context, *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - ActivatedHeight(context.Context, *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) - // FinalityProviderDelegations queries all BTC delegations of the given finality provider - FinalityProviderDelegations(context.Context, *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) - // BTCDelegation retrieves delegation by corresponding staking tx hash - BTCDelegation(context.Context, *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) +func (m *QueryFinalityProviderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { +func (m *QueryFinalityProviderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} -func (*UnimplementedQueryServer) ParamsByVersion(ctx context.Context, req *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ParamsByVersion not implemented") -} -func (*UnimplementedQueryServer) FinalityProviders(ctx context.Context, req *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviders not implemented") -} -func (*UnimplementedQueryServer) FinalityProvider(ctx context.Context, req *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProvider not implemented") -} -func (*UnimplementedQueryServer) BTCDelegations(ctx context.Context, req *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BTCDelegations not implemented") -} -func (*UnimplementedQueryServer) ActiveFinalityProvidersAtHeight(ctx context.Context, req *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ActiveFinalityProvidersAtHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderPowerAtHeight(ctx context.Context, req *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderPowerAtHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderCurrentPower(ctx context.Context, req *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderCurrentPower not implemented") -} -func (*UnimplementedQueryServer) ActivatedHeight(ctx context.Context, req *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ActivatedHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderDelegations(ctx context.Context, req *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderDelegations not implemented") -} -func (*UnimplementedQueryServer) BTCDelegation(ctx context.Context, req *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BTCDelegation not implemented") +func (m *QueryFinalityProviderResponse) 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 RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) +func (m *QueryFinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) +func (m *QueryFinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FinalityProvider != nil { + { + size, err := m.FinalityProvider.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return interceptor(ctx, in, info, handler) + return len(dAtA) - i, nil } -func _Query_ParamsByVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsByVersionRequest) - if err := dec(in); err != nil { +func (m *QueryBTCDelegationsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(QueryServer).ParamsByVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ParamsByVersion", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ParamsByVersion(ctx, req.(*QueryParamsByVersionRequest)) - } - return interceptor(ctx, in, info, handler) + return dAtA[:n], nil } -func _Query_FinalityProviders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProvidersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviders(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviders", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviders(ctx, req.(*QueryFinalityProvidersRequest)) - } - return interceptor(ctx, in, info, handler) +func (m *QueryBTCDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Query_FinalityProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProvider(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProvider", +func (m *QueryBTCDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProvider(ctx, req.(*QueryFinalityProviderRequest)) + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 } - return interceptor(ctx, in, info, handler) + return len(dAtA) - i, nil } -func _Query_BTCDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBTCDelegationsRequest) - if err := dec(in); err != nil { +func (m *QueryBTCDelegationsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(QueryServer).BTCDelegations(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/BTCDelegations", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).BTCDelegations(ctx, req.(*QueryBTCDelegationsRequest)) - } - return interceptor(ctx, in, info, handler) + return dAtA[:n], nil } -func _Query_ActiveFinalityProvidersAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryActiveFinalityProvidersAtHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ActiveFinalityProvidersAtHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, req.(*QueryActiveFinalityProvidersAtHeightRequest)) - } - return interceptor(ctx, in, info, handler) +func (m *QueryBTCDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Query_FinalityProviderPowerAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderPowerAtHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderPowerAtHeight", +func (m *QueryBTCDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, req.(*QueryFinalityProviderPowerAtHeightRequest)) + if len(m.BtcDelegations) > 0 { + for iNdEx := len(m.BtcDelegations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return interceptor(ctx, in, info, handler) + return len(dAtA) - i, nil } -func _Query_FinalityProviderCurrentPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderCurrentPowerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviderCurrentPower(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderCurrentPower(ctx, req.(*QueryFinalityProviderCurrentPowerRequest)) - } - 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 { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ActivatedHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ActivatedHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ActivatedHeight(ctx, req.(*QueryActivatedHeightRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_FinalityProviderDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderDelegationsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviderDelegations(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderDelegations(ctx, req.(*QueryFinalityProviderDelegationsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_BTCDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBTCDelegationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).BTCDelegation(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/BTCDelegation", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).BTCDelegation(ctx, req.(*QueryBTCDelegationRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "babylon.btcstaking.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "ParamsByVersion", - Handler: _Query_ParamsByVersion_Handler, - }, - { - MethodName: "FinalityProviders", - Handler: _Query_FinalityProviders_Handler, - }, - { - MethodName: "FinalityProvider", - Handler: _Query_FinalityProvider_Handler, - }, - { - MethodName: "BTCDelegations", - Handler: _Query_BTCDelegations_Handler, - }, - { - MethodName: "ActiveFinalityProvidersAtHeight", - Handler: _Query_ActiveFinalityProvidersAtHeight_Handler, - }, - { - MethodName: "FinalityProviderPowerAtHeight", - Handler: _Query_FinalityProviderPowerAtHeight_Handler, - }, - { - MethodName: "FinalityProviderCurrentPower", - Handler: _Query_FinalityProviderCurrentPower_Handler, - }, - { - MethodName: "ActivatedHeight", - Handler: _Query_ActivatedHeight_Handler, - }, - { - MethodName: "FinalityProviderDelegations", - Handler: _Query_FinalityProviderDelegations_Handler, - }, - { - MethodName: "BTCDelegation", - Handler: _Query_BTCDelegation_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "babylon/btcstaking/v1/query.proto", -} - -func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func (m *QueryFinalityProviderDelegationsRequest) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QueryParamsByVersionRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderDelegationsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2434,25 +2066,46 @@ func (m *QueryParamsByVersionRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsByVersionRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsByVersionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Version != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Version)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x8 + dAtA[i] = 0x12 + } + if len(m.BtcDelegatorDelegations) > 0 { + for iNdEx := len(m.BtcDelegatorDelegations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcDelegatorDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } -func (m *QueryParamsByVersionResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryBTCDelegationRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2462,30 +2115,27 @@ func (m *QueryParamsByVersionResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsByVersionResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsByVersionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + if len(m.StakingTxHashHex) > 0 { + i -= len(m.StakingTxHashHex) + copy(dAtA[i:], m.StakingTxHashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHashHex))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QueryFinalityProvidersRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryBTCDelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2495,19 +2145,19 @@ func (m *QueryFinalityProvidersRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalityProvidersRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalityProvidersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { + if m.BtcDelegation != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BtcDelegation.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2520,7 +2170,7 @@ func (m *QueryFinalityProvidersRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryFinalityProvidersResponse) Marshal() (dAtA []byte, err error) { +func (m *BTCDelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2530,19 +2180,26 @@ func (m *QueryFinalityProvidersResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalityProvidersResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalityProvidersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { + if m.ParamsVersion != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ParamsVersion)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.UndelegationResponse != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.UndelegationResponse.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2550,56 +2207,129 @@ func (m *QueryFinalityProvidersResponse) MarshalToSizedBuffer(dAtA []byte) (int, i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } - if len(m.FinalityProviders) > 0 { - for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + if m.UnbondingTime != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.UnbondingTime)) + i-- + dAtA[i] = 0x78 + } + if len(m.StatusDesc) > 0 { + i -= len(m.StatusDesc) + copy(dAtA[i:], m.StatusDesc) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StatusDesc))) + i-- + dAtA[i] = 0x72 + } + if m.Active { + i-- + if m.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x68 + } + if m.StakingOutputIdx != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StakingOutputIdx)) + i-- + dAtA[i] = 0x60 + } + if len(m.CovenantSigs) > 0 { + for iNdEx := len(m.CovenantSigs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CovenantSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x5a } } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if len(m.DelegatorSlashSigHex) > 0 { + i -= len(m.DelegatorSlashSigHex) + copy(dAtA[i:], m.DelegatorSlashSigHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashSigHex))) + i-- + dAtA[i] = 0x52 } - return dAtA[:n], nil -} - -func (m *QueryFinalityProviderRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + if len(m.SlashingTxHex) > 0 { + i -= len(m.SlashingTxHex) + copy(dAtA[i:], m.SlashingTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) + i-- + dAtA[i] = 0x4a + } + if len(m.StakingTxHex) > 0 { + i -= len(m.StakingTxHex) + copy(dAtA[i:], m.StakingTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHex))) + i-- + dAtA[i] = 0x42 + } + if m.TotalSat != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TotalSat)) + i-- + dAtA[i] = 0x38 + } + if m.EndHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EndHeight)) + i-- + dAtA[i] = 0x30 + } + if m.StartHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x28 + } + if m.StakingTime != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StakingTime)) + i-- + dAtA[i] = 0x20 + } + if len(m.FpBtcPkList) > 0 { + for iNdEx := len(m.FpBtcPkList) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.FpBtcPkList[iNdEx].Size() + i -= size + if _, err := m.FpBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerAddr))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryFinalityProviderResponse) Marshal() (dAtA []byte, err error) { +func (m *DelegatorUnbondingInfoResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2609,32 +2339,27 @@ func (m *QueryFinalityProviderResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegatorUnbondingInfoResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegatorUnbondingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.FinalityProvider != nil { - { - size, err := m.FinalityProvider.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.SpendStakeTxHex) > 0 { + i -= len(m.SpendStakeTxHex) + copy(dAtA[i:], m.SpendStakeTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpendStakeTxHex))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryBTCDelegationsRequest) Marshal() (dAtA []byte, err error) { +func (m *BTCUndelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2644,19 +2369,19 @@ func (m *QueryBTCDelegationsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryBTCDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCUndelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBTCDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { + if m.DelegatorUnbondingInfoResponse != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.DelegatorUnbondingInfoResponse.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2664,17 +2389,61 @@ func (m *QueryBTCDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x32 } - if m.Status != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + if len(m.CovenantSlashingSigs) > 0 { + for iNdEx := len(m.CovenantSlashingSigs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CovenantSlashingSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.DelegatorSlashingSigHex) > 0 { + i -= len(m.DelegatorSlashingSigHex) + copy(dAtA[i:], m.DelegatorSlashingSigHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashingSigHex))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x22 + } + if len(m.SlashingTxHex) > 0 { + i -= len(m.SlashingTxHex) + copy(dAtA[i:], m.SlashingTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) + i-- + dAtA[i] = 0x1a + } + if len(m.CovenantUnbondingSigList) > 0 { + for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CovenantUnbondingSigList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.UnbondingTxHex) > 0 { + i -= len(m.UnbondingTxHex) + copy(dAtA[i:], m.UnbondingTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.UnbondingTxHex))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryBTCDelegationsResponse) Marshal() (dAtA []byte, err error) { +func (m *BTCDelegatorDelegationsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2684,32 +2453,20 @@ func (m *QueryBTCDelegationsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryBTCDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCDelegatorDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBTCDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCDelegatorDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.BtcDelegations) > 0 { - for iNdEx := len(m.BtcDelegations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Dels) > 0 { + for iNdEx := len(m.Dels) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.BtcDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Dels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2723,7 +2480,7 @@ func (m *QueryBTCDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryFinalityProviderPowerAtHeightRequest) Marshal() (dAtA []byte, err error) { +func (m *FinalityProviderResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2733,145 +2490,44 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Marshal() (dAtA []byte, err return dAtA[:n], nil } -func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *FinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *FinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x48 + } if m.Height != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.Height)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x40 } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderPowerAtHeightResponse) 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 *QueryFinalityProviderPowerAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderPowerAtHeightResponse) 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] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderCurrentPowerRequest) 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 *QueryFinalityProviderCurrentPowerRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderCurrentPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderCurrentPowerResponse) 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 *QueryFinalityProviderCurrentPowerResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderCurrentPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + if m.SlashedBtcHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x38 } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if m.SlashedBabylonHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryActiveFinalityProvidersAtHeightRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + dAtA[i] = 0x30 } - return dAtA[:n], nil -} - -func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { + if m.Pop != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Pop.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2879,104 +2535,42 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ActiveFinalityProvidersAtHeightResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + dAtA[i] = 0x2a } - return dAtA[:n], nil -} - -func (m *ActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Jailed { - i-- - if m.Jailed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x30 - } - if m.SlashedBtcHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) - i-- - dAtA[i] = 0x28 - } - if m.SlashedBabylonHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) - i-- - dAtA[i] = 0x20 - } - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x18 + dAtA[i] = 0x22 } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Addr))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x1a } - if m.BtcPkHex != nil { + if m.Commission != nil { { - size := m.BtcPkHex.Size() + size := m.Commission.Size() i -= size - if _, err := m.BtcPkHex.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryActiveFinalityProvidersAtHeightResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + dAtA[i] = 0x12 } - return dAtA[:n], nil -} - -func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { + if m.Description != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2984,1930 +2578,434 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - } - if len(m.FinalityProviders) > 0 { - for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryActivatedHeightRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *QueryActivatedHeightRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *QueryActivatedHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - return len(dAtA) - i, nil + return n } -func (m *QueryActivatedHeightResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryActivatedHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryActivatedHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryParamsByVersionRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 + if m.Version != 0 { + n += 1 + sovQuery(uint64(m.Version)) } - return len(dAtA) - i, nil + return n } -func (m *QueryFinalityProviderDelegationsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryParamsByVersionResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryFinalityProviderDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryFinalityProvidersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryFinalityProviderDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryFinalityProvidersResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } - i-- - dAtA[i] = 0x12 } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *QueryFinalityProviderDelegationsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryFinalityProviderRequest) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryFinalityProviderDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryFinalityProviderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FinalityProvider != nil { + l = m.FinalityProvider.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryFinalityProviderDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryBTCDelegationsRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) } - if len(m.BtcDelegatorDelegations) > 0 { - for iNdEx := len(m.BtcDelegatorDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BtcDelegatorDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *QueryBTCDelegationRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryBTCDelegationsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *QueryBTCDelegationRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + var l int + _ = l + if len(m.BtcDelegations) > 0 { + for _, e := range m.BtcDelegations { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryBTCDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryFinalityProviderDelegationsRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.StakingTxHashHex) > 0 { - i -= len(m.StakingTxHashHex) - copy(dAtA[i:], m.StakingTxHashHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHashHex))) - i-- - dAtA[i] = 0xa + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryBTCDelegationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryFinalityProviderDelegationsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + if len(m.BtcDelegatorDelegations) > 0 { + for _, e := range m.BtcDelegatorDelegations { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryBTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryBTCDelegationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHashHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryBTCDelegationResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.BtcDelegation != nil { - { - size, err := m.BtcDelegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + l = m.BtcDelegation.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *BTCDelegationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *BTCDelegationResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *BTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if m.ParamsVersion != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ParamsVersion)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 + l = len(m.StakerAddr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if m.UndelegationResponse != nil { - { - size, err := m.UndelegationResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovQuery(uint64(l)) } - if m.UnbondingTime != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.UnbondingTime)) - i-- - dAtA[i] = 0x78 + if len(m.FpBtcPkList) > 0 { + for _, e := range m.FpBtcPkList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } - if len(m.StatusDesc) > 0 { - i -= len(m.StatusDesc) - copy(dAtA[i:], m.StatusDesc) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StatusDesc))) - i-- - dAtA[i] = 0x72 + if m.StakingTime != 0 { + n += 1 + sovQuery(uint64(m.StakingTime)) } - if m.Active { - i-- - if m.Active { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x68 + if m.StartHeight != 0 { + n += 1 + sovQuery(uint64(m.StartHeight)) } - if m.StakingOutputIdx != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StakingOutputIdx)) - i-- - dAtA[i] = 0x60 + if m.EndHeight != 0 { + n += 1 + sovQuery(uint64(m.EndHeight)) } - if len(m.CovenantSigs) > 0 { - for iNdEx := len(m.CovenantSigs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CovenantSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } + if m.TotalSat != 0 { + n += 1 + sovQuery(uint64(m.TotalSat)) } - if len(m.DelegatorSlashSigHex) > 0 { - i -= len(m.DelegatorSlashSigHex) - copy(dAtA[i:], m.DelegatorSlashSigHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashSigHex))) - i-- - dAtA[i] = 0x52 + l = len(m.StakingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.SlashingTxHex) > 0 { - i -= len(m.SlashingTxHex) - copy(dAtA[i:], m.SlashingTxHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) - i-- - dAtA[i] = 0x4a + l = len(m.SlashingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.StakingTxHex) > 0 { - i -= len(m.StakingTxHex) - copy(dAtA[i:], m.StakingTxHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHex))) - i-- - dAtA[i] = 0x42 + l = len(m.DelegatorSlashSigHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if m.TotalSat != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.TotalSat)) - i-- - dAtA[i] = 0x38 + if len(m.CovenantSigs) > 0 { + for _, e := range m.CovenantSigs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } - if m.EndHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.EndHeight)) - i-- - dAtA[i] = 0x30 + if m.StakingOutputIdx != 0 { + n += 1 + sovQuery(uint64(m.StakingOutputIdx)) } - if m.StartHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) - i-- - dAtA[i] = 0x28 + if m.Active { + n += 2 } - if m.StakingTime != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StakingTime)) - i-- - dAtA[i] = 0x20 + l = len(m.StatusDesc) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.FpBtcPkList) > 0 { - for iNdEx := len(m.FpBtcPkList) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.FpBtcPkList[iNdEx].Size() - i -= size - if _, err := m.FpBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } + if m.UnbondingTime != 0 { + n += 1 + sovQuery(uint64(m.UnbondingTime)) } - if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 + if m.UndelegationResponse != nil { + l = m.UndelegationResponse.Size() + n += 2 + l + sovQuery(uint64(l)) } - if len(m.StakerAddr) > 0 { - i -= len(m.StakerAddr) - copy(dAtA[i:], m.StakerAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerAddr))) - i-- - dAtA[i] = 0xa + if m.ParamsVersion != 0 { + n += 2 + sovQuery(uint64(m.ParamsVersion)) } - return len(dAtA) - i, nil + return n } -func (m *DelegatorUnbondingInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *DelegatorUnbondingInfoResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *DelegatorUnbondingInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegatorUnbondingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if len(m.SpendStakeTxHex) > 0 { - i -= len(m.SpendStakeTxHex) - copy(dAtA[i:], m.SpendStakeTxHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SpendStakeTxHex))) - i-- - dAtA[i] = 0xa + l = len(m.SpendStakeTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *BTCUndelegationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *BTCUndelegationResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *BTCUndelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if m.DelegatorUnbondingInfoResponse != nil { - { - size, err := m.DelegatorUnbondingInfoResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 + l = len(m.UnbondingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.CovenantSlashingSigs) > 0 { - for iNdEx := len(m.CovenantSlashingSigs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CovenantSlashingSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a + if len(m.CovenantUnbondingSigList) > 0 { + for _, e := range m.CovenantUnbondingSigList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } - if len(m.DelegatorSlashingSigHex) > 0 { - i -= len(m.DelegatorSlashingSigHex) - copy(dAtA[i:], m.DelegatorSlashingSigHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashingSigHex))) - i-- - dAtA[i] = 0x22 + l = len(m.SlashingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.SlashingTxHex) > 0 { - i -= len(m.SlashingTxHex) - copy(dAtA[i:], m.SlashingTxHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) - i-- - dAtA[i] = 0x1a + l = len(m.DelegatorSlashingSigHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - if len(m.CovenantUnbondingSigList) > 0 { - for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CovenantUnbondingSigList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 + if len(m.CovenantSlashingSigs) > 0 { + for _, e := range m.CovenantSlashingSigs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } - if len(m.UnbondingTxHex) > 0 { - i -= len(m.UnbondingTxHex) - copy(dAtA[i:], m.UnbondingTxHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.UnbondingTxHex))) - i-- - dAtA[i] = 0xa + if m.DelegatorUnbondingInfoResponse != nil { + l = m.DelegatorUnbondingInfoResponse.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *BTCDelegatorDelegationsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *BTCDelegatorDelegationsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *BTCDelegatorDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCDelegatorDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l if len(m.Dels) > 0 { - for iNdEx := len(m.Dels) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Dels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + for _, e := range m.Dels { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } - return len(dAtA) - i, nil + return n } -func (m *FinalityProviderResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *FinalityProviderResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *FinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if m.Jailed { - i-- - if m.Jailed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x50 - } - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x48 - } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x40 - } - if m.SlashedBtcHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) - i-- - dAtA[i] = 0x38 + if m.Description != nil { + l = m.Description.Size() + n += 1 + l + sovQuery(uint64(l)) } - if m.SlashedBabylonHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) - i-- - dAtA[i] = 0x30 + if m.Commission != nil { + l = m.Commission.Size() + n += 1 + l + sovQuery(uint64(l)) } - if m.Pop != nil { - { - size, err := m.Pop.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.Addr) > 0 { - i -= len(m.Addr) - copy(dAtA[i:], m.Addr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Addr))) - i-- - dAtA[i] = 0x1a - } - if m.Commission != nil { - { - size := m.Commission.Size() - i -= size - if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Description != nil { - { - size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + l = m.BtcPk.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ + if m.Pop != nil { + l = m.Pop.Size() + n += 1 + l + sovQuery(uint64(l)) } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 + if m.SlashedBabylonHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 + if m.SlashedBtcHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryParamsByVersionRequest) Size() (n int) { - if m == nil { - return 0 + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) } - var l int - _ = l - if m.Version != 0 { - n += 1 + sovQuery(uint64(m.Version)) + if m.Jailed { + n += 2 } return n } -func (m *QueryParamsByVersionResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryFinalityProvidersRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProvidersResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.FinalityProviders) > 0 { - for _, e := range m.FinalityProviders { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FinalityProvider != nil { - l = m.FinalityProvider.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != 0 { - n += 1 + sovQuery(uint64(m.Status)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BtcDelegations) > 0 { - for _, e := range m.BtcDelegations { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderPowerAtHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - return n -} - -func (m *QueryFinalityProviderPowerAtHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) - } - return n -} - -func (m *QueryFinalityProviderCurrentPowerRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderCurrentPowerResponse) 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 *QueryActiveFinalityProvidersAtHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *ActiveFinalityProvidersAtHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcPkHex != nil { - l = m.BtcPkHex.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) - } - if m.SlashedBabylonHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) - } - if m.SlashedBtcHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) - } - if m.Jailed { - n += 2 - } - return n -} - -func (m *QueryActiveFinalityProvidersAtHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.FinalityProviders) > 0 { - for _, e := range m.FinalityProviders { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryActivatedHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryActivatedHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - return n -} - -func (m *QueryFinalityProviderDelegationsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderDelegationsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BtcDelegatorDelegations) > 0 { - for _, e := range m.BtcDelegatorDelegations { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakingTxHashHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcDelegation != nil { - l = m.BtcDelegation.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *BTCDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.FpBtcPkList) > 0 { - for _, e := range m.FpBtcPkList { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.StakingTime != 0 { - n += 1 + sovQuery(uint64(m.StakingTime)) - } - if m.StartHeight != 0 { - n += 1 + sovQuery(uint64(m.StartHeight)) - } - if m.EndHeight != 0 { - n += 1 + sovQuery(uint64(m.EndHeight)) - } - if m.TotalSat != 0 { - n += 1 + sovQuery(uint64(m.TotalSat)) - } - l = len(m.StakingTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.SlashingTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.DelegatorSlashSigHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.CovenantSigs) > 0 { - for _, e := range m.CovenantSigs { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.StakingOutputIdx != 0 { - n += 1 + sovQuery(uint64(m.StakingOutputIdx)) - } - if m.Active { - n += 2 - } - l = len(m.StatusDesc) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.UnbondingTime != 0 { - n += 1 + sovQuery(uint64(m.UnbondingTime)) - } - if m.UndelegationResponse != nil { - l = m.UndelegationResponse.Size() - n += 2 + l + sovQuery(uint64(l)) - } - if m.ParamsVersion != 0 { - n += 2 + sovQuery(uint64(m.ParamsVersion)) - } - return n -} - -func (m *DelegatorUnbondingInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SpendStakeTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *BTCUndelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UnbondingTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.CovenantUnbondingSigList) > 0 { - for _, e := range m.CovenantUnbondingSigList { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - l = len(m.SlashingTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.DelegatorSlashingSigHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.CovenantSlashingSigs) > 0 { - for _, e := range m.CovenantSlashingSigs { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.DelegatorUnbondingInfoResponse != nil { - l = m.DelegatorUnbondingInfoResponse.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *BTCDelegatorDelegationsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Dels) > 0 { - for _, e := range m.Dels { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *FinalityProviderResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Description != nil { - l = m.Description.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Commission != nil { - l = m.Commission.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Addr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pop != nil { - l = m.Pop.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.SlashedBabylonHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) - } - if m.SlashedBtcHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) - } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) - } - if m.Jailed { - n += 2 - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *QueryParamsByVersionRequest) 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: QueryParamsByVersionRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsByVersionRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint32(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 *QueryParamsByVersionResponse) 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: QueryParamsByVersionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsByVersionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *QueryFinalityProvidersRequest) 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: QueryFinalityProvidersRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProvidersRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *QueryFinalityProvidersResponse) 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: QueryFinalityProvidersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProvidersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderResponse{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *QueryFinalityProviderRequest) 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: QueryFinalityProviderRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", 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.FpBtcPkHex = 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 *QueryFinalityProviderResponse) 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: QueryFinalityProviderResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProvider", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FinalityProvider == nil { - m.FinalityProvider = &FinalityProviderResponse{} - } - if err := m.FinalityProvider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *QueryBTCDelegationsRequest) 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: QueryBTCDelegationsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= BTCDelegationStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 postIndex > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - iNdEx = postIndex + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4929,7 +3027,7 @@ func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4952,49 +3050,15 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBTCDelegationsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BtcDelegations = append(m.BtcDelegations, &BTCDelegationResponse{}) - if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5021,10 +3085,7 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -5049,7 +3110,7 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsByVersionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5072,49 +3133,17 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsByVersionRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsByVersionRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", 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.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } - m.Height = 0 + m.Version = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5124,7 +3153,7 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Version |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -5150,7 +3179,7 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsByVersionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5173,17 +3202,17 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsByVersionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsByVersionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - m.VotingPower = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5193,11 +3222,25 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro } b := dAtA[iNdEx] iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5219,7 +3262,7 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro } return nil } -func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProvidersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5242,17 +3285,17 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProvidersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProvidersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5262,23 +3305,27 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -5301,7 +3348,7 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProvidersResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5324,17 +3371,17 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProvidersResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProvidersResponse: 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) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5344,16 +3391,31 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderResponse{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.VotingPower = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5363,11 +3425,28 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5389,7 +3468,7 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProviderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5412,36 +3491,17 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProviderRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProviderRequest: 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 != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5451,27 +3511,23 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + if postIndex > l { + return io.ErrUnexpectedEOF } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -5494,7 +3550,7 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err } return nil } -func (m *ActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProviderResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5517,17 +3573,17 @@ func (m *ActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProviderResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProviderResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPkHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProvider", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5537,124 +3593,28 @@ func (m *ActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPkHex = &v - if err := m.BtcPkHex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.FinalityProvider == nil { + m.FinalityProvider = &FinalityProviderResponse{} + } + if err := m.FinalityProvider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: - 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 3: - 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 - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashedBabylonHeight", wireType) - } - m.SlashedBabylonHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SlashedBabylonHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashedBtcHeight", wireType) - } - m.SlashedBtcHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SlashedBtcHeight |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Jailed = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5676,7 +3636,7 @@ func (m *ActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5699,17 +3659,17 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBTCDelegationsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBTCDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var msglen int + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5719,26 +3679,11 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Status |= BTCDelegationStatus(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FinalityProviders = append(m.FinalityProviders, &ActiveFinalityProvidersAtHeightResponse{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -5769,7 +3714,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + m.Pagination = &query.PageRequest{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -5796,7 +3741,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er } return nil } -func (m *QueryActivatedHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5819,67 +3764,51 @@ func (m *QueryActivatedHeightRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActivatedHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBTCDelegationsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivatedHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBTCDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegations", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthQuery } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryActivatedHeightResponse) 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 + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.BtcDelegations = append(m.BtcDelegations, &BTCDelegationResponse{}) + if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryActivatedHeightResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivatedHeightResponse: 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) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5889,11 +3818,28 @@ func (m *QueryActivatedHeightResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7502,25 +5448,6 @@ func (m *FinalityProviderResponse) Unmarshal(dAtA []byte) error { } } case 9: - 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 - } - } - case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) } diff --git a/x/btcstaking/types/query.pb.gw.go b/x/btcstaking/types/query.pb.gw.go index 4cd302b72..aa5969378 100644 --- a/x/btcstaking/types/query.pb.gw.go +++ b/x/btcstaking/types/query.pb.gw.go @@ -273,226 +273,6 @@ func local_request_Query_BTCDelegations_0(ctx context.Context, marshaler runtime } -var ( - filter_Query_ActiveFinalityProvidersAtHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActiveFinalityProvidersAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.ActiveFinalityProvidersAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActiveFinalityProvidersAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.ActiveFinalityProvidersAtHeight(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderPowerAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := client.FinalityProviderPowerAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderPowerAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := server.FinalityProviderPowerAtHeight(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderCurrentPowerRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - msg, err := client.FinalityProviderCurrentPower(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderCurrentPowerRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - msg, err := server.FinalityProviderCurrentPower(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 - - msg, err := client.ActivatedHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActivatedHeightRequest - var metadata runtime.ServerMetadata - - msg, err := server.ActivatedHeight(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_FinalityProviderDelegations_0 = &utilities.DoubleArray{Encoding: map[string]int{"fp_btc_pk_hex": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -740,98 +520,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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() - 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_ActivatedHeight_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_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_FinalityProviderDelegations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1019,86 +707,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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() - 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_ActivatedHeight_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_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_FinalityProviderDelegations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1153,14 +761,6 @@ var ( pattern_Query_BTCDelegations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "btc_delegations", "status"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_ActiveFinalityProvidersAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "finality_providers", "height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_FinalityProviderPowerAtHeight_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", "finality_providers", "fp_btc_pk_hex", "power", "height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_FinalityProviderCurrentPower_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", "finality_providers", "fp_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_FinalityProviderDelegations_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", "finality_providers", "fp_btc_pk_hex", "delegations"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_BTCDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "btc_delegation", "staking_tx_hash_hex"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1177,14 +777,6 @@ var ( forward_Query_BTCDelegations_0 = runtime.ForwardResponseMessage - forward_Query_ActiveFinalityProvidersAtHeight_0 = runtime.ForwardResponseMessage - - forward_Query_FinalityProviderPowerAtHeight_0 = runtime.ForwardResponseMessage - - forward_Query_FinalityProviderCurrentPower_0 = runtime.ForwardResponseMessage - - forward_Query_ActivatedHeight_0 = runtime.ForwardResponseMessage - forward_Query_FinalityProviderDelegations_0 = runtime.ForwardResponseMessage forward_Query_BTCDelegation_0 = runtime.ForwardResponseMessage diff --git a/x/finality/README.md b/x/finality/README.md index 11c35a766..c4f19e6d2 100644 --- a/x/finality/README.md +++ b/x/finality/README.md @@ -22,14 +22,17 @@ providers; - [Concepts](#concepts) - [States](#states) - [Parameters](#parameters) + - [Voting power table](#voting-power-table) - [Public randomness](#public-randomness) - [Finality votes](#finality-votes) - [Indexed blocks with finalization status](#indexed-blocks-with-finalization-status) - [Equivocation evidences](#equivocation-evidences) + - [Signing info tracker](#signing-info-tracker) - [Messages](#messages) - [MsgCommitPubRandList](#msgcommitpubrandlist) - [MsgAddFinalitySig](#msgaddfinalitysig) - [MsgUpdateParams](#msgupdateparams) +- [BeginBlocker](#beginblocker) - [EndBlocker](#endblocker) - [Events](#events) - [Queries](#queries) @@ -82,14 +85,13 @@ participate in the finality voting round, an active finality provider with BTC delegations (as specified in the [BTC Staking module](../btcstaking/README.md)) needs to interact with Babylon as follows: -- **Committing EOTS public randomness.** The finality provider proactively - sends a merkle-tree-based commit of a list of *EOTS public randomness* - for future heights to the Finality module. EOTS ensures that given an EOTS - public randomness, a signer can only sign a single message. - Otherwise, anyone can extract the signer's secret key - by using two EOTS signatures on different messages, the corresponding EOTS - public randomness, and the signer's public key. - A public randomness commit takes effect only after it is BTC-timestamped. +- **Committing EOTS public randomness.** The finality provider proactively sends + a merkle-tree-based commit of a list of *EOTS public randomness* for future + heights to the Finality module. EOTS ensures that given an EOTS public + randomness, a signer can only sign a single message. Otherwise, anyone can + extract the signer's secret key by using two EOTS signatures on different + messages, the corresponding EOTS public randomness, and the signer's public + key. A public randomness commit takes effect only after it is BTC-timestamped. - **Submitting EOTS signatures.** Upon a new block, the finality provider submits an EOTS signature w.r.t. the derived public randomness at that height. The Finality module will verify the EOTS signature, and check if there are @@ -137,14 +139,24 @@ message Params { } ``` +### Voting power table + +The [voting power table management](./keeper/voting_power_table.go) maintains +the voting power table of all finality providers at each height of the Babylon +chain. The key is the block height concatenated with the finality provider's +Bitcoin secp256k1 public key in BIP-340 format, and the value is the finality +provider's voting power quantified in Satoshis. Voting power is assigned to top +`N` (defined in parameters) finality providers that have BTC-timestamped public +randomness for the height, ranked by the total delegated value. + ### Public randomness The [public randomness storage](./keeper/public_randomness.go) maintains the EOTS public randomness commit that each finality provider commits to Babylon. The key is the finality provider's Bitcoin secp256k1 public key concatenated -with the block height, and the value is a merkle tree constructed by the list -of public randomness with starting height, and the number of public randomness. -It also stores the epoch number at which Babylon receives the commit. +with the block height, and the value is a merkle tree constructed by the list of +public randomness with starting height, and the number of public randomness. It +also stores the epoch number at which Babylon receives the commit. ```protobuf // PubRandCommit is a commitment to a series of public randomness @@ -250,18 +262,17 @@ Information about finality providers' voting histories is tracked through The first mapping allows us to easily look at the recent signing info for a finality provider based on its public key, while the second mapping -(`MissedBlocksBitArray`) acts as a bit-array of size `SignedBlocksWindow` -that tells us if the finality provider missed the block for a given index in -the bit-array. The index in the bit-array is given as little-endian uint64. -The result is a varint that takes on 0 or 1, where 0 indicates the finality -provider did not miss (did sign) the corresponding block, and 1 indicates -they missed the block (did not sign). +(`MissedBlocksBitArray`) acts as a bit-array of size `SignedBlocksWindow` that +tells us if the finality provider missed the block for a given index in the +bit-array. The index in the bit-array is given as little-endian uint64. The +result is a varint that takes on 0 or 1, where 0 indicates the finality provider +did not miss (did sign) the corresponding block, and 1 indicates they missed the +block (did not sign). Note that the `MissedBlocksBitArray` is not explicitly initialized up-front. -Keys are added as the first `SignedBlocksWindow` blocks -for a newly active finality provider. The `SignedBlocksWindow` parameter -defines the size (number of blocks) of the sliding window used to track -finality provider liveness. +Keys are added as the first `SignedBlocksWindow` blocks for a newly active +finality provider. The `SignedBlocksWindow` parameter defines the size (number +of blocks) of the sliding window used to track finality provider liveness. The information stored for tracking finality provider liveness is as follows: @@ -300,9 +311,9 @@ The message handlers are defined at ### MsgCommitPubRandList The `MsgCommitPubRandList` message is used for committing a merkle tree -constructed by a list of EOTS public randomness that will be used by a -finality provider in the future. It is typically submitted by a finality -provider via the [finality provider](https://github.com/babylonchain/finality-provider) program. +constructed by a list of EOTS public randomness that will be used by a finality +provider in the future. It is typically submitted by a finality provider via the +[finality provider](https://github.com/babylonchain/finality-provider) program. ```protobuf // MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS @@ -410,6 +421,21 @@ message MsgUpdateParams { } ``` +## BeginBlocker + +Upon `EndBlocker`, the Finality module of each Babylon node will [execute the +following](./abci.go): + +1. Record the voting power table at the current height, by reconciling the + voting power table at the last height with all events that affect voting + power distribution (including newly active BTC delegations, newly unbonded + BTC delegations, and slashed finality providers). Note that the voting power + is assigned to a finality provider if it (1) has BTC-timestamped public + randomness, and (2) it is ranked at top `N` by the total delegated value. +2. If the BTC Staking protocol is activated, i.e., there exists at least 1 + active BTC delegation, then record the voting power distribution w.r.t. the + active finality providers and active BTC delegations. + ## EndBlocker Upon `EndBlocker`, the Finality module of each Babylon node will [execute the @@ -435,8 +461,8 @@ been >=1 active BTC delegations)*: distribute rewards to the voted finality providers and their BTC delegations. Otherwise, none of the subsequent blocks shall be finalized and the loop breaks here. -3. Update the finality provider's voting history and label it to `sluggish` - if the number of block it has missed has passed the parameterized threshold. +3. Update the finality provider's voting history and label it to `sluggish` if + the number of block it has missed has passed the parameterized threshold. ## Events diff --git a/x/finality/client/cli/query.go b/x/finality/client/cli/query.go index 1d1215c82..01d0a7b07 100644 --- a/x/finality/client/cli/query.go +++ b/x/finality/client/cli/query.go @@ -28,15 +28,113 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdListPublicRandomness()) - cmd.AddCommand(CmdListPubRandCommit()) - cmd.AddCommand(CmdBlock()) - cmd.AddCommand(CmdListBlocks()) - cmd.AddCommand(CmdVotesAtHeight()) - cmd.AddCommand(CmdListEvidences()) - cmd.AddCommand(CmdSigningInfo()) - cmd.AddCommand(CmdAllSigningInfo()) + cmd.AddCommand( + CmdQueryParams(), + CmdFinalityProvidersAtHeight(), + CmdFinalityProviderPowerAtHeight(), + CmdActivatedHeight(), + CmdListPublicRandomness(), + CmdListPubRandCommit(), + CmdBlock(), + CmdListBlocks(), + CmdVotesAtHeight(), + CmdListEvidences(), + CmdSigningInfo(), + CmdAllSigningInfo(), + ) + + return cmd +} + +func CmdFinalityProviderPowerAtHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "finality-provider-power-at-height [fp_btc_pk_hex] [height]", + Short: "get the voting power of a given finality provider at a given height", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + height, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + res, err := queryClient.FinalityProviderPowerAtHeight(cmd.Context(), &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: args[0], + Height: height, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdActivatedHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "activated-height", + Short: "get activated height, i.e., the first height where there exists 1 finality provider with voting power", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.ActivatedHeight(cmd.Context(), &types.QueryActivatedHeightRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdFinalityProvidersAtHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "finality-providers-at-height [height]", + Short: "retrieve all finality providers at a given babylon height", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + height, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.ActiveFinalityProvidersAtHeight(cmd.Context(), &types.QueryActiveFinalityProvidersAtHeightRequest{ + Height: height, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "finality-providers-at-height") return cmd } diff --git a/x/finality/keeper/genesis.go b/x/finality/keeper/genesis.go index 8d9752866..ee5f21688 100644 --- a/x/finality/keeper/genesis.go +++ b/x/finality/keeper/genesis.go @@ -48,6 +48,14 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { } } + for _, fpVP := range gs.VotingPowers { + k.SetVotingPower(ctx, *fpVP.FpBtcPk, fpVP.BlockHeight, fpVP.VotingPower) + } + + for _, vpCache := range gs.VpDstCache { + k.SetVotingPowerDistCache(ctx, vpCache.BlockHeight, vpCache.VpDistribution) + } + return k.SetParams(ctx, gs.Params) } @@ -83,6 +91,16 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } + vpFps, err := k.fpVotingPowers(ctx) + if err != nil { + return nil, err + } + + vpDstCache, err := k.votingPowersDistCacheBlkHeight(ctx) + if err != nil { + return nil, err + } + return &types.GenesisState{ Params: k.GetParams(ctx), IndexedBlocks: blocks, @@ -92,6 +110,8 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) PubRandCommit: prCommit, SigningInfos: signingInfos, MissedBlocks: missedBlocks, + VotingPowers: vpFps, + VpDstCache: vpDstCache, }, nil } @@ -254,6 +274,49 @@ func (k Keeper) signingInfosAndMissedBlock(ctx context.Context) ([]types.Signing return signingInfos, missedBlocks, nil } +// fpVotingPowers gets the voting power of a given finality provider at a given Babylon height. +func (k Keeper) fpVotingPowers(ctx context.Context) ([]*types.VotingPowerFP, error) { + iter := k.votingPowerStore(ctx).Iterator(nil, nil) + defer iter.Close() + + vpFps := make([]*types.VotingPowerFP, 0) + + for ; iter.Valid(); iter.Next() { + blkHeight, fpBTCPK, err := btcstk.ParseBlkHeightAndPubKeyFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + + vp := sdk.BigEndianToUint64(iter.Value()) + vpFps = append(vpFps, &types.VotingPowerFP{ + BlockHeight: blkHeight, + FpBtcPk: fpBTCPK, + VotingPower: vp, + }) + } + + return vpFps, nil +} + +func (k Keeper) votingPowersDistCacheBlkHeight(ctx context.Context) ([]*types.VotingPowerDistCacheBlkHeight, error) { + vps := make([]*types.VotingPowerDistCacheBlkHeight, 0) + iter := k.votingPowerDistCacheStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var dc types.VotingPowerDistCache + if err := dc.Unmarshal(iter.Value()); err != nil { + return nil, err + } + vps = append(vps, &types.VotingPowerDistCacheBlkHeight{ + BlockHeight: sdk.BigEndianToUint64(iter.Key()), + VpDistribution: &dc, + }) + } + + return vps, nil +} + // parsePubKeyAndBlkHeightFromStoreKey expects to receive a key with // BIP340PubKey(fpBTCPK) || BigEndianUint64(blkHeight) func parsePubKeyAndBlkHeightFromStoreKey(key []byte) (fpBTCPK *bbn.BIP340PubKey, blkHeight uint64, err error) { diff --git a/x/finality/keeper/genesis_test.go b/x/finality/keeper/genesis_test.go index be852b15d..df9286152 100644 --- a/x/finality/keeper/genesis_test.go +++ b/x/finality/keeper/genesis_test.go @@ -36,6 +36,7 @@ func FuzzTestExportGenesis(f *testing.F) { allBlocks := make([]*types.IndexedBlock, numPubRand) allEvidences := make([]*types.Evidence, numPubRand) allPublicRandomness := make([]*types.PublicRandomness, numPubRand) + for i := 0; i < int(numPubRand); i++ { // Votes vt := &types.VoteSig{ @@ -109,6 +110,20 @@ func FuzzTestExportGenesis(f *testing.F) { fpSigningInfos[fpPk.MarshalHex()] = &signingInfo } + numFps := datagen.RandomInt(r, 10) + 1 + fps := datagen.CreateNFinalityProviders(r, t, int(numFps)) + vpFps := make(map[string]*types.VotingPowerFP, 0) + for _, fp := range fps { + vp := uint64(datagen.RandomInt(r, 1000000)) + // sets voting power + k.SetVotingPower(ctx, *fp.BtcPk, blkHeight, vp) + vpFps[fp.BtcPk.MarshalHex()] = &types.VotingPowerFP{ + BlockHeight: blkHeight, + FpBtcPk: fp.BtcPk, + VotingPower: vp, + } + } + require.Equal(t, len(allVotes), int(numPubRand)) require.Equal(t, len(allBlocks), int(numPubRand)) require.Equal(t, len(allEvidences), int(numPubRand)) @@ -128,5 +143,10 @@ func FuzzTestExportGenesis(f *testing.F) { require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].MissedBlocksCounter, info.FpSigningInfo.MissedBlocksCounter) require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].StartHeight, info.FpSigningInfo.StartHeight) } + + require.Equal(t, len(vpFps), len(gs.VotingPowers)) + for _, fpVp := range gs.VotingPowers { + require.Equal(t, vpFps[fpVp.FpBtcPk.MarshalHex()], fpVp) + } }) } diff --git a/x/finality/keeper/grpc_query.go b/x/finality/keeper/grpc_query.go index 5d4a33803..6b0289e49 100644 --- a/x/finality/keeper/grpc_query.go +++ b/x/finality/keeper/grpc_query.go @@ -13,14 +13,112 @@ import ( "google.golang.org/grpc/status" bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/types" ) var _ types.QueryServer = Keeper{} +// FinalityProviderPowerAtHeight returns the voting power of the specified finality provider +// at the provided Babylon height +func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.QueryFinalityProviderPowerAtHeightRequest) (*types.QueryFinalityProviderPowerAtHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) + } + + if !k.BTCStakingKeeper.HasFinalityProvider(ctx, *fpBTCPK) { + return nil, bstypes.ErrFpNotFound + } + + store := k.votingPowerBbnBlockHeightStore(ctx, req.Height) + iter := store.ReverseIterator(nil, nil) + defer iter.Close() + + if !iter.Valid() { + return nil, types.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", req.Height) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + power := k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height) + + return &types.QueryFinalityProviderPowerAtHeightResponse{VotingPower: power}, nil +} + +// FinalityProviderCurrentPower returns the voting power of the specified finality provider +// at the current height +func (k Keeper) FinalityProviderCurrentPower(ctx context.Context, req *types.QueryFinalityProviderCurrentPowerRequest) (*types.QueryFinalityProviderCurrentPowerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) + } + + height, power := k.GetCurrentVotingPower(ctx, *fpBTCPK) + + return &types.QueryFinalityProviderCurrentPowerResponse{Height: height, VotingPower: power}, nil +} + +// ActiveFinalityProvidersAtHeight returns the active finality providers at the provided height +func (k Keeper) ActiveFinalityProvidersAtHeight(ctx context.Context, req *types.QueryActiveFinalityProvidersAtHeightRequest) (*types.QueryActiveFinalityProvidersAtHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + store := k.votingPowerBbnBlockHeightStore(sdkCtx, req.Height) + + var finalityProvidersWithMeta []*bstypes.FinalityProviderWithMeta + pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + finalityProvider, err := k.BTCStakingKeeper.GetFinalityProvider(sdkCtx, key) + if err != nil { + return err + } + + votingPower := k.GetVotingPower(sdkCtx, key, req.Height) + if votingPower > 0 { + finalityProviderWithMeta := bstypes.FinalityProviderWithMeta{ + BtcPk: finalityProvider.BtcPk, + Height: req.Height, + VotingPower: votingPower, + SlashedBabylonHeight: finalityProvider.SlashedBabylonHeight, + SlashedBtcHeight: finalityProvider.SlashedBtcHeight, + } + finalityProvidersWithMeta = append(finalityProvidersWithMeta, &finalityProviderWithMeta) + } + + return nil + }) + if err != nil { + return nil, err + } + + return &types.QueryActiveFinalityProvidersAtHeightResponse{FinalityProviders: convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta), Pagination: pageRes}, nil +} + +// ActivatedHeight returns the Babylon height in which the BTC Staking protocol was enabled +func (k Keeper) ActivatedHeight(ctx context.Context, req *types.QueryActivatedHeightRequest) (*types.QueryActivatedHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + activatedHeight, err := k.GetBTCStakingActivatedHeight(sdkCtx) + if err != nil { + return nil, err + } + return &types.QueryActivatedHeightResponse{Height: activatedHeight}, nil +} + // ListPublicRandomness returns a list of public randomness committed by a given // finality provider -// TODO: remove public randomness storage? func (k Keeper) ListPublicRandomness(ctx context.Context, req *types.QueryListPublicRandomnessRequest) (*types.QueryListPublicRandomnessResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -311,3 +409,18 @@ func convertToEvidenceListResponse(evidences []*types.Evidence) []*types.Evidenc } return response } + +func convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta []*bstypes.FinalityProviderWithMeta) []*types.ActiveFinalityProvidersAtHeightResponse { + var activeFinalityProvidersAtHeightResponse []*types.ActiveFinalityProvidersAtHeightResponse + for _, fpWithMeta := range finalityProvidersWithMeta { + activeFinalityProvidersAtHeightResponse = append(activeFinalityProvidersAtHeightResponse, &types.ActiveFinalityProvidersAtHeightResponse{ + BtcPkHex: fpWithMeta.BtcPk, + Height: fpWithMeta.Height, + VotingPower: fpWithMeta.VotingPower, + SlashedBabylonHeight: fpWithMeta.SlashedBabylonHeight, + SlashedBtcHeight: fpWithMeta.SlashedBtcHeight, + Jailed: fpWithMeta.Jailed, + }) + } + return activeFinalityProvidersAtHeightResponse +} diff --git a/x/finality/keeper/grpc_query_test.go b/x/finality/keeper/grpc_query_test.go index d42d21bd4..10e25fe5f 100644 --- a/x/finality/keeper/grpc_query_test.go +++ b/x/finality/keeper/grpc_query_test.go @@ -11,14 +11,214 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/babylonlabs-io/babylon/x/finality/keeper" "github.com/babylonlabs-io/babylon/x/finality/types" ) +func FuzzActivatedHeight(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.FinalityKeeper(t, nil, nil, nil) + ctx = sdk.UnwrapSDKContext(ctx) + + // not activated yet + _, err := keeper.GetBTCStakingActivatedHeight(ctx) + require.Error(t, err) + + randomActivatedHeight := datagen.RandomInt(r, 100) + 1 + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomActivatedHeight, uint64(10)) + + // now it's activated + resp, err := keeper.ActivatedHeight(ctx, &types.QueryActivatedHeightRequest{}) + require.NoError(t, err) + require.Equal(t, randomActivatedHeight, resp.Height) + }) +} + +func FuzzFinalityProviderPowerAtHeight(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Setup keeper and context + bk := types.NewMockBTCStakingKeeper(ctrl) + keeper, ctx := testkeeper.FinalityKeeper(t, bk, nil, nil) + + // random finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + // set random voting power at random height + randomHeight := datagen.RandomInt(r, 100) + 1 + randomPower := datagen.RandomInt(r, 100) + 1 + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) + + // happy case + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).Times(1) + req1 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Height: randomHeight, + } + resp, err := keeper.FinalityProviderPowerAtHeight(ctx, req1) + require.NoError(t, err) + require.Equal(t, randomPower, resp.VotingPower) + + // case where the voting power store is not updated in + // the given height + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).Times(1) + requestHeight := randomHeight + datagen.RandomInt(r, 10) + 1 + req2 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Height: requestHeight, + } + _, err = keeper.FinalityProviderPowerAtHeight(ctx, req2) + require.ErrorIs(t, err, types.ErrVotingPowerTableNotUpdated) + + // case where the given fp pk does not exist + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(false).Times(1) + randPk, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + req3 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: randPk.MarshalHex(), + Height: randomHeight, + } + _, err = keeper.FinalityProviderPowerAtHeight(ctx, req3) + require.ErrorIs(t, err, bstypes.ErrFpNotFound) + }) +} + +func FuzzFinalityProviderCurrentVotingPower(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Setup keeper and context + bk := types.NewMockBTCStakingKeeper(ctrl) + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).AnyTimes() + keeper, ctx := testkeeper.FinalityKeeper(t, bk, nil, nil) + + // random finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + // set random voting power at random height + randomHeight := datagen.RandomInt(r, 100) + 1 + ctx = datagen.WithCtxHeight(ctx, randomHeight) + randomPower := datagen.RandomInt(r, 100) + 1 + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) + + // assert voting power at current height + req := &types.QueryFinalityProviderCurrentPowerRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + } + resp, err := keeper.FinalityProviderCurrentPower(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 = datagen.WithCtxHeight(ctx, randomHeight+1) + resp, err = keeper.FinalityProviderCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight, resp.Height) + require.Equal(t, randomPower, resp.VotingPower) + + // test the case when the finality provider has 0 voting power + ctx = datagen.WithCtxHeight(ctx, randomHeight+2) + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight+2, 0) + resp, err = keeper.FinalityProviderCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight+2, resp.Height) + require.Equal(t, uint64(0), resp.VotingPower) + }) +} + +func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := bstypes.NewMockBTCLightClientKeeper(ctrl) + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + btccKeeper := bstypes.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + h.GenAndApplyParams(r) + + // Generate a random batch of finality providers + var fps []*bstypes.FinalityProvider + numFpsWithVotingPower := datagen.RandomInt(r, 10) + 1 + numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + for i := uint64(0); i < numFps; i++ { + _, _, fp := h.CreateFinalityProvider(r) + fps = append(fps, fp) + } + + // For numFpsWithVotingPower finality providers, generate a random number of BTC delegations + babylonHeight := datagen.RandomInt(r, 10) + 1 + fpsWithVotingPowerMap := make(map[string]*bstypes.FinalityProvider) + for i := uint64(0); i < numFpsWithVotingPower; i++ { + fpBTCPK := fps[i].BtcPk + fpsWithVotingPowerMap[fpBTCPK.MarshalHex()] = fps[i] + h.FinalityKeeper.SetVotingPower(h.Ctx, fpBTCPK.MustMarshal(), babylonHeight, 1) + } + + h.BeginBlocker() + + // Test nil request + resp, err := h.FinalityKeeper.ActiveFinalityProvidersAtHeight(h.Ctx, nil) + require.Nil(t, resp) + require.Error(t, err) + + // Generate a page request with a limit and a nil key + limit := datagen.RandomInt(r, int(numFpsWithVotingPower)) + 1 + pagination := constructRequestWithLimit(r, limit) + // Generate the initial query + req := types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} + // Construct a mapping from the finality providers found to a boolean value + // Will be used later to evaluate whether all the finality providers were returned + fpsFound := make(map[string]bool, 0) + + for i := uint64(0); i < numFpsWithVotingPower; i += limit { + resp, err = h.FinalityKeeper.ActiveFinalityProvidersAtHeight(h.Ctx, &req) + h.NoError(err) + require.NotNil(t, resp) + + for _, fp := range resp.FinalityProviders { + // Check if the pk exists in the map + if _, ok := fpsWithVotingPowerMap[fp.BtcPkHex.MarshalHex()]; !ok { + t.Fatalf("rpc returned a finality provider that was not created") + } + fpsFound[fp.BtcPkHex.MarshalHex()] = true + } + + // Construct the next page request + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + req = types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} + } + + require.Equal(t, len(fpsFound), len(fpsWithVotingPowerMap), "some finality providers were missed, got %d while %d were expected", len(fpsFound), len(fpsWithVotingPowerMap)) + }) +} + func FuzzBlock(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -453,3 +653,22 @@ func convertToEvidence(er *types.EvidenceResponse) *types.Evidence { ForkFinalitySig: er.ForkFinalitySig, } } + +// Constructors for PageRequest objects +func constructRequestWithKeyAndLimit(r *rand.Rand, key []byte, limit uint64) *query.PageRequest { + // If limit is 0, set one randomly + if limit == 0 { + limit = uint64(r.Int63() + 1) // Use Int63 instead of Uint64 to avoid overflows + } + return &query.PageRequest{ + Key: key, + Offset: 0, // only offset or key is set + Limit: limit, + CountTotal: false, // only used when offset is used + Reverse: false, + } +} + +func constructRequestWithLimit(r *rand.Rand, limit uint64) *query.PageRequest { + return constructRequestWithKeyAndLimit(r, nil, limit) +} diff --git a/x/finality/keeper/keeper.go b/x/finality/keeper/keeper.go index c23b29fe5..1a9851104 100644 --- a/x/finality/keeper/keeper.go +++ b/x/finality/keeper/keeper.go @@ -97,6 +97,6 @@ func (k Keeper) IsFinalityActive(ctx context.Context) (activated bool) { return false } - _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx) + _, err := k.GetBTCStakingActivatedHeight(ctx) return err == nil } diff --git a/x/finality/keeper/liveness.go b/x/finality/keeper/liveness.go index 8748e3849..ec2cc3a4a 100644 --- a/x/finality/keeper/liveness.go +++ b/x/finality/keeper/liveness.go @@ -14,7 +14,7 @@ import ( // including jailing sluggish finality providers and applying punishment (TBD) func (k Keeper) HandleLiveness(ctx context.Context, height int64) { // get all the active finality providers for the height - fpSet := k.BTCStakingKeeper.GetVotingPowerTable(ctx, uint64(height)) + fpSet := k.GetVotingPowerTable(ctx, uint64(height)) // get all the voters for the height voterBTCPKs := k.GetVoters(ctx, uint64(height)) diff --git a/x/finality/keeper/msg_server.go b/x/finality/keeper/msg_server.go index b02329a19..f414a877c 100644 --- a/x/finality/keeper/msg_server.go +++ b/x/finality/keeper/msg_server.go @@ -92,7 +92,7 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal } // ensure the finality provider has voting power at this height - if ms.BTCStakingKeeper.GetVotingPower(ctx, fpPK.MustMarshal(), req.BlockHeight) == 0 { + if ms.GetVotingPower(ctx, fpPK.MustMarshal(), req.BlockHeight) == 0 { return nil, types.ErrInvalidFinalitySig.Wrapf("the finality provider %s does not have voting power at height %d", fpPK.MarshalHex(), req.BlockHeight) } diff --git a/x/finality/keeper/msg_server_test.go b/x/finality/keeper/msg_server_test.go index 224dcd343..f7e54ee50 100644 --- a/x/finality/keeper/msg_server_test.go +++ b/x/finality/keeper/msg_server_test.go @@ -150,7 +150,7 @@ func FuzzAddFinalitySig(f *testing.F) { // Case 0: fail if the committed epoch is not finalized lastFinalizedEpoch := datagen.RandomInt(r, int(committedEpochNum)) o1 := cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).Times(1) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(1)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg) require.ErrorIs(t, err, types.ErrPubRandCommitNotBTCTimestamped) @@ -160,17 +160,17 @@ func FuzzAddFinalitySig(f *testing.F) { cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).After(o1).AnyTimes() // Case 1: fail if the finality provider does not have voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(0)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 0) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg) require.Error(t, err) // mock voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) // Case 2: fail if the finality provider has not committed public randomness at that height blockHeight2 := startHeight + numPubRand + 1 - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight2)).Return(uint64(1)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) msg.BlockHeight = blockHeight2 _, err = ms.AddFinalitySig(ctx, msg) @@ -353,9 +353,7 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: forkHash}) msg1, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, forkHash) require.NoError(t, err) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), - gomock.Eq(fpBTCPKBytes), - gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg1) @@ -364,9 +362,7 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { msg, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, canonicalHash) ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: canonicalHash}) require.NoError(t, err) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), - gomock.Eq(fpBTCPKBytes), - gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) bsKeeper.EXPECT().SlashFinalityProvider(gomock.Any(), @@ -435,7 +431,7 @@ func TestDoNotPanicOnNilProof(t *testing.T) { fKeeper.IndexBlock(ctx) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).AnyTimes() // mock voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) // set the committed epoch finalized for the rest of the cases lastFinalizedEpoch := datagen.GenRandomEpochNum(r) + committedEpochNum cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).AnyTimes() diff --git a/x/finality/keeper/power_dist_change.go b/x/finality/keeper/power_dist_change.go index b07afe0fd..880aaf83a 100644 --- a/x/finality/keeper/power_dist_change.go +++ b/x/finality/keeper/power_dist_change.go @@ -7,7 +7,9 @@ import ( "sort" "cosmossdk.io/collections" + "cosmossdk.io/store/prefix" "github.com/btcsuite/btcd/btcutil" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" bbn "github.com/babylonlabs-io/babylon/types" @@ -24,10 +26,10 @@ func (k Keeper) UpdatePowerDist(ctx context.Context) { btcTipHeight := k.BTCStakingKeeper.GetCurrentBTCHeight(ctx) // get the power dist cache in the last height - dc := k.BTCStakingKeeper.GetVotingPowerDistCache(ctx, height-1) + dc := k.GetVotingPowerDistCache(ctx, height-1) if dc == nil { // no BTC staker at the prior height - dc = types.NewVotingPowerDistCache() + dc = ftypes.NewVotingPowerDistCache() } // get all power distribution update events during the previous tip @@ -58,7 +60,7 @@ func (k Keeper) UpdatePowerDist(ctx context.Context) { // with the following consideration: // 1. the fp must have timestamped pub rand // 2. the fp must in the top x ranked by the voting power (x is given by maxActiveFps) -func (k Keeper) recordVotingPowerAndCache(ctx context.Context, newDc *types.VotingPowerDistCache) { +func (k Keeper) recordVotingPowerAndCache(ctx context.Context, newDc *ftypes.VotingPowerDistCache) { if newDc == nil { panic("the voting power distribution cache cannot be nil") } @@ -83,15 +85,15 @@ func (k Keeper) recordVotingPowerAndCache(ctx context.Context, newDc *types.Voti // set voting power table for each active finality providers at this height for i := uint32(0); i < newDc.NumActiveFps; i++ { fp := newDc.FinalityProviders[i] - k.BTCStakingKeeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.TotalBondedSat) + k.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.TotalBondedSat) } // set the voting power distribution cache of the current height - k.BTCStakingKeeper.SetVotingPowerDistCache(ctx, babylonTipHeight, newDc) + k.SetVotingPowerDistCache(ctx, babylonTipHeight, newDc) } // handleFPStateUpdates emits events and triggers hooks for finality providers with state updates -func (k Keeper) handleFPStateUpdates(ctx context.Context, prevDc, newDc *types.VotingPowerDistCache) { +func (k Keeper) handleFPStateUpdates(ctx context.Context, prevDc, newDc *ftypes.VotingPowerDistCache) { sdkCtx := sdk.UnwrapSDKContext(ctx) newlyActiveFPs := newDc.FindNewActiveFinalityProviders(prevDc) @@ -140,7 +142,7 @@ func (k Keeper) handleActivatedFinalityProvider(ctx context.Context, fpPk *bbn.B return k.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) } -func (k Keeper) recordMetrics(dc *types.VotingPowerDistCache) { +func (k Keeper) recordMetrics(dc *ftypes.VotingPowerDistCache) { // number of active FPs numActiveFPs := int(dc.NumActiveFps) types.RecordActiveFinalityProviders(numActiveFPs) @@ -167,9 +169,9 @@ func (k Keeper) recordMetrics(dc *types.VotingPowerDistCache) { // - newly unjailed finality providers func (k Keeper) ProcessAllPowerDistUpdateEvents( ctx context.Context, - dc *types.VotingPowerDistCache, + dc *ftypes.VotingPowerDistCache, events []*types.EventPowerDistUpdate, -) *types.VotingPowerDistCache { +) *ftypes.VotingPowerDistCache { // a map where key is finality provider's BTC PK hex and value is a list // of BTC delegations that newly become active under this provider activeBTCDels := map[string][]*types.BTCDelegation{} @@ -230,14 +232,14 @@ func (k Keeper) ProcessAllPowerDistUpdateEvents( // sub-optimal. Ideally we only need to iterate over all events above rather // than the entire cache. This is made difficulty since BTC delegations are // not keyed in the cache. Need to find a way to optimise this. - newDc := types.NewVotingPowerDistCache() + newDc := ftypes.NewVotingPowerDistCache() // iterate over all finality providers and apply all events for i := range dc.FinalityProviders { // create a copy of the finality provider fp := *dc.FinalityProviders[i] fp.TotalBondedSat = 0 - fp.BtcDels = []*types.BTCDelDistInfo{} + fp.BtcDels = []*ftypes.BTCDelDistInfo{} fpBTCPKHex := fp.BtcPk.MarshalHex() @@ -308,7 +310,7 @@ func (k Keeper) ProcessAllPowerDistUpdateEvents( if err != nil { panic(err) // only programming error } - fpDistInfo := types.NewFinalityProviderDistInfo(newFP) + fpDistInfo := ftypes.NewFinalityProviderDistInfo(newFP) // add each BTC delegation fpActiveBTCDels := activeBTCDels[fpBTCPKHex] @@ -324,3 +326,33 @@ func (k Keeper) ProcessAllPowerDistUpdateEvents( return newDc } + +func (k Keeper) SetVotingPowerDistCache(ctx context.Context, height uint64, dc *ftypes.VotingPowerDistCache) { + store := k.votingPowerDistCacheStore(ctx) + store.Set(sdk.Uint64ToBigEndian(height), k.cdc.MustMarshal(dc)) +} + +func (k Keeper) GetVotingPowerDistCache(ctx context.Context, height uint64) *ftypes.VotingPowerDistCache { + store := k.votingPowerDistCacheStore(ctx) + rdcBytes := store.Get(sdk.Uint64ToBigEndian(height)) + if len(rdcBytes) == 0 { + return nil + } + var dc ftypes.VotingPowerDistCache + k.cdc.MustUnmarshal(rdcBytes, &dc) + return &dc +} + +func (k Keeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { + store := k.votingPowerDistCacheStore(ctx) + store.Delete(sdk.Uint64ToBigEndian(height)) +} + +// votingPowerDistCacheStore returns the KVStore of the voting power distribution cache +// prefix: VotingPowerDistCacheKey +// key: Babylon block height +// value: VotingPowerDistCache +func (k Keeper) votingPowerDistCacheStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, ftypes.VotingPowerDistCacheKey) +} diff --git a/x/finality/keeper/power_dist_change_test.go b/x/finality/keeper/power_dist_change_test.go index 6420934ed..2617fa54d 100644 --- a/x/finality/keeper/power_dist_change_test.go +++ b/x/finality/keeper/power_dist_change_test.go @@ -13,6 +13,7 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) func FuzzProcessAllPowerDistUpdateEvents_Determinism(f *testing.F) { @@ -41,7 +42,7 @@ func FuzzProcessAllPowerDistUpdateEvents_Determinism(f *testing.F) { } // empty dist cache - dc := types.NewVotingPowerDistCache() + dc := ftypes.NewVotingPowerDistCache() stakingValue := int64(2 * 10e8) @@ -132,7 +133,7 @@ func FuzzSlashFinalityProviderEvent(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() // ensure the finality provider has voting power at this height - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* Slash the finality provider and execute BeginBlock @@ -161,7 +162,7 @@ func FuzzSlashFinalityProviderEvent(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) }) } @@ -222,7 +223,7 @@ func FuzzJailFinalityProviderEvents(f *testing.F) { fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) h.NoError(err) require.False(t, fpBeforeJailing.IsJailed()) - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* Jail the finality provider and execute BeginBlock @@ -253,7 +254,7 @@ func FuzzJailFinalityProviderEvents(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* insert another active BTC delegation and check whether the jailed @@ -291,7 +292,7 @@ func FuzzJailFinalityProviderEvents(f *testing.F) { fpAfterJailing, err = h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) h.NoError(err) require.True(t, fpAfterJailing.IsJailed()) - require.Equal(t, uint64(0), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(0), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) }) } @@ -352,7 +353,7 @@ func FuzzUnjailFinalityProviderEvents(f *testing.F) { fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) h.NoError(err) require.False(t, fpBeforeJailing.IsJailed()) - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // try unjail fp that is not jailed, should expect error err = h.BTCStakingKeeper.UnjailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) @@ -376,7 +377,7 @@ func FuzzUnjailFinalityProviderEvents(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* Unjail the finality provider and execute BeginBlock @@ -396,7 +397,7 @@ func FuzzUnjailFinalityProviderEvents(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() // ensure the finality provider does not have voting power anymore - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) }) } @@ -460,7 +461,7 @@ func FuzzBTCDelegationEvents_NoPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* Generate a quorum number of covenant signatures @@ -482,7 +483,7 @@ func FuzzBTCDelegationEvents_NoPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure this finality provider has voting power at the current height after having timestamped pub rand babylonHeight += 1 @@ -490,7 +491,7 @@ func FuzzBTCDelegationEvents_NoPreApproval(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.CommitPubRandList(r, fpSK, fp, 1, 100, true) h.BeginBlocker() - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure event queue is cleared at BTC tip height events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) @@ -504,7 +505,7 @@ func FuzzBTCDelegationEvents_NoPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: unbondedHeight}).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure the unbonded event is processed and cleared events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) @@ -557,7 +558,7 @@ func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* Generate a quorum number of covenant signatures @@ -573,7 +574,7 @@ func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) /* submit the inclusion proof to activate the BTC delegation @@ -606,7 +607,7 @@ func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure this finality provider has voting power at the current height after having timestamped pub rand babylonHeight += 1 @@ -614,7 +615,7 @@ func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() h.CommitPubRandList(r, fpSK, fp, 1, 100, true) h.BeginBlocker() - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure event queue is cleared at BTC tip height events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) @@ -628,7 +629,7 @@ func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: unbondedHeight}).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) // ensure the unbonded event is processed and cleared events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) @@ -692,7 +693,7 @@ func TestDoNotGenerateDuplicateEventsAfterHavingCovenantQuorum(t *testing.T) { h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() h.BeginBlocker() - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) diff --git a/x/btcstaking/keeper/voting_power_table.go b/x/finality/keeper/power_table.go similarity index 82% rename from x/btcstaking/keeper/voting_power_table.go rename to x/finality/keeper/power_table.go index f7abc715b..0d0101dca 100644 --- a/x/btcstaking/keeper/voting_power_table.go +++ b/x/finality/keeper/power_table.go @@ -8,37 +8,10 @@ import ( "cosmossdk.io/store/prefix" bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -// IterateActiveFPs iterates over all finality providers that are not slashed -func (k Keeper) IterateActiveFPs(ctx context.Context, handler func(fp *types.FinalityProvider) (shouldContinue bool)) { - k.IterateFPs(ctx, func(fp *types.FinalityProvider) (shouldContinue bool) { - if fp.IsSlashed() { - // slashed finality provider is removed from finality provider set - return true - } - - return handler(fp) - }) -} - -// IterateFPs iterates over all finality providers. -func (k Keeper) IterateFPs(ctx context.Context, handler func(fp *types.FinalityProvider) (shouldContinue bool)) { - // filter out all finality providers with positive voting power - fpIter := k.finalityProviderStore(ctx).Iterator(nil, nil) - defer fpIter.Close() - for ; fpIter.Valid(); fpIter.Next() { - var fp types.FinalityProvider - k.cdc.MustUnmarshal(fpIter.Value(), &fp) - shouldContinue := handler(&fp) - if !shouldContinue { - return - } - } -} - func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64, power uint64) { store := k.votingPowerBbnBlockHeightStore(ctx, height) store.Set(fpBTCPK, sdk.Uint64ToBigEndian(power)) @@ -46,9 +19,6 @@ func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint6 // GetVotingPower gets the voting power of a given finality provider at a given Babylon height func (k Keeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 { - if !k.HasFinalityProvider(ctx, fpBTCPK) { - return 0 - } store := k.votingPowerBbnBlockHeightStore(ctx, height) powerBytes := store.Get(fpBTCPK) if len(powerBytes) == 0 { @@ -77,7 +47,7 @@ func (k Keeper) GetCurrentVotingPower(ctx context.Context, fpBTCPK []byte) (uint storeAtHeight := prefix.NewStore(store, sdk.Uint64ToBigEndian(lastHeight)) // if the finality provider is not known, return 0 voting power - if !k.HasFinalityProvider(ctx, fpBTCPK) { + if !k.BTCStakingKeeper.HasFinalityProvider(ctx, fpBTCPK) { return lastHeight, 0 } diff --git a/x/finality/keeper/power_table_test.go b/x/finality/keeper/power_table_test.go index 6d1799a58..b3c0fe70f 100644 --- a/x/finality/keeper/power_table_test.go +++ b/x/finality/keeper/power_table_test.go @@ -12,8 +12,159 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) +func FuzzVotingPowerTable(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + h.NoError(err) + + // generate a random batch of finality providers, and commit pub rand list with timestamp + fps := []*types.FinalityProvider{} + numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 + numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + for i := uint64(0); i < numFps; i++ { + fpSK, _, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + fps = append(fps, fp) + } + + // for the first numFpsWithVotingPower finality providers, generate a random number of BTC delegations + numBTCDels := datagen.RandomInt(r, 10) + 1 + stakingValue := datagen.RandomInt(r, 100000) + 100000 + for i := uint64(0); i < numFpsWithVotingPower; i++ { + for j := uint64(0); j < numBTCDels; j++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + fps[i].BtcPk.MustToBTCPK(), + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, + 0, + 0, + true, + ) + h.NoError(err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + } + } + + /* + assert the first numFpsWithVotingPower finality providers have voting power + */ + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) + err = h.FinalityKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) + + for i := uint64(0); i < numFpsWithVotingPower; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + require.Equal(t, numBTCDels*stakingValue, power) + } + for i := numFpsWithVotingPower; i < numFps; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + require.Zero(t, power) + } + + // also, get voting power table and assert consistency + powerTable := h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + require.NotNil(t, powerTable) + for i := uint64(0); i < numFpsWithVotingPower; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + require.Equal(t, powerTable[fps[i].BtcPk.MarshalHex()], power) + } + // the activation height should be the current Babylon height as well + activatedHeight, err := h.FinalityKeeper.GetBTCStakingActivatedHeight(h.Ctx) + require.NoError(t, err) + require.Equal(t, babylonHeight, activatedHeight) + + /* + slash a random finality provider and move on + then assert the slashed finality provider does not have voting power + */ + // move to next Babylon height + h.BTCLightClientKeeper = btclcKeeper + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + // slash a random finality provider + slashedIdx := datagen.RandomInt(r, int(numFpsWithVotingPower)) + slashedFp := fps[slashedIdx] + err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, slashedFp.BtcPk.MustMarshal()) + require.NoError(t, err) + // index height and record power table + err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) + err = h.FinalityKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) + + // check if the slashed finality provider's voting power becomes zero + for i := uint64(0); i < numFpsWithVotingPower; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + if i == slashedIdx { + require.Zero(t, power) + } else { + require.Equal(t, numBTCDels*stakingValue, power) + } + } + for i := numFpsWithVotingPower; i < numFps; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + require.Zero(t, power) + } + + // also, get voting power table and assert consistency + powerTable = h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + require.NotNil(t, powerTable) + for i := uint64(0); i < numFpsWithVotingPower; i++ { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + if i == slashedIdx { + require.Zero(t, power) + } + require.Equal(t, powerTable[fps[i].BtcPk.MarshalHex()], power) + } + + /* + move to 999th BTC block, then assert none of finality providers has voting power (since end height - w < BTC height) + */ + // replace the old mocked keeper + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 999}).AnyTimes() + err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) + + for _, fp := range fps { + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight) + require.Zero(t, power) + } + + // the activation height should be same as before + activatedHeight2, err := h.FinalityKeeper.GetBTCStakingActivatedHeight(h.Ctx) + require.NoError(t, err) + require.Equal(t, activatedHeight, activatedHeight2) + }) +} func FuzzRecordVotingPowerDistCache(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -78,7 +229,7 @@ func FuzzRecordVotingPowerDistCache(f *testing.F) { h.BeginBlocker() // assert voting power distribution cache is correct - dc := h.BTCStakingKeeper.GetVotingPowerDistCache(h.Ctx, babylonHeight) + dc := h.FinalityKeeper.GetVotingPowerDistCache(h.Ctx, babylonHeight) require.NotNil(t, dc) require.Equal(t, dc.TotalBondedSat, numFpsWithVotingPower*numBTCDels*stakingValue, dc.String()) activeFPs := dc.GetActiveFinalityProviderSet() @@ -114,7 +265,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { h.NoError(err) // generate a random batch of finality providers, each with a BTC delegation with random power - fpsWithMeta := []*types.FinalityProviderDistInfo{} + fpsWithMeta := []*ftypes.FinalityProviderDistInfo{} numFps := datagen.RandomInt(r, 300) + 1 noTimestampedFps := map[string]bool{} for i := uint64(0); i < numFps; i++ { @@ -142,7 +293,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // 30 percent not have timestamped randomness, which causes // zero voting power in the table - fpDistInfo := &types.FinalityProviderDistInfo{BtcPk: fp.BtcPk, TotalBondedSat: stakingValue} + fpDistInfo := &ftypes.FinalityProviderDistInfo{BtcPk: fp.BtcPk, TotalBondedSat: stakingValue} if r.Intn(10) <= 2 { h.CommitPubRandList(r, fpSK, fp, 1, 100, false) noTimestampedFps[fp.BtcPk.MarshalHex()] = true @@ -158,7 +309,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { maxActiveFpsParam := h.FinalityKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders // get a map of expected active finality providers - types.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta) + ftypes.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta) expectedActiveFps := fpsWithMeta[:min(uint32(len(fpsWithMeta)-len(noTimestampedFps)), maxActiveFpsParam)] expectedActiveFpsMap := map[string]uint64{} for _, fp := range expectedActiveFps { @@ -173,7 +324,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // only finality providers in expectedActiveFpsMap have voting power for _, fp := range fpsWithMeta { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, fp.BtcPk.MustMarshal(), babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, fp.BtcPk.MustMarshal(), babylonHeight) if expectedPower, ok := expectedActiveFpsMap[fp.BtcPk.MarshalHex()]; ok { require.Equal(t, expectedPower, power) } else { @@ -183,7 +334,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // also, get voting power table and assert there is // min(len(expectedActiveFps), MaxActiveFinalityProviders) active finality providers - powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + powerTable := h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) expectedNumActiveFps := len(expectedActiveFpsMap) if expectedNumActiveFps > int(maxActiveFpsParam) { expectedNumActiveFps = int(maxActiveFpsParam) @@ -274,11 +425,11 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { return fpsWithMeta[i].VotingPower > fpsWithMeta[j].VotingPower }) for i := 0; i < numActiveFPs; i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) } for i := numActiveFPs; i < int(numFps); i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Zero(t, votingPower) } @@ -364,11 +515,11 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { return fpsWithMeta[i].VotingPower > fpsWithMeta[j].VotingPower }) for i := 0; i < numActiveFPs; i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) } for i := numActiveFPs; i < int(numFps); i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Zero(t, votingPower) } }) diff --git a/x/finality/keeper/tallying.go b/x/finality/keeper/tallying.go index e9de293aa..53051d29d 100644 --- a/x/finality/keeper/tallying.go +++ b/x/finality/keeper/tallying.go @@ -19,7 +19,7 @@ import ( // but without block that has finality providers set AND does not receive QC func (k Keeper) TallyBlocks(ctx context.Context) { sdkCtx := sdk.UnwrapSDKContext(ctx) - activatedHeight, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx) + activatedHeight, err := k.GetBTCStakingActivatedHeight(ctx) if err != nil { // invoking TallyBlocks when BTC staking protocol is not activated is a programming error panic(fmt.Errorf("cannot tally a block when the BTC staking protocol hasn't been activated yet, current height: %v, activated height: %v", @@ -46,7 +46,7 @@ func (k Keeper) TallyBlocks(ctx context.Context) { } // get the finality provider set of this block - fpSet := k.BTCStakingKeeper.GetVotingPowerTable(ctx, ib.Height) + fpSet := k.GetVotingPowerTable(ctx, ib.Height) if fpSet != nil && !ib.Finalized { // has finality providers, non-finalised: tally and try to finalise the block @@ -84,7 +84,7 @@ func (k Keeper) finalizeBlock(ctx context.Context, block *types.IndexedBlock, vo // set next height to finalise as height+1 k.setNextHeightToFinalize(ctx, block.Height+1) // distribute rewards to BTC staking stakeholders w.r.t. the voting power distribution cache - dc := k.BTCStakingKeeper.GetVotingPowerDistCache(ctx, block.Height) + dc := k.GetVotingPowerDistCache(ctx, block.Height) if dc == nil { // failing to get a voting power distribution cache before distributing reward is a programming error panic(fmt.Errorf("voting power distribution cache not found at height %d", block.Height)) @@ -94,7 +94,7 @@ func (k Keeper) finalizeBlock(ctx context.Context, block *types.IndexedBlock, vo // reward voted finality providers k.IncentiveKeeper.RewardBTCStaking(ctx, block.Height, filteredDc) // remove reward distribution cache afterwards - k.BTCStakingKeeper.RemoveVotingPowerDistCache(ctx, block.Height) + k.RemoveVotingPowerDistCache(ctx, block.Height) // record the last finalized height metric types.RecordLastFinalizedHeight(block.Height) } diff --git a/x/finality/keeper/tallying_bench_test.go b/x/finality/keeper/tallying_bench_test.go index 12a9261d5..9e1d5f998 100644 --- a/x/finality/keeper/tallying_bench_test.go +++ b/x/finality/keeper/tallying_bench_test.go @@ -14,7 +14,6 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/types" ) @@ -32,7 +31,6 @@ func benchmarkTallyBlocks(b *testing.B, numFPs int) { activatedHeight := uint64(1) // add mock queries to GetBTCStakingActivatedHeight ctx = datagen.WithCtxHeight(ctx, uint64(activatedHeight)) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).AnyTimes() // simulate fp set fpSet := map[string]uint64{} @@ -40,13 +38,11 @@ func benchmarkTallyBlocks(b *testing.B, numFPs int) { votedFpPK, err := datagen.GenRandomBIP340PubKey(r) require.NoError(b, err) fpSet[votedFpPK.MarshalHex()] = 1 + fKeeper.SetVotingPower(ctx, []byte(votedFpPK.MarshalHex()), activatedHeight, 1) } - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Any()).Return(fpSet).AnyTimes() // TODO: test incentive - bsKeeper.EXPECT().GetVotingPowerDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewVotingPowerDistCache()).AnyTimes() iKeeper.EXPECT().RewardBTCStaking(gomock.Any(), gomock.Any(), gomock.Any()).Return().AnyTimes() - bsKeeper.EXPECT().RemoveVotingPowerDistCache(gomock.Any(), gomock.Any()).Return().AnyTimes() // Start the CPU profiler cpuProfileFile := fmt.Sprintf("/tmp/finality-tally-blocks-%d-cpu.pprof", numFPs) f, err := os.Create(cpuProfileFile) diff --git a/x/finality/keeper/tallying_test.go b/x/finality/keeper/tallying_test.go index 7a4ca3f78..24b4c13e3 100644 --- a/x/finality/keeper/tallying_test.go +++ b/x/finality/keeper/tallying_test.go @@ -1,7 +1,6 @@ package keeper_test import ( - "encoding/hex" "math/rand" "testing" @@ -12,42 +11,10 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/keeper" "github.com/babylonlabs-io/babylon/x/finality/types" ) -func FuzzTallying_PanicCases(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - bsKeeper := types.NewMockBTCStakingKeeper(ctrl) - iKeeper := types.NewMockIncentiveKeeper(ctrl) - cKeeper := types.NewMockCheckpointingKeeper(ctrl) - fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) - - // Case 1: expect to panic if tallying upon BTC staking protocol is not activated - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(uint64(0), bstypes.ErrBTCStakingNotActivated).Times(1) - require.Panics(t, func() { fKeeper.TallyBlocks(ctx) }) - - // Case 2: expect to panic if finalised block with nil finality provider - fKeeper.SetBlock(ctx, &types.IndexedBlock{ - Height: 1, - AppHash: datagen.GenRandomByteArray(r, 32), - Finalized: true, - }) - // activate BTC staking protocol at height 1 - ctx = datagen.WithCtxHeight(ctx, 1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(uint64(1), nil).Times(1) - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(uint64(1))).Return(nil).Times(1) - require.Panics(t, func() { fKeeper.TallyBlocks(ctx) }) - }) -} - func FuzzTallying_FinalizingNoBlock(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -74,13 +41,13 @@ func FuzzTallying_FinalizingNoBlock(f *testing.F) { Finalized: false, }) // this block does not have QC - err := giveNoQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveNoQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } - // add mock queries to GetBTCStakingActivatedHeight - ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).Times(1) + // mock activated height + fKeeper.SetVotingPower(ctx, datagen.GenRandomByteArray(r, 32), activatedHeight, 1) // tally blocks and none of them should be finalised + ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) fKeeper.TallyBlocks(ctx) for i := activatedHeight; i < activatedHeight+10; i++ { ib, err := fKeeper.GetBlock(ctx, i) @@ -119,22 +86,18 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { }) if i < activatedHeight+numWithQCs { // this block has QC - err := giveQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } else { // this block does not have QC - err := giveNoQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveNoQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } } // we don't test incentive in this function - bsKeeper.EXPECT().GetVotingPowerDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewVotingPowerDistCache()).Times(int(numWithQCs)) iKeeper.EXPECT().RewardBTCStaking(gomock.Any(), gomock.Any(), gomock.Any()).Return().Times(int(numWithQCs)) - bsKeeper.EXPECT().RemoveVotingPowerDistCache(gomock.Any(), gomock.Any()).Return().Times(int(numWithQCs)) - // add mock queries to GetBTCStakingActivatedHeight - ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).Times(1) // tally blocks and none of them should be finalised + ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) fKeeper.TallyBlocks(ctx) for i := activatedHeight; i < activatedHeight+10; i++ { ib, err := fKeeper.GetBlock(ctx, i) @@ -149,49 +112,62 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { } -func giveQCToHeight(r *rand.Rand, ctx sdk.Context, bsKeeper *types.MockBTCStakingKeeper, fKeeper *keeper.Keeper, height uint64) error { - // 4 finality providers - fpSet := map[string]uint64{} +func giveQCToHeight(r *rand.Rand, ctx sdk.Context, fKeeper *keeper.Keeper, height uint64) error { + dc := types.NewVotingPowerDistCache() // 3 votes for i := 0; i < 3; i++ { votedFpPK, err := datagen.GenRandomBIP340PubKey(r) if err != nil { return err } + fKeeper.SetVotingPower(ctx, votedFpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: votedFpPK, + TotalBondedSat: 1, + }) votedSig, err := bbn.NewSchnorrEOTSSig(datagen.GenRandomByteArray(r, 32)) if err != nil { return err } fKeeper.SetSig(ctx, height, votedFpPK, votedSig) - // add finality provider - fpSet[votedFpPK.MarshalHex()] = 1 } // the rest of the finality providers do not vote - fpSet[hex.EncodeToString(datagen.GenRandomByteArray(r, 32))] = 1 - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(height)).Return(fpSet).Times(1) - + fKeeper.SetVotingPower(ctx, datagen.GenRandomByteArray(r, 32), height, 1) + fKeeper.SetVotingPowerDistCache(ctx, height, dc) return nil } -func giveNoQCToHeight(r *rand.Rand, ctx sdk.Context, bsKeeper *types.MockBTCStakingKeeper, fKeeper *keeper.Keeper, height uint64) error { +func giveNoQCToHeight(r *rand.Rand, ctx sdk.Context, fKeeper *keeper.Keeper, height uint64) error { + dc := types.NewVotingPowerDistCache() // 1 vote votedFpPK, err := datagen.GenRandomBIP340PubKey(r) if err != nil { return err } + fKeeper.SetVotingPower(ctx, votedFpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: votedFpPK, + TotalBondedSat: 1, + }) votedSig, err := bbn.NewSchnorrEOTSSig(datagen.GenRandomByteArray(r, 32)) if err != nil { return err } fKeeper.SetSig(ctx, height, votedFpPK, votedSig) - // 4 finality providers - fpSet := map[string]uint64{ - votedFpPK.MarshalHex(): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, + + // the other 3 finality providers + for i := 0; i < 3; i++ { + fpPK, err := datagen.GenRandomBIP340PubKey(r) + if err != nil { + return err + } + fKeeper.SetVotingPower(ctx, fpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: fpPK, + TotalBondedSat: 1, + }) } - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(height)).Return(fpSet).MaxTimes(1) + fKeeper.SetVotingPowerDistCache(ctx, height, dc) return nil } diff --git a/x/finality/keeper/votes_bench_test.go b/x/finality/keeper/votes_bench_test.go index 3a0f97faa..23666daf3 100644 --- a/x/finality/keeper/votes_bench_test.go +++ b/x/finality/keeper/votes_bench_test.go @@ -39,8 +39,6 @@ func benchmarkAddFinalitySig(b *testing.B) { // register the finality provider bsKeeper.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(true).AnyTimes() bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).AnyTimes() - // mock voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Any()).Return(uint64(1)).AnyTimes() // commit enough public randomness // TODO: generalise commit public randomness to allow arbitrary benchtime diff --git a/x/finality/types/errors.go b/x/finality/types/errors.go index 8ae4bcdd2..1b026b6dc 100644 --- a/x/finality/types/errors.go +++ b/x/finality/types/errors.go @@ -19,5 +19,7 @@ var ( ErrNoSlashableEvidence = errorsmod.Register(ModuleName, 1110, "there is no slashable evidence") ErrPubRandCommitNotBTCTimestamped = errorsmod.Register(ModuleName, 1111, "the public randomness commit is not BTC timestamped yet") ErrJailingPeriodNotPassed = errorsmod.Register(ModuleName, 1112, "the jailing period is not passed") - ErrFinalityNotActivated = errorsmod.Register(ModuleName, 1113, "finality is not active yet") + ErrVotingPowerTableNotUpdated = errorsmod.Register(ModuleName, 1113, "voting power table has not been updated") + ErrBTCStakingNotActivated = errorsmod.Register(ModuleName, 1114, "the BTC staking protocol is not activated yet") + ErrFinalityNotActivated = errorsmod.Register(ModuleName, 1115, "finality is not active yet") ) diff --git a/x/finality/types/expected_keepers.go b/x/finality/types/expected_keepers.go index 97941ec88..eac488a83 100644 --- a/x/finality/types/expected_keepers.go +++ b/x/finality/types/expected_keepers.go @@ -16,15 +16,8 @@ type BTCStakingKeeper interface { HasFinalityProvider(ctx context.Context, fpBTCPK []byte) bool SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*bstypes.BTCDelegation, error) - GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 - GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 - SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64, votingPower uint64) - GetBTCStakingActivatedHeight(ctx context.Context) (uint64, error) - GetVotingPowerDistCache(ctx context.Context, height uint64) *bstypes.VotingPowerDistCache - SetVotingPowerDistCache(ctx context.Context, height uint64, dc *bstypes.VotingPowerDistCache) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTipHeight, btcTipHeight uint32) []*bstypes.EventPowerDistUpdate ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint32) - RemoveVotingPowerDistCache(ctx context.Context, height uint64) JailFinalityProvider(ctx context.Context, fpBTCPK []byte) error UnjailFinalityProvider(ctx context.Context, fpBTCPK []byte) error } @@ -37,6 +30,6 @@ type CheckpointingKeeper interface { // IncentiveKeeper defines the expected interface needed for distributing rewards // and refund transaction fee for finality signatures type IncentiveKeeper interface { - RewardBTCStaking(ctx context.Context, height uint64, filteredDc *bstypes.VotingPowerDistCache) + RewardBTCStaking(ctx context.Context, height uint64, filteredDc *VotingPowerDistCache) IndexRefundableMsg(ctx context.Context, msg sdk.Msg) } diff --git a/x/finality/types/finality.pb.go b/x/finality/types/finality.pb.go index 93c60cba2..67590f46f 100644 --- a/x/finality/types/finality.pb.go +++ b/x/finality/types/finality.pb.go @@ -4,8 +4,10 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -29,6 +31,219 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +type VotingPowerDistCache struct { + // total_sat is the total amount of bonded BTC stake (in Satoshi) of all the finality providers + // in the cache + TotalBondedSat uint64 `protobuf:"varint,1,opt,name=total_bonded_sat,json=totalBondedSat,proto3" json:"total_bonded_sat,omitempty"` + // finality_providers is a list of finality providers' voting power information + FinalityProviders []*FinalityProviderDistInfo `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` + // num_active_fps is the number of finality providers that have active BTC + // delegations as well as timestamped public randomness + NumActiveFps uint32 `protobuf:"varint,3,opt,name=num_active_fps,json=numActiveFps,proto3" json:"num_active_fps,omitempty"` +} + +func (m *VotingPowerDistCache) Reset() { *m = VotingPowerDistCache{} } +func (m *VotingPowerDistCache) String() string { return proto.CompactTextString(m) } +func (*VotingPowerDistCache) ProtoMessage() {} +func (*VotingPowerDistCache) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{0} +} +func (m *VotingPowerDistCache) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerDistCache.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 *VotingPowerDistCache) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerDistCache.Merge(m, src) +} +func (m *VotingPowerDistCache) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerDistCache) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerDistCache.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerDistCache proto.InternalMessageInfo + +// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations +type FinalityProviderDistInfo struct { + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // addr is the address to receive commission from delegations. + Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` + // commission defines the commission rate of finality provider + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` + // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider + TotalBondedSat uint64 `protobuf:"varint,4,opt,name=total_bonded_sat,json=totalBondedSat,proto3" json:"total_bonded_sat,omitempty"` + // btc_dels is a list of BTC delegations' voting power information under this finality provider + BtcDels []*BTCDelDistInfo `protobuf:"bytes,5,rep,name=btc_dels,json=btcDels,proto3" json:"btc_dels,omitempty"` + // is_timestamped indicates whether the finality provider + // has timestamped public randomness committed + // if no, it should not be assigned voting power + IsTimestamped bool `protobuf:"varint,6,opt,name=is_timestamped,json=isTimestamped,proto3" json:"is_timestamped,omitempty"` + // is_jailed indicates whether the finality provider + // is jailed, if so, it should not be assigned voting power + IsJailed bool `protobuf:"varint,7,opt,name=is_jailed,json=isJailed,proto3" json:"is_jailed,omitempty"` + // is_slashed indicates whether the finality provider + // is slashed, if so, it should not be assigned voting power + IsSlashed bool `protobuf:"varint,8,opt,name=is_slashed,json=isSlashed,proto3" json:"is_slashed,omitempty"` +} + +func (m *FinalityProviderDistInfo) Reset() { *m = FinalityProviderDistInfo{} } +func (m *FinalityProviderDistInfo) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderDistInfo) ProtoMessage() {} +func (*FinalityProviderDistInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{1} +} +func (m *FinalityProviderDistInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalityProviderDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalityProviderDistInfo.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 *FinalityProviderDistInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderDistInfo.Merge(m, src) +} +func (m *FinalityProviderDistInfo) XXX_Size() int { + return m.Size() +} +func (m *FinalityProviderDistInfo) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderDistInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalityProviderDistInfo proto.InternalMessageInfo + +func (m *FinalityProviderDistInfo) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *FinalityProviderDistInfo) GetTotalBondedSat() uint64 { + if m != nil { + return m.TotalBondedSat + } + return 0 +} + +func (m *FinalityProviderDistInfo) GetBtcDels() []*BTCDelDistInfo { + if m != nil { + return m.BtcDels + } + return nil +} + +func (m *FinalityProviderDistInfo) GetIsTimestamped() bool { + if m != nil { + return m.IsTimestamped + } + return false +} + +func (m *FinalityProviderDistInfo) GetIsJailed() bool { + if m != nil { + return m.IsJailed + } + return false +} + +func (m *FinalityProviderDistInfo) GetIsSlashed() bool { + if m != nil { + return m.IsSlashed + } + return false +} + +// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation +type BTCDelDistInfo struct { + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // staker_addr is the address to receive rewards from BTC delegation. + StakerAddr string `protobuf:"bytes,2,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` + // staking_tx_hash is the staking tx hash of the BTC delegation + StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation + TotalSat uint64 `protobuf:"varint,4,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` +} + +func (m *BTCDelDistInfo) Reset() { *m = BTCDelDistInfo{} } +func (m *BTCDelDistInfo) String() string { return proto.CompactTextString(m) } +func (*BTCDelDistInfo) ProtoMessage() {} +func (*BTCDelDistInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{2} +} +func (m *BTCDelDistInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCDelDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCDelDistInfo.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 *BTCDelDistInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelDistInfo.Merge(m, src) +} +func (m *BTCDelDistInfo) XXX_Size() int { + return m.Size() +} +func (m *BTCDelDistInfo) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelDistInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCDelDistInfo proto.InternalMessageInfo + +func (m *BTCDelDistInfo) GetStakerAddr() string { + if m != nil { + return m.StakerAddr + } + return "" +} + +func (m *BTCDelDistInfo) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *BTCDelDistInfo) GetTotalSat() uint64 { + if m != nil { + return m.TotalSat + } + return 0 +} + // IndexedBlock is the necessary metadata and finalization status of a block type IndexedBlock struct { // height is the height of the block @@ -44,7 +259,7 @@ func (m *IndexedBlock) Reset() { *m = IndexedBlock{} } func (m *IndexedBlock) String() string { return proto.CompactTextString(m) } func (*IndexedBlock) ProtoMessage() {} func (*IndexedBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{0} + return fileDescriptor_ca5b87e52e3e6d02, []int{3} } func (m *IndexedBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,7 +328,7 @@ func (m *PubRandCommit) Reset() { *m = PubRandCommit{} } func (m *PubRandCommit) String() string { return proto.CompactTextString(m) } func (*PubRandCommit) ProtoMessage() {} func (*PubRandCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{1} + return fileDescriptor_ca5b87e52e3e6d02, []int{4} } func (m *PubRandCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,7 +412,7 @@ func (m *Evidence) Reset() { *m = Evidence{} } func (m *Evidence) String() string { return proto.CompactTextString(m) } func (*Evidence) ProtoMessage() {} func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{2} + return fileDescriptor_ca5b87e52e3e6d02, []int{5} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -265,7 +480,7 @@ func (m *FinalityProviderSigningInfo) Reset() { *m = FinalityProviderSig func (m *FinalityProviderSigningInfo) String() string { return proto.CompactTextString(m) } func (*FinalityProviderSigningInfo) ProtoMessage() {} func (*FinalityProviderSigningInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{3} + return fileDescriptor_ca5b87e52e3e6d02, []int{6} } func (m *FinalityProviderSigningInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -316,6 +531,9 @@ func (m *FinalityProviderSigningInfo) GetJailedUntil() time.Time { } func init() { + proto.RegisterType((*VotingPowerDistCache)(nil), "babylon.finality.v1.VotingPowerDistCache") + proto.RegisterType((*FinalityProviderDistInfo)(nil), "babylon.finality.v1.FinalityProviderDistInfo") + proto.RegisterType((*BTCDelDistInfo)(nil), "babylon.finality.v1.BTCDelDistInfo") proto.RegisterType((*IndexedBlock)(nil), "babylon.finality.v1.IndexedBlock") proto.RegisterType((*PubRandCommit)(nil), "babylon.finality.v1.PubRandCommit") proto.RegisterType((*Evidence)(nil), "babylon.finality.v1.Evidence") @@ -327,48 +545,274 @@ func init() { } var fileDescriptor_ca5b87e52e3e6d02 = []byte{ - // 646 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0x8e, 0xdb, 0xfc, 0x9a, 0x74, 0xe3, 0xea, 0x47, 0xdd, 0x52, 0x85, 0x16, 0x39, 0x21, 0xa7, - 0x0a, 0x81, 0x4d, 0xff, 0x08, 0x21, 0x6e, 0xb8, 0x2a, 0x6a, 0x45, 0x05, 0x91, 0xd3, 0x5e, 0xb8, - 0xac, 0xd6, 0xf6, 0xda, 0x5e, 0x62, 0xef, 0xae, 0xec, 0x75, 0xd5, 0xf0, 0x00, 0x9c, 0xcb, 0x8d, - 0x47, 0xe0, 0xc8, 0x63, 0xf4, 0xd8, 0x23, 0xea, 0xa1, 0xa0, 0xe6, 0xc0, 0x6b, 0x20, 0xaf, 0xed, - 0xa4, 0x39, 0x81, 0x40, 0x5c, 0x2c, 0xef, 0x37, 0xb3, 0xf3, 0xcd, 0x37, 0x33, 0x3b, 0xa0, 0xe7, - 0x20, 0x67, 0x14, 0x31, 0x6a, 0xfa, 0x84, 0xa2, 0x88, 0x88, 0x91, 0x79, 0xba, 0x35, 0xf9, 0x37, - 0x78, 0xc2, 0x04, 0xd3, 0x56, 0x4a, 0x1f, 0x63, 0x82, 0x9f, 0x6e, 0xad, 0xaf, 0x06, 0x2c, 0x60, - 0xd2, 0x6e, 0xe6, 0x7f, 0x85, 0xeb, 0xfa, 0x32, 0x8a, 0x09, 0x65, 0xa6, 0xfc, 0x96, 0x50, 0x27, - 0x60, 0x2c, 0x88, 0xb0, 0x29, 0x4f, 0x4e, 0xe6, 0x9b, 0x82, 0xc4, 0x38, 0x15, 0x28, 0xe6, 0x85, - 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xca, 0x89, - 0x49, 0xa1, 0xcb, 0x32, 0x2a, 0x70, 0x22, 0x07, 0x65, 0xde, 0x5e, 0x29, 0x8c, 0xf2, 0xc9, 0xa6, - 0x7b, 0x85, 0x49, 0x3b, 0x02, 0xea, 0x3b, 0x44, 0x22, 0xec, 0xc1, 0x8c, 0x0a, 0x12, 0xc9, 0x96, - 0xb7, 0xb6, 0xd7, 0x8d, 0x62, 0x05, 0x18, 0xd5, 0x0a, 0x30, 0x8e, 0xab, 0x15, 0x60, 0x2d, 0x5d, - 0x5c, 0x77, 0x6a, 0xe7, 0xdf, 0x3a, 0xca, 0xe7, 0x1f, 0x5f, 0x1e, 0x2a, 0x76, 0xab, 0xb8, 0x7e, - 0x92, 0xdf, 0xb6, 0x8e, 0x2e, 0x6e, 0x74, 0xe5, 0xf2, 0x46, 0x57, 0xbe, 0xdf, 0xe8, 0xca, 0xf9, - 0x58, 0xaf, 0x5d, 0x8e, 0xf5, 0xda, 0xd7, 0xb1, 0x5e, 0x7b, 0xbb, 0xfd, 0x6b, 0xf5, 0x67, 0xd3, - 0x8d, 0x26, 0x0b, 0xe1, 0x2c, 0x48, 0xf6, 0x9d, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xae, - 0x27, 0x1f, 0xf2, 0x04, 0x00, 0x00, + // 1008 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x26, 0x4e, 0x6c, 0x8f, 0xed, 0xb4, 0x99, 0x86, 0x6a, 0x9b, 0x80, 0xed, 0x9a, 0x1f, + 0xb2, 0x50, 0xb3, 0xa6, 0x69, 0x85, 0xa0, 0x07, 0xa4, 0x6c, 0xd2, 0xaa, 0x81, 0x40, 0xad, 0xb5, + 0xcb, 0x01, 0x21, 0x8d, 0x66, 0x77, 0xc7, 0xbb, 0x83, 0x77, 0x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d4, 0xf3, 0xa7, + 0x53, 0x95, 0xaf, 0xe0, 0x35, 0x50, 0xc1, 0x51, 0x94, 0xb1, 0xa4, 0x45, 0xd6, 0xad, 0x32, 0x8e, + 0x22, 0x95, 0xff, 0x75, 0x50, 0xcd, 0x0c, 0xfb, 0x86, 0xb8, 0xaa, 0x82, 0x8a, 0x35, 0x03, 0x3a, + 0xdf, 0x6b, 0xa0, 0xd1, 0x4f, 0x6c, 0x0b, 0x33, 0x77, 0x37, 0xed, 0x13, 0x09, 0xaf, 0x83, 0xba, + 0x90, 0x38, 0x96, 0x68, 0x8e, 0xa8, 0xa6, 0xb0, 0xfb, 0x19, 0x5b, 0x1b, 0xa4, 0x73, 0x84, 0xa2, + 0xc4, 0x46, 0x31, 0x66, 0xae, 0x62, 0x2c, 0x59, 0x80, 0x25, 0x61, 0x9e, 0x0a, 0x36, 0xf3, 0xbe, + 0x95, 0x21, 0x61, 0x52, 0xb1, 0xd6, 0xad, 0x73, 0x48, 0x2a, 0x9a, 0x44, 0xdc, 0xf1, 0x11, 0x4b, + 0xc2, 0xa9, 0x68, 0x05, 0x7c, 0x96, 0x84, 0x9d, 0x6f, 0x4b, 0xa0, 0x72, 0x37, 0x1d, 0x43, 0xe6, + 0x10, 0x38, 0x04, 0xd5, 0x51, 0x84, 0x5e, 0x92, 0xab, 0xe5, 0x51, 0x64, 0x2a, 0x5f, 0xaf, 0x83, + 0xba, 0x9d, 0x1e, 0xe8, 0x54, 0x64, 0xa6, 0xa0, 0xa6, 0xb0, 0x5c, 0xe4, 0x43, 0x50, 0x29, 0x04, + 0x2a, 0x01, 0xe6, 0x9d, 0xe3, 0x93, 0xd6, 0xfb, 0x2f, 0xca, 0x3b, 0x70, 0x7c, 0xc6, 0xe3, 0x38, + 0x3f, 0x10, 0xab, 0x1c, 0xe5, 0x27, 0x73, 0x03, 0x40, 0x07, 0x33, 0xce, 0xa8, 0x83, 0x03, 0x54, + 0x78, 0x56, 0x52, 0x27, 0x74, 0xb9, 0x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xe1, 0xe9, 0x59, 0x73, 0xe1, 0xb7, + 0xb3, 0xe6, 0xc2, 0x17, 0xdb, 0xff, 0xae, 0xfe, 0x68, 0xf6, 0xaf, 0x42, 0x1d, 0x84, 0xbd, 0xa2, + 0xd8, 0x6f, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x98, 0xec, 0xc2, 0x24, 0x76, 0x08, 0x00, 0x00, +} + +func (m *VotingPowerDistCache) 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 *VotingPowerDistCache) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumActiveFps != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.NumActiveFps)) + i-- + dAtA[i] = 0x18 + } + if len(m.FinalityProviders) > 0 { + for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.TotalBondedSat != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalBondedSat)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *FinalityProviderDistInfo) 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 *FinalityProviderDistInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalityProviderDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSlashed { + i-- + if m.IsSlashed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.IsJailed { + i-- + if m.IsJailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.IsTimestamped { + i-- + if m.IsTimestamped { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if len(m.BtcDels) > 0 { + for iNdEx := len(m.BtcDels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcDels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.TotalBondedSat != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalBondedSat)) + i-- + dAtA[i] = 0x20 + } + if m.Commission != nil { + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintFinality(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0x12 + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BTCDelDistInfo) 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 *BTCDelDistInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCDelDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalSat != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalSat)) + i-- + dAtA[i] = 0x20 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintFinality(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintFinality(dAtA, i, uint64(len(m.StakerAddr))) + i-- + dAtA[i] = 0x12 + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *IndexedBlock) Marshal() (dAtA []byte, err error) { @@ -615,18 +1059,102 @@ func encodeVarintFinality(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *IndexedBlock) Size() (n int) { +func (m *VotingPowerDistCache) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Height != 0 { - n += 1 + sovFinality(uint64(m.Height)) + if m.TotalBondedSat != 0 { + n += 1 + sovFinality(uint64(m.TotalBondedSat)) } - l = len(m.AppHash) - if l > 0 { - n += 1 + l + sovFinality(uint64(l)) + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovFinality(uint64(l)) + } + } + if m.NumActiveFps != 0 { + n += 1 + sovFinality(uint64(m.NumActiveFps)) + } + return n +} + +func (m *FinalityProviderDistInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + if m.Commission != nil { + l = m.Commission.Size() + n += 1 + l + sovFinality(uint64(l)) + } + if m.TotalBondedSat != 0 { + n += 1 + sovFinality(uint64(m.TotalBondedSat)) + } + if len(m.BtcDels) > 0 { + for _, e := range m.BtcDels { + l = e.Size() + n += 1 + l + sovFinality(uint64(l)) + } + } + if m.IsTimestamped { + n += 2 + } + if m.IsJailed { + n += 2 + } + if m.IsSlashed { + n += 2 + } + return n +} + +func (m *BTCDelDistInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.StakerAddr) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + if m.TotalSat != 0 { + n += 1 + sovFinality(uint64(m.TotalSat)) + } + return n +} + +func (m *IndexedBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovFinality(uint64(m.Height)) + } + l = len(m.AppHash) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) } if m.Finalized { n += 2 @@ -719,6 +1247,562 @@ func sovFinality(x uint64) (n int) { func sozFinality(x uint64) (n int) { return sovFinality(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *VotingPowerDistCache) 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 ErrIntOverflowFinality + } + 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: VotingPowerDistCache: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerDistCache: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBondedSat", wireType) + } + m.TotalBondedSat = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBondedSat |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderDistInfo{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumActiveFps", wireType) + } + m.NumActiveFps = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumActiveFps |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FinalityProviderDistInfo) 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 ErrIntOverflowFinality + } + 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: FinalityProviderDistInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalityProviderDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPk = &v + if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.LegacyDec + m.Commission = &v + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBondedSat", wireType) + } + m.TotalBondedSat = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBondedSat |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcDels = append(m.BtcDels, &BTCDelDistInfo{}) + if err := m.BtcDels[len(m.BtcDels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsTimestamped", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsTimestamped = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsJailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsJailed = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSlashed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSlashed = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BTCDelDistInfo) 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 ErrIntOverflowFinality + } + 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: BTCDelDistInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCDelDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPk = &v + if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakerAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) + } + m.TotalSat = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalSat |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *IndexedBlock) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/genesis.pb.go b/x/finality/types/genesis.pb.go index 86488a953..97bda62d0 100644 --- a/x/finality/types/genesis.pb.go +++ b/x/finality/types/genesis.pb.go @@ -44,6 +44,10 @@ type GenesisState struct { // missed_blocks represents a map between finality provider public key and their // missed blocks. MissedBlocks []FinalityProviderMissedBlocks `protobuf:"bytes,8,rep,name=missed_blocks,json=missedBlocks,proto3" json:"missed_blocks"` + // voting_powers the voting power of every finality provider at every block height. + VotingPowers []*VotingPowerFP `protobuf:"bytes,9,rep,name=voting_powers,json=votingPowers,proto3" json:"voting_powers,omitempty"` + // vp_dst_cache is the table of all providers voting power with the total at one specific block. + VpDstCache []*VotingPowerDistCacheBlkHeight `protobuf:"bytes,10,rep,name=vp_dst_cache,json=vpDstCache,proto3" json:"vp_dst_cache,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -135,6 +139,20 @@ func (m *GenesisState) GetMissedBlocks() []FinalityProviderMissedBlocks { return nil } +func (m *GenesisState) GetVotingPowers() []*VotingPowerFP { + if m != nil { + return m.VotingPowers + } + return nil +} + +func (m *GenesisState) GetVpDstCache() []*VotingPowerDistCacheBlkHeight { + if m != nil { + return m.VpDstCache + } + return nil +} + // VoteSig the vote of an finality provider // with the block of the vote, the finality provider btc public key and the vote signature. type VoteSig struct { @@ -437,6 +455,119 @@ func (m *MissedBlock) GetMissed() bool { return false } +// VotingPowerFP contains the information about the voting power +// of an finality provider in a specific block height. +type VotingPowerFP struct { + // block_height is the height of the block the voting power was stored. + BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // fp_btc_pk the finality provider btc public key. + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + // voting_power is the power of the finality provider at this specific block height. + VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +} + +func (m *VotingPowerFP) Reset() { *m = VotingPowerFP{} } +func (m *VotingPowerFP) String() string { return proto.CompactTextString(m) } +func (*VotingPowerFP) ProtoMessage() {} +func (*VotingPowerFP) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{7} +} +func (m *VotingPowerFP) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerFP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerFP.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 *VotingPowerFP) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerFP.Merge(m, src) +} +func (m *VotingPowerFP) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerFP) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerFP.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerFP proto.InternalMessageInfo + +func (m *VotingPowerFP) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *VotingPowerFP) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 +} + +// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height +type VotingPowerDistCacheBlkHeight struct { + // block_height is the height of the block the voting power distribution cached was stored. + BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // vp_distribution the finality providers distribution cache at that height. + VpDistribution *VotingPowerDistCache `protobuf:"bytes,2,opt,name=vp_distribution,json=vpDistribution,proto3" json:"vp_distribution,omitempty"` +} + +func (m *VotingPowerDistCacheBlkHeight) Reset() { *m = VotingPowerDistCacheBlkHeight{} } +func (m *VotingPowerDistCacheBlkHeight) String() string { return proto.CompactTextString(m) } +func (*VotingPowerDistCacheBlkHeight) ProtoMessage() {} +func (*VotingPowerDistCacheBlkHeight) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{8} +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerDistCacheBlkHeight.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 *VotingPowerDistCacheBlkHeight) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerDistCacheBlkHeight.Merge(m, src) +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerDistCacheBlkHeight) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerDistCacheBlkHeight.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerDistCacheBlkHeight proto.InternalMessageInfo + +func (m *VotingPowerDistCacheBlkHeight) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *VotingPowerDistCacheBlkHeight) GetVpDistribution() *VotingPowerDistCache { + if m != nil { + return m.VpDistribution + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "babylon.finality.v1.GenesisState") proto.RegisterType((*VoteSig)(nil), "babylon.finality.v1.VoteSig") @@ -445,56 +576,66 @@ func init() { proto.RegisterType((*SigningInfo)(nil), "babylon.finality.v1.SigningInfo") proto.RegisterType((*FinalityProviderMissedBlocks)(nil), "babylon.finality.v1.FinalityProviderMissedBlocks") proto.RegisterType((*MissedBlock)(nil), "babylon.finality.v1.MissedBlock") + proto.RegisterType((*VotingPowerFP)(nil), "babylon.finality.v1.VotingPowerFP") + proto.RegisterType((*VotingPowerDistCacheBlkHeight)(nil), "babylon.finality.v1.VotingPowerDistCacheBlkHeight") } func init() { proto.RegisterFile("babylon/finality/v1/genesis.proto", fileDescriptor_52dc577f74d797d1) } var fileDescriptor_52dc577f74d797d1 = []byte{ - // 693 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xcf, 0x6f, 0xd3, 0x4a, - 0x10, 0xc7, 0xe3, 0x24, 0x4d, 0xd2, 0x4d, 0xf2, 0xda, 0xb7, 0xad, 0x9e, 0xac, 0xbe, 0x92, 0xa6, - 0x96, 0x90, 0x72, 0xc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0x58, 0x46, 0x11, 0xaf, 0xdd, 0x68, 0x90, 0x2e, 0x4f, 0x69, 0xd9, 0xf6, 0x63, - 0x46, 0xe5, 0x93, 0x04, 0x96, 0xaf, 0x9a, 0xbe, 0x5b, 0x4a, 0xab, 0x39, 0xbd, 0x1d, 0xd2, 0x57, - 0xac, 0x9a, 0x58, 0x3c, 0x89, 0xcb, 0x60, 0x07, 0x14, 0x63, 0x12, 0xb8, 0x08, 0x66, 0xc4, 0xd6, - 0x17, 0xd1, 0x66, 0x50, 0x78, 0x81, 0xff, 0x81, 0x5c, 0xe8, 0x24, 0xea, 0x57, 0x40, 0xd1, 0xad, - 0xf1, 0xec, 0x78, 0x58, 0x91, 0x4e, 0x86, 0x15, 0xe9, 0xdb, 0xb0, 0x22, 0x7d, 0x38, 0xaf, 0xa4, - 0x4e, 0xce, 0x2b, 0xa9, 0x2f, 0xe7, 0x95, 0xd4, 0x9b, 0x8d, 0xeb, 0x53, 0x3c, 0x9a, 0x7c, 0x02, - 0x45, 0xb6, 0x66, 0x4e, 0x7c, 0xfd, 0x36, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0xae, 0x0d, 0xf5, - 0xca, 0x93, 0x07, 0x00, 0x00, + // 824 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xc7, 0xe3, 0x24, 0xcd, 0xcb, 0xc4, 0xd9, 0x2e, 0xb3, 0x2b, 0x64, 0x95, 0xdd, 0x34, 0xb1, + 0x84, 0x14, 0x0e, 0x24, 0xdb, 0xec, 0x0a, 0xb1, 0xec, 0x2d, 0xdb, 0x7d, 0x29, 0x01, 0x61, 0x4d, + 0x0a, 0x48, 0x08, 0xb0, 0x6c, 0x67, 0xe2, 0x8c, 0x92, 0x78, 0x46, 0x9e, 0x89, 0xd9, 0x7c, 0x0b, + 0x4e, 0x7c, 0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0xd7, 0xb9, 0xf9, 0x52, 0xde, 0xad, + 0x3e, 0x74, 0xe4, 0xfd, 0xd8, 0x05, 0xf9, 0x8d, 0xf3, 0xf4, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x47, 0x03, 0xe3, 0xd4, 0x79, 0x09, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -517,6 +658,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.VpDstCache) > 0 { + for iNdEx := len(m.VpDstCache) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VpDstCache[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.VotingPowers) > 0 { + for iNdEx := len(m.VotingPowers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VotingPowers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } if len(m.MissedBlocks) > 0 { for iNdEx := len(m.MissedBlocks) - 1; iNdEx >= 0; iNdEx-- { { @@ -911,6 +1080,91 @@ func (m *MissedBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *VotingPowerFP) 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 *VotingPowerFP) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerFP) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VotingPower != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x18 + } + if m.FpBtcPk != nil { + { + size := m.FpBtcPk.Size() + i -= size + if _, err := m.FpBtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *VotingPowerDistCacheBlkHeight) 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 *VotingPowerDistCacheBlkHeight) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerDistCacheBlkHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VpDistribution != nil { + { + size, err := m.VpDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -972,6 +1226,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.VotingPowers) > 0 { + for _, e := range m.VotingPowers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.VpDstCache) > 0 { + for _, e := range m.VpDstCache { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -1081,6 +1347,41 @@ func (m *MissedBlock) Size() (n int) { return n } +func (m *VotingPowerFP) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeight)) + } + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.VotingPower != 0 { + n += 1 + sovGenesis(uint64(m.VotingPower)) + } + return n +} + +func (m *VotingPowerDistCacheBlkHeight) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeight)) + } + if m.VpDistribution != nil { + l = m.VpDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1387,6 +1688,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPowers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VotingPowers = append(m.VotingPowers, &VotingPowerFP{}) + if err := m.VotingPowers[len(m.VotingPowers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VpDstCache", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VpDstCache = append(m.VpDstCache, &VotingPowerDistCacheBlkHeight{}) + if err := m.VpDstCache[len(m.VpDstCache)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -2133,6 +2502,234 @@ func (m *MissedBlock) Unmarshal(dAtA []byte) error { } return nil } +func (m *VotingPowerFP) 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 ErrIntOverflowGenesis + } + 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: VotingPowerFP: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerFP: 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.FpBtcPk = &v + if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + 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 ErrIntOverflowGenesis + } + 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 := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VotingPowerDistCacheBlkHeight) 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 ErrIntOverflowGenesis + } + 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: VotingPowerDistCacheBlkHeight: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerDistCacheBlkHeight: 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VpDistribution", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.VpDistribution == nil { + m.VpDistribution = &VotingPowerDistCache{} + } + if err := m.VpDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/keys.go b/x/finality/types/keys.go index 96b9fc331..8adaa365c 100644 --- a/x/finality/types/keys.go +++ b/x/finality/types/keys.go @@ -47,4 +47,6 @@ var ( NextHeightToFinalizeKey = []byte{0x07} // key prefix for next height to finalise FinalityProviderSigningInfoKeyPrefix = collections.NewPrefix(8) // key prefix for signing info FinalityProviderMissedBlockBitmapKeyPrefix = collections.NewPrefix(9) // key prefix for missed block bitmap + VotingPowerKey = []byte{0x10} // key prefix for the voting power + VotingPowerDistCacheKey = []byte{0x11} // key prefix for voting power distribution cache ) diff --git a/x/finality/types/mocked_keepers.go b/x/finality/types/mocked_keepers.go index c88b595b1..044983cc6 100644 --- a/x/finality/types/mocked_keepers.go +++ b/x/finality/types/mocked_keepers.go @@ -8,10 +8,9 @@ import ( context "context" reflect "reflect" - types "github.com/babylonlabs-io/babylon/types" - types0 "github.com/babylonlabs-io/babylon/x/btcstaking/types" - types1 "github.com/babylonlabs-io/babylon/x/epoching/types" - types2 "github.com/cosmos/cosmos-sdk/types" + types "github.com/babylonlabs-io/babylon/x/btcstaking/types" + types0 "github.com/babylonlabs-io/babylon/x/epoching/types" + types1 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" ) @@ -51,10 +50,10 @@ func (mr *MockBTCStakingKeeperMockRecorder) ClearPowerDistUpdateEvents(ctx, btcH } // GetAllPowerDistUpdateEvents mocks base method. -func (m *MockBTCStakingKeeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTipHeight, btcTipHeight uint32) []*types0.EventPowerDistUpdate { +func (m *MockBTCStakingKeeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTipHeight, btcTipHeight uint32) []*types.EventPowerDistUpdate { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllPowerDistUpdateEvents", ctx, lastBTCTipHeight, btcTipHeight) - ret0, _ := ret[0].([]*types0.EventPowerDistUpdate) + ret0, _ := ret[0].([]*types.EventPowerDistUpdate) return ret0 } @@ -65,10 +64,10 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetAllPowerDistUpdateEvents(ctx, las } // GetBTCDelegation mocks base method. -func (m *MockBTCStakingKeeper) GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*types0.BTCDelegation, error) { +func (m *MockBTCStakingKeeper) GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*types.BTCDelegation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBTCDelegation", ctx, stakingTxHashStr) - ret0, _ := ret[0].(*types0.BTCDelegation) + ret0, _ := ret[0].(*types.BTCDelegation) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -93,21 +92,6 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetBTCHeightAtBabylonHeight(ctx, bab return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBTCHeightAtBabylonHeight", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetBTCHeightAtBabylonHeight), ctx, babylonHeight) } -// GetBTCStakingActivatedHeight mocks base method. -func (m *MockBTCStakingKeeper) GetBTCStakingActivatedHeight(ctx context.Context) (uint64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBTCStakingActivatedHeight", ctx) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetBTCStakingActivatedHeight indicates an expected call of GetBTCStakingActivatedHeight. -func (mr *MockBTCStakingKeeperMockRecorder) GetBTCStakingActivatedHeight(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBTCStakingActivatedHeight", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetBTCStakingActivatedHeight), ctx) -} - // GetCurrentBTCHeight mocks base method. func (m *MockBTCStakingKeeper) GetCurrentBTCHeight(ctx context.Context) uint32 { m.ctrl.T.Helper() @@ -123,10 +107,10 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetCurrentBTCHeight(ctx interface{}) } // GetFinalityProvider mocks base method. -func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types0.FinalityProvider, error) { +func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types.FinalityProvider, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetFinalityProvider", ctx, fpBTCPK) - ret0, _ := ret[0].(*types0.FinalityProvider) + ret0, _ := ret[0].(*types.FinalityProvider) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -138,10 +122,10 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetFinalityProvider(ctx, fpBTCPK int } // GetParams mocks base method. -func (m *MockBTCStakingKeeper) GetParams(ctx context.Context) types0.Params { +func (m *MockBTCStakingKeeper) GetParams(ctx context.Context) types.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types0.Params) + ret0, _ := ret[0].(types.Params) return ret0 } @@ -151,48 +135,6 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetParams), ctx) } -// GetVotingPower mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPower", ctx, fpBTCPK, height) - ret0, _ := ret[0].(uint64) - return ret0 -} - -// GetVotingPower indicates an expected call of GetVotingPower. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPower(ctx, fpBTCPK, height interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPower", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPower), ctx, fpBTCPK, height) -} - -// GetVotingPowerDistCache mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPowerDistCache(ctx context.Context, height uint64) *types0.VotingPowerDistCache { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPowerDistCache", ctx, height) - ret0, _ := ret[0].(*types0.VotingPowerDistCache) - return ret0 -} - -// GetVotingPowerDistCache indicates an expected call of GetVotingPowerDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPowerDistCache(ctx, height interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPowerDistCache), ctx, height) -} - -// GetVotingPowerTable mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPowerTable", ctx, height) - ret0, _ := ret[0].(map[string]uint64) - return ret0 -} - -// GetVotingPowerTable indicates an expected call of GetVotingPowerTable. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPowerTable(ctx, height interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPowerTable", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPowerTable), ctx, height) -} - // HasFinalityProvider mocks base method. func (m *MockBTCStakingKeeper) HasFinalityProvider(ctx context.Context, fpBTCPK []byte) bool { m.ctrl.T.Helper() @@ -221,42 +163,6 @@ func (mr *MockBTCStakingKeeperMockRecorder) JailFinalityProvider(ctx, fpBTCPK in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JailFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).JailFinalityProvider), ctx, fpBTCPK) } -// RemoveVotingPowerDistCache mocks base method. -func (m *MockBTCStakingKeeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveVotingPowerDistCache", ctx, height) -} - -// RemoveVotingPowerDistCache indicates an expected call of RemoveVotingPowerDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) RemoveVotingPowerDistCache(ctx, height interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).RemoveVotingPowerDistCache), ctx, height) -} - -// SetVotingPower mocks base method. -func (m *MockBTCStakingKeeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height, votingPower uint64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetVotingPower", ctx, fpBTCPK, height, votingPower) -} - -// SetVotingPower indicates an expected call of SetVotingPower. -func (mr *MockBTCStakingKeeperMockRecorder) SetVotingPower(ctx, fpBTCPK, height, votingPower interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVotingPower", reflect.TypeOf((*MockBTCStakingKeeper)(nil).SetVotingPower), ctx, fpBTCPK, height, votingPower) -} - -// SetVotingPowerDistCache mocks base method. -func (m *MockBTCStakingKeeper) SetVotingPowerDistCache(ctx context.Context, height uint64, dc *types0.VotingPowerDistCache) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetVotingPowerDistCache", ctx, height, dc) -} - -// SetVotingPowerDistCache indicates an expected call of SetVotingPowerDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) SetVotingPowerDistCache(ctx, height, dc interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).SetVotingPowerDistCache), ctx, height, dc) -} - // SlashFinalityProvider mocks base method. func (m *MockBTCStakingKeeper) SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error { m.ctrl.T.Helper() @@ -309,10 +215,10 @@ func (m *MockCheckpointingKeeper) EXPECT() *MockCheckpointingKeeperMockRecorder } // GetEpoch mocks base method. -func (m *MockCheckpointingKeeper) GetEpoch(ctx context.Context) *types1.Epoch { +func (m *MockCheckpointingKeeper) GetEpoch(ctx context.Context) *types0.Epoch { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetEpoch", ctx) - ret0, _ := ret[0].(*types1.Epoch) + ret0, _ := ret[0].(*types0.Epoch) return ret0 } @@ -360,7 +266,7 @@ func (m *MockIncentiveKeeper) EXPECT() *MockIncentiveKeeperMockRecorder { } // IndexRefundableMsg mocks base method. -func (m *MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg types2.Msg) { +func (m *MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg types1.Msg) { m.ctrl.T.Helper() m.ctrl.Call(m, "IndexRefundableMsg", ctx, msg) } @@ -372,7 +278,7 @@ func (mr *MockIncentiveKeeperMockRecorder) IndexRefundableMsg(ctx, msg interface } // RewardBTCStaking mocks base method. -func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *types0.VotingPowerDistCache) { +func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *VotingPowerDistCache) { m.ctrl.T.Helper() m.ctrl.Call(m, "RewardBTCStaking", ctx, height, filteredDc) } @@ -382,40 +288,3 @@ func (mr *MockIncentiveKeeperMockRecorder) RewardBTCStaking(ctx, height, filtere mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RewardBTCStaking", reflect.TypeOf((*MockIncentiveKeeper)(nil).RewardBTCStaking), ctx, height, filteredDc) } - -// MockFinalityHooks is a mock of FinalityHooks interface. -type MockFinalityHooks struct { - ctrl *gomock.Controller - recorder *MockFinalityHooksMockRecorder -} - -// MockFinalityHooksMockRecorder is the mock recorder for MockFinalityHooks. -type MockFinalityHooksMockRecorder struct { - mock *MockFinalityHooks -} - -// NewMockFinalityHooks creates a new mock instance. -func NewMockFinalityHooks(ctrl *gomock.Controller) *MockFinalityHooks { - mock := &MockFinalityHooks{ctrl: ctrl} - mock.recorder = &MockFinalityHooksMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockFinalityHooks) EXPECT() *MockFinalityHooksMockRecorder { - return m.recorder -} - -// AfterSluggishFinalityProviderDetected mocks base method. -func (m *MockFinalityHooks) AfterSluggishFinalityProviderDetected(ctx context.Context, btcPk *types.BIP340PubKey) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AfterSluggishFinalityProviderDetected", ctx, btcPk) - ret0, _ := ret[0].(error) - return ret0 -} - -// AfterSluggishFinalityProviderDetected indicates an expected call of AfterSluggishFinalityProviderDetected. -func (mr *MockFinalityHooksMockRecorder) AfterSluggishFinalityProviderDetected(ctx, btcPk interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterSluggishFinalityProviderDetected", reflect.TypeOf((*MockFinalityHooks)(nil).AfterSluggishFinalityProviderDetected), ctx, btcPk) -} diff --git a/x/btcstaking/types/incentive.go b/x/finality/types/power_table.go similarity index 82% rename from x/btcstaking/types/incentive.go rename to x/finality/types/power_table.go index caf658512..2fd0073dc 100644 --- a/x/btcstaking/types/incentive.go +++ b/x/finality/types/power_table.go @@ -1,7 +1,10 @@ package types import ( + "sort" + sdkmath "cosmossdk.io/math" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -157,7 +160,7 @@ func (dc *VotingPowerDistCache) GetFinalityProviderPortion(v *FinalityProviderDi return sdkmath.LegacyNewDec(int64(v.TotalBondedSat)).QuoTruncate(sdkmath.LegacyNewDec(int64(dc.TotalBondedSat))) } -func NewFinalityProviderDistInfo(fp *FinalityProvider) *FinalityProviderDistInfo { +func NewFinalityProviderDistInfo(fp *bstypes.FinalityProvider) *FinalityProviderDistInfo { return &FinalityProviderDistInfo{ BtcPk: fp.BtcPk, Addr: fp.Addr, @@ -171,7 +174,7 @@ func (v *FinalityProviderDistInfo) GetAddress() sdk.AccAddress { return sdk.MustAccAddressFromBech32(v.Addr) } -func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *BTCDelegation) { +func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *bstypes.BTCDelegation) { btcDelDistInfo := &BTCDelDistInfo{ BtcPk: btcDel.BtcPk, StakerAddr: btcDel.StakerAddr, @@ -196,3 +199,37 @@ func (v *FinalityProviderDistInfo) GetBTCDelPortion(d *BTCDelDistInfo) sdkmath.L func (d *BTCDelDistInfo) GetAddress() sdk.AccAddress { return sdk.MustAccAddressFromBech32(d.StakerAddr) } + +// SortFinalityProvidersWithZeroedVotingPower sorts the finality providers slice, +// from higher to lower voting power. In the following cases, the voting power +// is treated as zero: +// 1. IsTimestamped is false +// 2. IsJailed is true +func SortFinalityProvidersWithZeroedVotingPower(fps []*FinalityProviderDistInfo) { + sort.SliceStable(fps, func(i, j int) bool { + iShouldBeZeroed := fps[i].IsJailed || !fps[i].IsTimestamped + jShouldBeZeroed := fps[j].IsJailed || !fps[j].IsTimestamped + + if iShouldBeZeroed && !jShouldBeZeroed { + return false + } + + if !iShouldBeZeroed && jShouldBeZeroed { + return true + } + + iPkHex, jPkHex := fps[i].BtcPk.MarshalHex(), fps[j].BtcPk.MarshalHex() + + if iShouldBeZeroed && jShouldBeZeroed { + // Both have zeroed voting power, compare BTC public keys + return iPkHex < jPkHex + } + + // both voting power the same, compare BTC public keys + if fps[i].TotalBondedSat == fps[j].TotalBondedSat { + return iPkHex < jPkHex + } + + return fps[i].TotalBondedSat > fps[j].TotalBondedSat + }) +} diff --git a/x/btcstaking/types/btcstaking_test.go b/x/finality/types/power_table_test.go similarity index 60% rename from x/btcstaking/types/btcstaking_test.go rename to x/finality/types/power_table_test.go index 2daf00c18..2775d6fc9 100644 --- a/x/btcstaking/types/btcstaking_test.go +++ b/x/finality/types/power_table_test.go @@ -4,13 +4,193 @@ import ( "math/rand" "testing" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" "github.com/babylonlabs-io/babylon/testutil/datagen" bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" + types "github.com/babylonlabs-io/babylon/x/finality/types" ) +var ( + fpPrivKey1, _ = btcec.NewPrivateKey() + fpPrivKey2, _ = btcec.NewPrivateKey() + fpPubKey1 = bbn.NewBIP340PubKeyFromBTCPK(fpPrivKey1.PubKey()) + fpPubKey2 = bbn.NewBIP340PubKeyFromBTCPK(fpPrivKey2.PubKey()) +) + +func TestVotingPowerDistCache(t *testing.T) { + tests := []struct { + desc string + maxActiveFPs uint32 + numActiveFps uint32 + numInactiveFps uint32 + totalVotingPower uint64 + prevDistCache *types.VotingPowerDistCache + fps []*types.FinalityProviderDistInfo + }{ + { + desc: "all not timestamped", + maxActiveFPs: 80, + numActiveFps: 0, + numInactiveFps: 2, + totalVotingPower: 0, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: false, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: false, + }, + }, + }, + { + desc: "all timestamped", + maxActiveFPs: 80, + numActiveFps: 2, + numInactiveFps: 0, + totalVotingPower: 3000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + }, + }, + }, + { + desc: "partly timestamped", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 1, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: false, + }, + }, + }, + { + desc: "small max active fps", + maxActiveFPs: 1, + numActiveFps: 1, + numInactiveFps: 1, + totalVotingPower: 2000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + }, + }, + }, + { + desc: "one got jailed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + IsJailed: true, + }, + }, + }, + { + desc: "one got slashed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 0, // a jailed fp cannot accept delegation + IsTimestamped: true, + IsSlashed: true, + }, + }, + }, + { + desc: "previous one got unjailed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCacheWithFinalityProviders( + []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + IsJailed: true, + }}), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + IsJailed: false, + }, + }, + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + dc := types.NewVotingPowerDistCacheWithFinalityProviders(tc.fps) + dc.ApplyActiveFinalityProviders(tc.maxActiveFPs) + require.Equal(t, tc.totalVotingPower, dc.TotalBondedSat) + require.Equal(t, tc.numActiveFps, dc.NumActiveFps) + + newActiveFps := dc.FindNewActiveFinalityProviders(tc.prevDistCache) + require.Equal(t, tc.numActiveFps, uint32(len(newActiveFps))) + + newInactiveFps := dc.FindNewInactiveFinalityProviders(tc.prevDistCache) + require.Equal(t, tc.numInactiveFps, uint32(len(newInactiveFps))) + }) + } +} + func TestSortFinalityProvidersWithZeroedVotingPower(t *testing.T) { tests := []struct { name string diff --git a/x/finality/types/query.pb.go b/x/finality/types/query.pb.go index c0d39e1ce..64ccbf9ac 100644 --- a/x/finality/types/query.pb.go +++ b/x/finality/types/query.pb.go @@ -151,27 +151,33 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -// QueryListPublicRandomnessRequest is the request type for the -// Query/ListPublicRandomness RPC method. -type QueryListPublicRandomnessRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider +// QueryFinalityProviderPowerAtHeightRequest is the request type for the +// Query/FinalityProviderPowerAtHeight RPC method. +type QueryFinalityProviderPowerAtHeightRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // height is used for querying the given finality provider's voting power at this height + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QueryListPublicRandomnessRequest) Reset() { *m = QueryListPublicRandomnessRequest{} } -func (m *QueryListPublicRandomnessRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListPublicRandomnessRequest) ProtoMessage() {} -func (*QueryListPublicRandomnessRequest) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderPowerAtHeightRequest) Reset() { + *m = QueryFinalityProviderPowerAtHeightRequest{} +} +func (m *QueryFinalityProviderPowerAtHeightRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryFinalityProviderPowerAtHeightRequest) ProtoMessage() {} +func (*QueryFinalityProviderPowerAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{2} } -func (m *QueryListPublicRandomnessRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPublicRandomnessRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -181,54 +187,55 @@ func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryListPublicRandomnessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPublicRandomnessRequest.Merge(m, src) +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Merge(m, src) } -func (m *QueryListPublicRandomnessRequest) XXX_Size() int { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListPublicRandomnessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPublicRandomnessRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPublicRandomnessRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest proto.InternalMessageInfo -func (m *QueryListPublicRandomnessRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderPowerAtHeightRequest) GetFpBtcPkHex() string { if m != nil { return m.FpBtcPkHex } return "" } -func (m *QueryListPublicRandomnessRequest) GetPagination() *query.PageRequest { +func (m *QueryFinalityProviderPowerAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.Pagination + return m.Height } - return nil + return 0 } -// QueryListPublicRandomnessResponse is the response type for the -// Query/ListPublicRandomness RPC method. -type QueryListPublicRandomnessResponse struct { - // pub_rand_map is the map where the key is the height and the value - // is the public randomness at this height for the given finality provider - PubRandMap map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,1,rep,name=pub_rand_map,json=pubRandMap,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryFinalityProviderPowerAtHeightResponse is the response type for the +// Query/FinalityProviderPowerAtHeight RPC method. +type QueryFinalityProviderPowerAtHeightResponse struct { + // voting_power is the voting power of the finality provider + VotingPower uint64 `protobuf:"varint,1,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` } -func (m *QueryListPublicRandomnessResponse) Reset() { *m = QueryListPublicRandomnessResponse{} } -func (m *QueryListPublicRandomnessResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListPublicRandomnessResponse) ProtoMessage() {} -func (*QueryListPublicRandomnessResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderPowerAtHeightResponse) Reset() { + *m = QueryFinalityProviderPowerAtHeightResponse{} +} +func (m *QueryFinalityProviderPowerAtHeightResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryFinalityProviderPowerAtHeightResponse) ProtoMessage() {} +func (*QueryFinalityProviderPowerAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{3} } -func (m *QueryListPublicRandomnessResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPublicRandomnessResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -238,47 +245,48 @@ func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryListPublicRandomnessResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPublicRandomnessResponse.Merge(m, src) +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Merge(m, src) } -func (m *QueryListPublicRandomnessResponse) XXX_Size() int { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryListPublicRandomnessResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPublicRandomnessResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPublicRandomnessResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse proto.InternalMessageInfo -func (m *QueryListPublicRandomnessResponse) GetPagination() *query.PageResponse { +func (m *QueryFinalityProviderPowerAtHeightResponse) GetVotingPower() uint64 { if m != nil { - return m.Pagination + return m.VotingPower } - return nil + return 0 } -// PubRandCommitResponse is the response type for a public randomness commitment -type PubRandCommitResponse struct { - // num_pub_rand is the number of committed public randomness - NumPubRand uint64 `protobuf:"varint,1,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` - // commitment is the value of the commitment - Commitment []byte `protobuf:"bytes,2,opt,name=commitment,proto3" json:"commitment,omitempty"` - // epoch_num defines the epoch number that the commit falls into - EpochNum uint64 `protobuf:"varint,3,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` +// QueryFinalityProviderCurrentPowerRequest is the request type for the +// Query/FinalityProviderCurrentPower RPC method. +type QueryFinalityProviderCurrentPowerRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` } -func (m *PubRandCommitResponse) Reset() { *m = PubRandCommitResponse{} } -func (m *PubRandCommitResponse) String() string { return proto.CompactTextString(m) } -func (*PubRandCommitResponse) ProtoMessage() {} -func (*PubRandCommitResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderCurrentPowerRequest) Reset() { + *m = QueryFinalityProviderCurrentPowerRequest{} +} +func (m *QueryFinalityProviderCurrentPowerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderCurrentPowerRequest) ProtoMessage() {} +func (*QueryFinalityProviderCurrentPowerRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{4} } -func (m *PubRandCommitResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PubRandCommitResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -288,60 +296,50 @@ func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *PubRandCommitResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PubRandCommitResponse.Merge(m, src) +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Merge(m, src) } -func (m *PubRandCommitResponse) XXX_Size() int { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Size() int { return m.Size() } -func (m *PubRandCommitResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PubRandCommitResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.DiscardUnknown(m) } -var xxx_messageInfo_PubRandCommitResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest proto.InternalMessageInfo -func (m *PubRandCommitResponse) GetNumPubRand() uint64 { +func (m *QueryFinalityProviderCurrentPowerRequest) GetFpBtcPkHex() string { if m != nil { - return m.NumPubRand + return m.FpBtcPkHex } - return 0 + return "" } -func (m *PubRandCommitResponse) GetCommitment() []byte { - if m != nil { - return m.Commitment - } - return nil +// QueryFinalityProviderCurrentPowerResponse is the response type for the +// Query/FinalityProviderCurrentPower RPC method. +type QueryFinalityProviderCurrentPowerResponse 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 finality provider + VotingPower uint64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` } -func (m *PubRandCommitResponse) GetEpochNum() uint64 { - if m != nil { - return m.EpochNum - } - return 0 +func (m *QueryFinalityProviderCurrentPowerResponse) Reset() { + *m = QueryFinalityProviderCurrentPowerResponse{} } - -// QueryListPubRandCommitRequest is the request type for the -// Query/ListPubRandCommit RPC method. -type QueryListPubRandCommitRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryFinalityProviderCurrentPowerResponse) String() string { + return proto.CompactTextString(m) } - -func (m *QueryListPubRandCommitRequest) Reset() { *m = QueryListPubRandCommitRequest{} } -func (m *QueryListPubRandCommitRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListPubRandCommitRequest) ProtoMessage() {} -func (*QueryListPubRandCommitRequest) Descriptor() ([]byte, []int) { +func (*QueryFinalityProviderCurrentPowerResponse) ProtoMessage() {} +func (*QueryFinalityProviderCurrentPowerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{5} } -func (m *QueryListPubRandCommitRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPubRandCommitRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -351,54 +349,57 @@ func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryListPubRandCommitRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPubRandCommitRequest.Merge(m, src) +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Merge(m, src) } -func (m *QueryListPubRandCommitRequest) XXX_Size() int { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Size() int { return m.Size() } -func (m *QueryListPubRandCommitRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPubRandCommitRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPubRandCommitRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse proto.InternalMessageInfo -func (m *QueryListPubRandCommitRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderCurrentPowerResponse) GetHeight() uint64 { if m != nil { - return m.FpBtcPkHex + return m.Height } - return "" + return 0 } -func (m *QueryListPubRandCommitRequest) GetPagination() *query.PageRequest { +func (m *QueryFinalityProviderCurrentPowerResponse) GetVotingPower() uint64 { if m != nil { - return m.Pagination + return m.VotingPower } - return nil + return 0 } -// QueryListPubRandCommitResponse is the response type for the -// Query/ListPubRandCommit RPC method. -type QueryListPubRandCommitResponse struct { - // pub_rand_commit_map is the map where the key is the start height and the value - // is the public randomness commitment at this height for the given finality provider - PubRandCommitMap map[uint64]*PubRandCommitResponse `protobuf:"bytes,1,rep,name=pub_rand_commit_map,json=pubRandCommitMap,proto3" json:"pub_rand_commit_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryActiveFinalityProvidersAtHeightRequest is the request type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +type QueryActiveFinalityProvidersAtHeightRequest struct { + // height defines at which Babylon height to query the finality providers info. + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryListPubRandCommitResponse) Reset() { *m = QueryListPubRandCommitResponse{} } -func (m *QueryListPubRandCommitResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListPubRandCommitResponse) ProtoMessage() {} -func (*QueryListPubRandCommitResponse) Descriptor() ([]byte, []int) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) Reset() { + *m = QueryActiveFinalityProvidersAtHeightRequest{} +} +func (m *QueryActiveFinalityProvidersAtHeightRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryActiveFinalityProvidersAtHeightRequest) ProtoMessage() {} +func (*QueryActiveFinalityProvidersAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{6} } -func (m *QueryListPubRandCommitResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPubRandCommitResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -408,51 +409,67 @@ func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *QueryListPubRandCommitResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPubRandCommitResponse.Merge(m, src) +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Merge(m, src) } -func (m *QueryListPubRandCommitResponse) XXX_Size() int { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListPubRandCommitResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPubRandCommitResponse.DiscardUnknown(m) +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPubRandCommitResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest proto.InternalMessageInfo -func (m *QueryListPubRandCommitResponse) GetPubRandCommitMap() map[uint64]*PubRandCommitResponse { +func (m *QueryActiveFinalityProvidersAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.PubRandCommitMap + return m.Height } - return nil + return 0 } -func (m *QueryListPubRandCommitResponse) GetPagination() *query.PageResponse { +func (m *QueryActiveFinalityProvidersAtHeightRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -// QueryBlockRequest is the request type for the -// Query/Block RPC method. -type QueryBlockRequest struct { - // height is the height of the Babylon block - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *QueryBlockRequest) Reset() { *m = QueryBlockRequest{} } -func (m *QueryBlockRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBlockRequest) ProtoMessage() {} -func (*QueryBlockRequest) Descriptor() ([]byte, []int) { +// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. +type ActiveFinalityProvidersAtHeightResponse struct { + // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider + // the PK follows encoding in BIP-340 spec + BtcPkHex *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk_hex,json=btcPkHex,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk_hex,omitempty"` + // height is the queried Babylon height + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // voting_power is the voting power of this finality provider at the given height + VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBabylonHeight uint64 `protobuf:"varint,4,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBtcHeight uint32 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + // jailed defines whether the finality provider is detected jailed + Jailed bool `protobuf:"varint,6,opt,name=jailed,proto3" json:"jailed,omitempty"` +} + +func (m *ActiveFinalityProvidersAtHeightResponse) Reset() { + *m = ActiveFinalityProvidersAtHeightResponse{} +} +func (m *ActiveFinalityProvidersAtHeightResponse) String() string { return proto.CompactTextString(m) } +func (*ActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} +func (*ActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{7} } -func (m *QueryBlockRequest) XXX_Unmarshal(b []byte) error { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBlockRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -462,44 +479,78 @@ func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *QueryBlockRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBlockRequest.Merge(m, src) +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.Merge(m, src) } -func (m *QueryBlockRequest) XXX_Size() int { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryBlockRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBlockRequest.DiscardUnknown(m) +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBlockRequest proto.InternalMessageInfo +var xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo -func (m *QueryBlockRequest) GetHeight() uint64 { +func (m *ActiveFinalityProvidersAtHeightResponse) GetHeight() uint64 { if m != nil { return m.Height } return 0 } -// QueryBlockResponse is the response type for the -// Query/Block RPC method. -type QueryBlockResponse struct { - // block is the Babylon at the given height - Block *IndexedBlock `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` +func (m *ActiveFinalityProvidersAtHeightResponse) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 } -func (m *QueryBlockResponse) Reset() { *m = QueryBlockResponse{} } -func (m *QueryBlockResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBlockResponse) ProtoMessage() {} -func (*QueryBlockResponse) Descriptor() ([]byte, []int) { +func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBabylonHeight() uint64 { + if m != nil { + return m.SlashedBabylonHeight + } + return 0 +} + +func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBtcHeight() uint32 { + if m != nil { + return m.SlashedBtcHeight + } + return 0 +} + +func (m *ActiveFinalityProvidersAtHeightResponse) GetJailed() bool { + if m != nil { + return m.Jailed + } + return false +} + +// QueryActiveFinalityProvidersAtHeightResponse is the response type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +type QueryActiveFinalityProvidersAtHeightResponse struct { + // finality_providers contains all the queried finality providersn. + FinalityProviders []*ActiveFinalityProvidersAtHeightResponse `protobuf:"bytes,1,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) Reset() { + *m = QueryActiveFinalityProvidersAtHeightResponse{} +} +func (m *QueryActiveFinalityProvidersAtHeightResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} +func (*QueryActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{8} } -func (m *QueryBlockResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBlockResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -509,46 +560,48 @@ func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryBlockResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBlockResponse.Merge(m, src) +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Merge(m, src) } -func (m *QueryBlockResponse) XXX_Size() int { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryBlockResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBlockResponse.DiscardUnknown(m) +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBlockResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo -func (m *QueryBlockResponse) GetBlock() *IndexedBlock { +func (m *QueryActiveFinalityProvidersAtHeightResponse) GetFinalityProviders() []*ActiveFinalityProvidersAtHeightResponse { if m != nil { - return m.Block + return m.FinalityProviders } return nil } -// QueryListBlocksRequest is the request type for the -// Query/ListBlocks RPC method. -type QueryListBlocksRequest struct { - // status indicates the status of blocks that the querier wants to query - Status QueriedBlockStatus `protobuf:"varint,1,opt,name=status,proto3,enum=babylon.finality.v1.QueriedBlockStatus" json:"status,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryActiveFinalityProvidersAtHeightResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryListBlocksRequest) Reset() { *m = QueryListBlocksRequest{} } -func (m *QueryListBlocksRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListBlocksRequest) ProtoMessage() {} -func (*QueryListBlocksRequest) Descriptor() ([]byte, []int) { +// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. +type QueryActivatedHeightRequest struct { +} + +func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeightRequest{} } +func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryActivatedHeightRequest) ProtoMessage() {} +func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{9} } -func (m *QueryListBlocksRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListBlocksRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActivatedHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -558,53 +611,35 @@ func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryListBlocksRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListBlocksRequest.Merge(m, src) +func (m *QueryActivatedHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActivatedHeightRequest.Merge(m, src) } -func (m *QueryListBlocksRequest) XXX_Size() int { +func (m *QueryActivatedHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListBlocksRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListBlocksRequest.DiscardUnknown(m) +func (m *QueryActivatedHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActivatedHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListBlocksRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryActivatedHeightRequest proto.InternalMessageInfo -func (m *QueryListBlocksRequest) GetStatus() QueriedBlockStatus { - if m != nil { - return m.Status - } - return QueriedBlockStatus_NON_FINALIZED +// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. +type QueryActivatedHeightResponse struct { + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QueryListBlocksRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryListBlocksResponse is the response type for the -// Query/ListBlocks RPC method. -type QueryListBlocksResponse struct { - // blocks is the list of blocks at the given status - Blocks []*IndexedBlock `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryListBlocksResponse) Reset() { *m = QueryListBlocksResponse{} } -func (m *QueryListBlocksResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListBlocksResponse) ProtoMessage() {} -func (*QueryListBlocksResponse) Descriptor() ([]byte, []int) { +func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeightResponse{} } +func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryActivatedHeightResponse) ProtoMessage() {} +func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{10} } -func (m *QueryListBlocksResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListBlocksResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActivatedHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -614,51 +649,46 @@ func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryListBlocksResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListBlocksResponse.Merge(m, src) +func (m *QueryActivatedHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActivatedHeightResponse.Merge(m, src) } -func (m *QueryListBlocksResponse) XXX_Size() int { +func (m *QueryActivatedHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryListBlocksResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListBlocksResponse.DiscardUnknown(m) +func (m *QueryActivatedHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActivatedHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListBlocksResponse proto.InternalMessageInfo - -func (m *QueryListBlocksResponse) GetBlocks() []*IndexedBlock { - if m != nil { - return m.Blocks - } - return nil -} +var xxx_messageInfo_QueryActivatedHeightResponse proto.InternalMessageInfo -func (m *QueryListBlocksResponse) GetPagination() *query.PageResponse { +func (m *QueryActivatedHeightResponse) GetHeight() uint64 { if m != nil { - return m.Pagination + return m.Height } - return nil + return 0 } -// QueryVotesAtHeightRequest is the request type for the -// Query/VotesAtHeight RPC method. -type QueryVotesAtHeightRequest struct { - // height defines at which height to query the finality providers. - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +// QueryListPublicRandomnessRequest is the request type for the +// Query/ListPublicRandomness RPC method. +type QueryListPublicRandomnessRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryVotesAtHeightRequest) Reset() { *m = QueryVotesAtHeightRequest{} } -func (m *QueryVotesAtHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryVotesAtHeightRequest) ProtoMessage() {} -func (*QueryVotesAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *QueryListPublicRandomnessRequest) Reset() { *m = QueryListPublicRandomnessRequest{} } +func (m *QueryListPublicRandomnessRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListPublicRandomnessRequest) ProtoMessage() {} +func (*QueryListPublicRandomnessRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{11} } -func (m *QueryVotesAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListPublicRandomnessRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVotesAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPublicRandomnessRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -668,45 +698,54 @@ func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryVotesAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVotesAtHeightRequest.Merge(m, src) +func (m *QueryListPublicRandomnessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPublicRandomnessRequest.Merge(m, src) } -func (m *QueryVotesAtHeightRequest) XXX_Size() int { +func (m *QueryListPublicRandomnessRequest) XXX_Size() int { return m.Size() } -func (m *QueryVotesAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVotesAtHeightRequest.DiscardUnknown(m) +func (m *QueryListPublicRandomnessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPublicRandomnessRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryVotesAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListPublicRandomnessRequest proto.InternalMessageInfo -func (m *QueryVotesAtHeightRequest) GetHeight() uint64 { +func (m *QueryListPublicRandomnessRequest) GetFpBtcPkHex() string { if m != nil { - return m.Height + return m.FpBtcPkHex } - return 0 + return "" } -// QueryVotesAtHeightResponse is the response type for the -// Query/VotesAtHeight RPC method. -type QueryVotesAtHeightResponse struct { - // btc_pk is the Bitcoin secp256k1 PK of finality providers who have signed the block at given height. - // the PK follows encoding in BIP-340 spec - BtcPks []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=btc_pks,json=btcPks,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pks,omitempty"` +func (m *QueryListPublicRandomnessRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryVotesAtHeightResponse) Reset() { *m = QueryVotesAtHeightResponse{} } -func (m *QueryVotesAtHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryVotesAtHeightResponse) ProtoMessage() {} -func (*QueryVotesAtHeightResponse) Descriptor() ([]byte, []int) { +// QueryListPublicRandomnessResponse is the response type for the +// Query/ListPublicRandomness RPC method. +type QueryListPublicRandomnessResponse struct { + // pub_rand_map is the map where the key is the height and the value + // is the public randomness at this height for the given finality provider + PubRandMap map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,1,rep,name=pub_rand_map,json=pubRandMap,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListPublicRandomnessResponse) Reset() { *m = QueryListPublicRandomnessResponse{} } +func (m *QueryListPublicRandomnessResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListPublicRandomnessResponse) ProtoMessage() {} +func (*QueryListPublicRandomnessResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{12} } -func (m *QueryVotesAtHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPublicRandomnessResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVotesAtHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPublicRandomnessResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -716,38 +755,47 @@ func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryVotesAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVotesAtHeightResponse.Merge(m, src) +func (m *QueryListPublicRandomnessResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPublicRandomnessResponse.Merge(m, src) } -func (m *QueryVotesAtHeightResponse) XXX_Size() int { +func (m *QueryListPublicRandomnessResponse) XXX_Size() int { return m.Size() } -func (m *QueryVotesAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVotesAtHeightResponse.DiscardUnknown(m) +func (m *QueryListPublicRandomnessResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPublicRandomnessResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryVotesAtHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPublicRandomnessResponse proto.InternalMessageInfo -// QueryEvidenceRequest is the request type for the -// Query/Evidence RPC method. -type QueryEvidenceRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - // (in BIP340 format) of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +func (m *QueryListPublicRandomnessResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryEvidenceRequest) Reset() { *m = QueryEvidenceRequest{} } -func (m *QueryEvidenceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryEvidenceRequest) ProtoMessage() {} -func (*QueryEvidenceRequest) Descriptor() ([]byte, []int) { +// PubRandCommitResponse is the response type for a public randomness commitment +type PubRandCommitResponse struct { + // num_pub_rand is the number of committed public randomness + NumPubRand uint64 `protobuf:"varint,1,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` + // commitment is the value of the commitment + Commitment []byte `protobuf:"bytes,2,opt,name=commitment,proto3" json:"commitment,omitempty"` + // epoch_num defines the epoch number that the commit falls into + EpochNum uint64 `protobuf:"varint,3,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` +} + +func (m *PubRandCommitResponse) Reset() { *m = PubRandCommitResponse{} } +func (m *PubRandCommitResponse) String() string { return proto.CompactTextString(m) } +func (*PubRandCommitResponse) ProtoMessage() {} +func (*PubRandCommitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{13} } -func (m *QueryEvidenceRequest) XXX_Unmarshal(b []byte) error { +func (m *PubRandCommitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEvidenceRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_PubRandCommitResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -757,60 +805,60 @@ func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *QueryEvidenceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEvidenceRequest.Merge(m, src) +func (m *PubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubRandCommitResponse.Merge(m, src) } -func (m *QueryEvidenceRequest) XXX_Size() int { +func (m *PubRandCommitResponse) XXX_Size() int { return m.Size() } -func (m *QueryEvidenceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEvidenceRequest.DiscardUnknown(m) +func (m *PubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PubRandCommitResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryEvidenceRequest proto.InternalMessageInfo +var xxx_messageInfo_PubRandCommitResponse proto.InternalMessageInfo -func (m *QueryEvidenceRequest) GetFpBtcPkHex() string { +func (m *PubRandCommitResponse) GetNumPubRand() uint64 { if m != nil { - return m.FpBtcPkHex + return m.NumPubRand } - return "" + return 0 } -// Evidence is the evidence that a finality provider has signed finality -// signatures with correct public randomness on two conflicting Babylon headers -type EvidenceResponse struct { - // fp_btc_pk_hex is the BTC PK of the finality provider that casts this vote +func (m *PubRandCommitResponse) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil +} + +func (m *PubRandCommitResponse) GetEpochNum() uint64 { + if m != nil { + return m.EpochNum + } + return 0 +} + +// QueryListPubRandCommitRequest is the request type for the +// Query/ListPubRandCommit RPC method. +type QueryListPubRandCommitRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // block_height is the height of the conflicting blocks - BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // pub_rand is the public randomness the finality provider has committed to - PubRand *github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,3,opt,name=pub_rand,json=pubRand,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand,omitempty"` - // canonical_app_hash is the AppHash of the canonical block - CanonicalAppHash []byte `protobuf:"bytes,4,opt,name=canonical_app_hash,json=canonicalAppHash,proto3" json:"canonical_app_hash,omitempty"` - // fork_app_hash is the AppHash of the fork block - ForkAppHash []byte `protobuf:"bytes,5,opt,name=fork_app_hash,json=forkAppHash,proto3" json:"fork_app_hash,omitempty"` - // canonical_finality_sig is the finality signature to the canonical block - // where finality signature is an EOTS signature, i.e., - // the `s` in a Schnorr signature `(r, s)` - // `r` is the public randomness that is already committed by the finality provider - CanonicalFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,6,opt,name=canonical_finality_sig,json=canonicalFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"canonical_finality_sig,omitempty"` - // fork_finality_sig is the finality signature to the fork block - // where finality signature is an EOTS signature - ForkFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,7,opt,name=fork_finality_sig,json=forkFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"fork_finality_sig,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *EvidenceResponse) Reset() { *m = EvidenceResponse{} } -func (m *EvidenceResponse) String() string { return proto.CompactTextString(m) } -func (*EvidenceResponse) ProtoMessage() {} -func (*EvidenceResponse) Descriptor() ([]byte, []int) { +func (m *QueryListPubRandCommitRequest) Reset() { *m = QueryListPubRandCommitRequest{} } +func (m *QueryListPubRandCommitRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListPubRandCommitRequest) ProtoMessage() {} +func (*QueryListPubRandCommitRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{14} } -func (m *EvidenceResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPubRandCommitRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EvidenceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPubRandCommitRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -820,64 +868,54 @@ func (m *EvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *EvidenceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_EvidenceResponse.Merge(m, src) +func (m *QueryListPubRandCommitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitRequest.Merge(m, src) } -func (m *EvidenceResponse) XXX_Size() int { +func (m *QueryListPubRandCommitRequest) XXX_Size() int { return m.Size() } -func (m *EvidenceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_EvidenceResponse.DiscardUnknown(m) +func (m *QueryListPubRandCommitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitRequest.DiscardUnknown(m) } -var xxx_messageInfo_EvidenceResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPubRandCommitRequest proto.InternalMessageInfo -func (m *EvidenceResponse) GetFpBtcPkHex() string { +func (m *QueryListPubRandCommitRequest) GetFpBtcPkHex() string { if m != nil { return m.FpBtcPkHex } return "" } -func (m *EvidenceResponse) GetBlockHeight() uint64 { +func (m *QueryListPubRandCommitRequest) GetPagination() *query.PageRequest { if m != nil { - return m.BlockHeight - } - return 0 -} - -func (m *EvidenceResponse) GetCanonicalAppHash() []byte { - if m != nil { - return m.CanonicalAppHash - } - return nil -} - -func (m *EvidenceResponse) GetForkAppHash() []byte { - if m != nil { - return m.ForkAppHash + return m.Pagination } return nil } -// QueryEvidenceResponse is the response type for the -// Query/Evidence RPC method. -type QueryEvidenceResponse struct { - Evidence *EvidenceResponse `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` +// QueryListPubRandCommitResponse is the response type for the +// Query/ListPubRandCommit RPC method. +type QueryListPubRandCommitResponse struct { + // pub_rand_commit_map is the map where the key is the start height and the value + // is the public randomness commitment at this height for the given finality provider + PubRandCommitMap map[uint64]*PubRandCommitResponse `protobuf:"bytes,1,rep,name=pub_rand_commit_map,json=pubRandCommitMap,proto3" json:"pub_rand_commit_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryEvidenceResponse) Reset() { *m = QueryEvidenceResponse{} } -func (m *QueryEvidenceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryEvidenceResponse) ProtoMessage() {} -func (*QueryEvidenceResponse) Descriptor() ([]byte, []int) { +func (m *QueryListPubRandCommitResponse) Reset() { *m = QueryListPubRandCommitResponse{} } +func (m *QueryListPubRandCommitResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListPubRandCommitResponse) ProtoMessage() {} +func (*QueryListPubRandCommitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{15} } -func (m *QueryEvidenceResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPubRandCommitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEvidenceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPubRandCommitResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -887,47 +925,51 @@ func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryEvidenceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEvidenceResponse.Merge(m, src) +func (m *QueryListPubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitResponse.Merge(m, src) } -func (m *QueryEvidenceResponse) XXX_Size() int { +func (m *QueryListPubRandCommitResponse) XXX_Size() int { return m.Size() } -func (m *QueryEvidenceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEvidenceResponse.DiscardUnknown(m) +func (m *QueryListPubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryEvidenceResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPubRandCommitResponse proto.InternalMessageInfo -func (m *QueryEvidenceResponse) GetEvidence() *EvidenceResponse { +func (m *QueryListPubRandCommitResponse) GetPubRandCommitMap() map[uint64]*PubRandCommitResponse { if m != nil { - return m.Evidence + return m.PubRandCommitMap } return nil } -// QueryListEvidencesRequest is the request type for the -// Query/ListEvidences RPC method. -type QueryListEvidencesRequest struct { - // start_height is the starting height that the querier specifies - // such that the RPC will only return evidences since this height - StartHeight uint64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryListPubRandCommitResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryListEvidencesRequest) Reset() { *m = QueryListEvidencesRequest{} } -func (m *QueryListEvidencesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListEvidencesRequest) ProtoMessage() {} -func (*QueryListEvidencesRequest) Descriptor() ([]byte, []int) { +// QueryBlockRequest is the request type for the +// Query/Block RPC method. +type QueryBlockRequest struct { + // height is the height of the Babylon block + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryBlockRequest) Reset() { *m = QueryBlockRequest{} } +func (m *QueryBlockRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBlockRequest) ProtoMessage() {} +func (*QueryBlockRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{16} } -func (m *QueryListEvidencesRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListEvidencesRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -937,53 +979,44 @@ func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryListEvidencesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListEvidencesRequest.Merge(m, src) +func (m *QueryBlockRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockRequest.Merge(m, src) } -func (m *QueryListEvidencesRequest) XXX_Size() int { +func (m *QueryBlockRequest) XXX_Size() int { return m.Size() } -func (m *QueryListEvidencesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListEvidencesRequest.DiscardUnknown(m) +func (m *QueryBlockRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListEvidencesRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryBlockRequest proto.InternalMessageInfo -func (m *QueryListEvidencesRequest) GetStartHeight() uint64 { +func (m *QueryBlockRequest) GetHeight() uint64 { if m != nil { - return m.StartHeight + return m.Height } return 0 } -func (m *QueryListEvidencesRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryListEvidencesResponse is the response type for the -// Query/ListEvidences RPC method. -type QueryListEvidencesResponse struct { - // blocks is the list of evidences - Evidences []*EvidenceResponse `protobuf:"bytes,1,rep,name=evidences,proto3" json:"evidences,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryBlockResponse is the response type for the +// Query/Block RPC method. +type QueryBlockResponse struct { + // block is the Babylon at the given height + Block *IndexedBlock `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` } -func (m *QueryListEvidencesResponse) Reset() { *m = QueryListEvidencesResponse{} } -func (m *QueryListEvidencesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListEvidencesResponse) ProtoMessage() {} -func (*QueryListEvidencesResponse) Descriptor() ([]byte, []int) { +func (m *QueryBlockResponse) Reset() { *m = QueryBlockResponse{} } +func (m *QueryBlockResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBlockResponse) ProtoMessage() {} +func (*QueryBlockResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{17} } -func (m *QueryListEvidencesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListEvidencesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -993,52 +1026,46 @@ func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryListEvidencesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListEvidencesResponse.Merge(m, src) +func (m *QueryBlockResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockResponse.Merge(m, src) } -func (m *QueryListEvidencesResponse) XXX_Size() int { +func (m *QueryBlockResponse) XXX_Size() int { return m.Size() } -func (m *QueryListEvidencesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListEvidencesResponse.DiscardUnknown(m) +func (m *QueryBlockResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListEvidencesResponse proto.InternalMessageInfo - -func (m *QueryListEvidencesResponse) GetEvidences() []*EvidenceResponse { - if m != nil { - return m.Evidences - } - return nil -} +var xxx_messageInfo_QueryBlockResponse proto.InternalMessageInfo -func (m *QueryListEvidencesResponse) GetPagination() *query.PageResponse { +func (m *QueryBlockResponse) GetBlock() *IndexedBlock { if m != nil { - return m.Pagination + return m.Block } return nil } -// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC -// method -type QuerySigningInfoRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - // (in BIP340 format) of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +// QueryListBlocksRequest is the request type for the +// Query/ListBlocks RPC method. +type QueryListBlocksRequest struct { + // status indicates the status of blocks that the querier wants to query + Status QueriedBlockStatus `protobuf:"varint,1,opt,name=status,proto3,enum=babylon.finality.v1.QueriedBlockStatus" json:"status,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QuerySigningInfoRequest) Reset() { *m = QuerySigningInfoRequest{} } -func (m *QuerySigningInfoRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfoRequest) ProtoMessage() {} -func (*QuerySigningInfoRequest) Descriptor() ([]byte, []int) { +func (m *QueryListBlocksRequest) Reset() { *m = QueryListBlocksRequest{} } +func (m *QueryListBlocksRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListBlocksRequest) ProtoMessage() {} +func (*QueryListBlocksRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{18} } -func (m *QuerySigningInfoRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListBlocksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfoRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListBlocksRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1048,51 +1075,53 @@ func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QuerySigningInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfoRequest.Merge(m, src) +func (m *QueryListBlocksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListBlocksRequest.Merge(m, src) } -func (m *QuerySigningInfoRequest) XXX_Size() int { +func (m *QueryListBlocksRequest) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfoRequest.DiscardUnknown(m) +func (m *QueryListBlocksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListBlocksRequest.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfoRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListBlocksRequest proto.InternalMessageInfo -func (m *QuerySigningInfoRequest) GetFpBtcPkHex() string { +func (m *QueryListBlocksRequest) GetStatus() QueriedBlockStatus { if m != nil { - return m.FpBtcPkHex + return m.Status } - return "" + return QueriedBlockStatus_NON_FINALIZED } -// SigningInfoResponse defines the API response containing a finality provider's signing info -// for monitoring their liveness activity. -type SigningInfoResponse struct { - // fp_btc_pk is the BTC PK of the finality provider that casts this vote - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // start_height is the block height at which finality provider become active - StartHeight int64 `protobuf:"varint,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // missed_blocks_counter defines a counter to avoid unnecessary array reads. - // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. - MissedBlocksCounter int64 `protobuf:"varint,3,opt,name=missed_blocks_counter,json=missedBlocksCounter,proto3" json:"missed_blocks_counter,omitempty"` - // Timestamp until which the validator is jailed due to liveness downtime. - JailedUntil time.Time `protobuf:"bytes,4,opt,name=jailed_until,json=jailedUntil,proto3,stdtime" json:"jailed_until"` +func (m *QueryListBlocksRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *SigningInfoResponse) Reset() { *m = SigningInfoResponse{} } -func (m *SigningInfoResponse) String() string { return proto.CompactTextString(m) } -func (*SigningInfoResponse) ProtoMessage() {} -func (*SigningInfoResponse) Descriptor() ([]byte, []int) { +// QueryListBlocksResponse is the response type for the +// Query/ListBlocks RPC method. +type QueryListBlocksResponse struct { + // blocks is the list of blocks at the given status + Blocks []*IndexedBlock `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListBlocksResponse) Reset() { *m = QueryListBlocksResponse{} } +func (m *QueryListBlocksResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListBlocksResponse) ProtoMessage() {} +func (*QueryListBlocksResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{19} } -func (m *SigningInfoResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListBlocksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SigningInfoResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListBlocksResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1102,64 +1131,51 @@ func (m *SigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *SigningInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SigningInfoResponse.Merge(m, src) +func (m *QueryListBlocksResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListBlocksResponse.Merge(m, src) } -func (m *SigningInfoResponse) XXX_Size() int { +func (m *QueryListBlocksResponse) XXX_Size() int { return m.Size() } -func (m *SigningInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SigningInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SigningInfoResponse proto.InternalMessageInfo - -func (m *SigningInfoResponse) GetFpBtcPkHex() string { - if m != nil { - return m.FpBtcPkHex - } - return "" +func (m *QueryListBlocksResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListBlocksResponse.DiscardUnknown(m) } -func (m *SigningInfoResponse) GetStartHeight() int64 { - if m != nil { - return m.StartHeight - } - return 0 -} +var xxx_messageInfo_QueryListBlocksResponse proto.InternalMessageInfo -func (m *SigningInfoResponse) GetMissedBlocksCounter() int64 { +func (m *QueryListBlocksResponse) GetBlocks() []*IndexedBlock { if m != nil { - return m.MissedBlocksCounter + return m.Blocks } - return 0 + return nil } -func (m *SigningInfoResponse) GetJailedUntil() time.Time { +func (m *QueryListBlocksResponse) GetPagination() *query.PageResponse { if m != nil { - return m.JailedUntil + return m.Pagination } - return time.Time{} + return nil } -// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC -// method -type QuerySigningInfoResponse struct { - SigningInfo SigningInfoResponse `protobuf:"bytes,1,opt,name=signing_info,json=signingInfo,proto3" json:"signing_info"` +// QueryVotesAtHeightRequest is the request type for the +// Query/VotesAtHeight RPC method. +type QueryVotesAtHeightRequest struct { + // height defines at which height to query the finality providers. + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QuerySigningInfoResponse) Reset() { *m = QuerySigningInfoResponse{} } -func (m *QuerySigningInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfoResponse) ProtoMessage() {} -func (*QuerySigningInfoResponse) Descriptor() ([]byte, []int) { +func (m *QueryVotesAtHeightRequest) Reset() { *m = QueryVotesAtHeightRequest{} } +func (m *QueryVotesAtHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesAtHeightRequest) ProtoMessage() {} +func (*QueryVotesAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{20} } -func (m *QuerySigningInfoResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryVotesAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfoResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryVotesAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1169,43 +1185,45 @@ func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QuerySigningInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfoResponse.Merge(m, src) +func (m *QueryVotesAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesAtHeightRequest.Merge(m, src) } -func (m *QuerySigningInfoResponse) XXX_Size() int { +func (m *QueryVotesAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfoResponse.DiscardUnknown(m) +func (m *QueryVotesAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesAtHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfoResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryVotesAtHeightRequest proto.InternalMessageInfo -func (m *QuerySigningInfoResponse) GetSigningInfo() SigningInfoResponse { +func (m *QueryVotesAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.SigningInfo + return m.Height } - return SigningInfoResponse{} + return 0 } -// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC -// method -type QuerySigningInfosRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryVotesAtHeightResponse is the response type for the +// Query/VotesAtHeight RPC method. +type QueryVotesAtHeightResponse struct { + // btc_pk is the Bitcoin secp256k1 PK of finality providers who have signed the block at given height. + // the PK follows encoding in BIP-340 spec + BtcPks []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=btc_pks,json=btcPks,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pks,omitempty"` } -func (m *QuerySigningInfosRequest) Reset() { *m = QuerySigningInfosRequest{} } -func (m *QuerySigningInfosRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfosRequest) ProtoMessage() {} -func (*QuerySigningInfosRequest) Descriptor() ([]byte, []int) { +func (m *QueryVotesAtHeightResponse) Reset() { *m = QueryVotesAtHeightResponse{} } +func (m *QueryVotesAtHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesAtHeightResponse) ProtoMessage() {} +func (*QueryVotesAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{21} } -func (m *QuerySigningInfosRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryVotesAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfosRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryVotesAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1215,45 +1233,101 @@ func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QuerySigningInfosRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfosRequest.Merge(m, src) +func (m *QueryVotesAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesAtHeightResponse.Merge(m, src) } -func (m *QuerySigningInfosRequest) XXX_Size() int { +func (m *QueryVotesAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfosRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfosRequest.DiscardUnknown(m) +func (m *QueryVotesAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfosRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryVotesAtHeightResponse proto.InternalMessageInfo -func (m *QuerySigningInfosRequest) GetPagination() *query.PageRequest { +// QueryEvidenceRequest is the request type for the +// Query/Evidence RPC method. +type QueryEvidenceRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + // (in BIP340 format) of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +} + +func (m *QueryEvidenceRequest) Reset() { *m = QueryEvidenceRequest{} } +func (m *QueryEvidenceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceRequest) ProtoMessage() {} +func (*QueryEvidenceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{22} +} +func (m *QueryEvidenceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceRequest.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 *QueryEvidenceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceRequest.Merge(m, src) +} +func (m *QueryEvidenceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceRequest proto.InternalMessageInfo + +func (m *QueryEvidenceRequest) GetFpBtcPkHex() string { if m != nil { - return m.Pagination + return m.FpBtcPkHex } - return nil + return "" } -// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC -// method -type QuerySigningInfosResponse struct { - // info is the signing info of all finality providers with signing info - SigningInfos []SigningInfoResponse `protobuf:"bytes,1,rep,name=signing_infos,json=signingInfos,proto3" json:"signing_infos"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// Evidence is the evidence that a finality provider has signed finality +// signatures with correct public randomness on two conflicting Babylon headers +type EvidenceResponse struct { + // fp_btc_pk_hex is the BTC PK of the finality provider that casts this vote + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // block_height is the height of the conflicting blocks + BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // pub_rand is the public randomness the finality provider has committed to + PubRand *github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,3,opt,name=pub_rand,json=pubRand,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand,omitempty"` + // canonical_app_hash is the AppHash of the canonical block + CanonicalAppHash []byte `protobuf:"bytes,4,opt,name=canonical_app_hash,json=canonicalAppHash,proto3" json:"canonical_app_hash,omitempty"` + // fork_app_hash is the AppHash of the fork block + ForkAppHash []byte `protobuf:"bytes,5,opt,name=fork_app_hash,json=forkAppHash,proto3" json:"fork_app_hash,omitempty"` + // canonical_finality_sig is the finality signature to the canonical block + // where finality signature is an EOTS signature, i.e., + // the `s` in a Schnorr signature `(r, s)` + // `r` is the public randomness that is already committed by the finality provider + CanonicalFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,6,opt,name=canonical_finality_sig,json=canonicalFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"canonical_finality_sig,omitempty"` + // fork_finality_sig is the finality signature to the fork block + // where finality signature is an EOTS signature + ForkFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,7,opt,name=fork_finality_sig,json=forkFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"fork_finality_sig,omitempty"` } -func (m *QuerySigningInfosResponse) Reset() { *m = QuerySigningInfosResponse{} } -func (m *QuerySigningInfosResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfosResponse) ProtoMessage() {} -func (*QuerySigningInfosResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_32bddab77af6fdae, []int{22} +func (m *EvidenceResponse) Reset() { *m = EvidenceResponse{} } +func (m *EvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*EvidenceResponse) ProtoMessage() {} +func (*EvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{23} } -func (m *QuerySigningInfosResponse) XXX_Unmarshal(b []byte) error { +func (m *EvidenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfosResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_EvidenceResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1263,1050 +1337,1226 @@ func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QuerySigningInfosResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfosResponse.Merge(m, src) +func (m *EvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EvidenceResponse.Merge(m, src) } -func (m *QuerySigningInfosResponse) XXX_Size() int { +func (m *EvidenceResponse) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfosResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfosResponse.DiscardUnknown(m) +func (m *EvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EvidenceResponse.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfosResponse proto.InternalMessageInfo +var xxx_messageInfo_EvidenceResponse proto.InternalMessageInfo -func (m *QuerySigningInfosResponse) GetSigningInfos() []SigningInfoResponse { +func (m *EvidenceResponse) GetFpBtcPkHex() string { if m != nil { - return m.SigningInfos + return m.FpBtcPkHex } - return nil + return "" } -func (m *QuerySigningInfosResponse) GetPagination() *query.PageResponse { +func (m *EvidenceResponse) GetBlockHeight() uint64 { if m != nil { - return m.Pagination + return m.BlockHeight + } + return 0 +} + +func (m *EvidenceResponse) GetCanonicalAppHash() []byte { + if m != nil { + return m.CanonicalAppHash } return nil } -func init() { - proto.RegisterEnum("babylon.finality.v1.QueriedBlockStatus", QueriedBlockStatus_name, QueriedBlockStatus_value) - proto.RegisterType((*QueryParamsRequest)(nil), "babylon.finality.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "babylon.finality.v1.QueryParamsResponse") - proto.RegisterType((*QueryListPublicRandomnessRequest)(nil), "babylon.finality.v1.QueryListPublicRandomnessRequest") - proto.RegisterType((*QueryListPublicRandomnessResponse)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse") - proto.RegisterMapType((map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse.PubRandMapEntry") - proto.RegisterType((*PubRandCommitResponse)(nil), "babylon.finality.v1.PubRandCommitResponse") - proto.RegisterType((*QueryListPubRandCommitRequest)(nil), "babylon.finality.v1.QueryListPubRandCommitRequest") - proto.RegisterType((*QueryListPubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse") - proto.RegisterMapType((map[uint64]*PubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse.PubRandCommitMapEntry") - proto.RegisterType((*QueryBlockRequest)(nil), "babylon.finality.v1.QueryBlockRequest") - proto.RegisterType((*QueryBlockResponse)(nil), "babylon.finality.v1.QueryBlockResponse") - proto.RegisterType((*QueryListBlocksRequest)(nil), "babylon.finality.v1.QueryListBlocksRequest") - proto.RegisterType((*QueryListBlocksResponse)(nil), "babylon.finality.v1.QueryListBlocksResponse") - proto.RegisterType((*QueryVotesAtHeightRequest)(nil), "babylon.finality.v1.QueryVotesAtHeightRequest") - proto.RegisterType((*QueryVotesAtHeightResponse)(nil), "babylon.finality.v1.QueryVotesAtHeightResponse") - proto.RegisterType((*QueryEvidenceRequest)(nil), "babylon.finality.v1.QueryEvidenceRequest") - proto.RegisterType((*EvidenceResponse)(nil), "babylon.finality.v1.EvidenceResponse") - proto.RegisterType((*QueryEvidenceResponse)(nil), "babylon.finality.v1.QueryEvidenceResponse") - proto.RegisterType((*QueryListEvidencesRequest)(nil), "babylon.finality.v1.QueryListEvidencesRequest") - proto.RegisterType((*QueryListEvidencesResponse)(nil), "babylon.finality.v1.QueryListEvidencesResponse") - proto.RegisterType((*QuerySigningInfoRequest)(nil), "babylon.finality.v1.QuerySigningInfoRequest") - proto.RegisterType((*SigningInfoResponse)(nil), "babylon.finality.v1.SigningInfoResponse") - proto.RegisterType((*QuerySigningInfoResponse)(nil), "babylon.finality.v1.QuerySigningInfoResponse") - proto.RegisterType((*QuerySigningInfosRequest)(nil), "babylon.finality.v1.QuerySigningInfosRequest") - proto.RegisterType((*QuerySigningInfosResponse)(nil), "babylon.finality.v1.QuerySigningInfosResponse") +func (m *EvidenceResponse) GetForkAppHash() []byte { + if m != nil { + return m.ForkAppHash + } + return nil } -func init() { proto.RegisterFile("babylon/finality/v1/query.proto", fileDescriptor_32bddab77af6fdae) } - -var fileDescriptor_32bddab77af6fdae = []byte{ - // 1589 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xdd, 0x6f, 0xd3, 0x56, - 0x14, 0xef, 0x6d, 0xe9, 0xd7, 0x49, 0x32, 0xda, 0xdb, 0xc2, 0xba, 0x30, 0xd2, 0xd6, 0x40, 0xe9, - 0x0a, 0xd8, 0x6b, 0xca, 0x18, 0xa0, 0x4d, 0xd0, 0xb0, 0x76, 0xad, 0x56, 0x4a, 0x70, 0x01, 0x69, - 0xbc, 0x58, 0x76, 0xea, 0x24, 0x5e, 0x63, 0x5f, 0x13, 0xdb, 0x55, 0x2b, 0x84, 0x34, 0x4d, 0x1a, - 0x0f, 0xd3, 0x26, 0x21, 0xed, 0x65, 0x7b, 0xe0, 0x61, 0xd2, 0x34, 0x4d, 0xdb, 0xcb, 0x5e, 0xf7, - 0x1f, 0xf0, 0x88, 0xd8, 0x1e, 0x26, 0x26, 0xd8, 0x04, 0x93, 0xf6, 0x6f, 0x4c, 0xbe, 0xf7, 0x3a, - 0xb1, 0x53, 0xe7, 0xa3, 0xa5, 0xda, 0x4b, 0x14, 0x5f, 0x9f, 0x8f, 0xdf, 0x39, 0xf7, 0xdc, 0x9f, - 0x7f, 0x17, 0xc6, 0x35, 0x55, 0xdb, 0xae, 0x10, 0x4b, 0x2a, 0x1a, 0x96, 0x5a, 0x31, 0xdc, 0x6d, - 0x69, 0x73, 0x56, 0xba, 0xe3, 0xe9, 0xd5, 0x6d, 0xd1, 0xae, 0x12, 0x97, 0xe0, 0x11, 0x6e, 0x20, - 0x06, 0x06, 0xe2, 0xe6, 0x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xcf, - 0x08, 0x06, 0x82, 0x0f, 0x2a, 0x7e, 0xab, 0x79, 0xaa, 0x06, 0xc9, 0x9a, 0x9e, 0xe9, 0xc4, 0x94, - 0x03, 0x5a, 0xa2, 0x80, 0x72, 0xf8, 0xf2, 0x5e, 0x27, 0x2e, 0xf8, 0xbe, 0xe3, 0x6f, 0x10, 0xa4, - 0x22, 0xea, 0xa1, 0x55, 0x37, 0xe3, 0xf4, 0x4e, 0xab, 0x6e, 0xc6, 0xca, 0x12, 0x61, 0x8a, 0x82, - 0x9f, 0xc0, 0x99, 0x58, 0xf0, 0x75, 0xe5, 0xf1, 0x03, 0x82, 0x44, 0x88, 0xf8, 0x71, 0x8b, 0x59, - 0xda, 0xa9, 0x29, 0xd2, 0x67, 0x3a, 0xb4, 0xe6, 0xa0, 0x2e, 0x52, 0x50, 0x67, 0x71, 0x36, 0x16, - 0x54, 0xe4, 0x4b, 0xd5, 0xd8, 0x4c, 0xfc, 0x2d, 0x82, 0x64, 0xf8, 0x1b, 0x87, 0x3b, 0xcb, 0x5d, - 0xeb, 0xa0, 0xd8, 0xa9, 0x39, 0xc7, 0x3a, 0x43, 0xb1, 0x1e, 0xc7, 0x42, 0x7b, 0xac, 0xb9, 0x95, - 0x47, 0x2f, 0x32, 0xe8, 0xf1, 0x8b, 0x0c, 0xfa, 0xfb, 0x45, 0x06, 0x3d, 0x78, 0x99, 0xe9, 0x7a, - 0xfc, 0x32, 0xd3, 0xf5, 0xc7, 0xcb, 0x4c, 0xd7, 0xed, 0x6c, 0x7b, 0xa9, 0xbd, 0x55, 0x0f, 0x4c, - 0x55, 0xb7, 0xd6, 0x47, 0x55, 0xcd, 0xdc, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xb4, 0xbe, - 0x11, 0x96, 0x15, 0x00, 0x00, +// QueryEvidenceResponse is the response type for the +// Query/Evidence RPC method. +type QueryEvidenceResponse struct { + Evidence *EvidenceResponse `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +func (m *QueryEvidenceResponse) Reset() { *m = QueryEvidenceResponse{} } +func (m *QueryEvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceResponse) ProtoMessage() {} +func (*QueryEvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{24} +} +func (m *QueryEvidenceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceResponse.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 *QueryEvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceResponse.Merge(m, src) +} +func (m *QueryEvidenceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceResponse.DiscardUnknown(m) +} -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +var xxx_messageInfo_QueryEvidenceResponse proto.InternalMessageInfo -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ListPublicRandomness is a range query for public randomness of a given finality provider - // NOTE: Babylon only has the knowledge of public randomness that is already revealed by - // finality providers, i.e., the finality provider already provides a finality signature - // at the corresponding height - // TODO: remove public randomness storage? - ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) - // ListPubRandCommit is a range query for public randomness commitments of a given finality provider - ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) - // Block queries a block at a given height - Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) - // ListBlocks is a range query for blocks at a given status - ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) - // VotesAtHeight queries finality providers who have signed the block at given height. - VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) - // Evidence queries the first evidence which can be used for extracting the BTC SK - Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) - // ListEvidences queries is a range query for evidences - ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) - // SigningInfo queries the signing info of given finality provider BTC public key - SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) - // SigningInfos queries the signing info of all the active finality providers - SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) +func (m *QueryEvidenceResponse) GetEvidence() *EvidenceResponse { + if m != nil { + return m.Evidence + } + return nil } -type queryClient struct { - cc grpc1.ClientConn +// QueryListEvidencesRequest is the request type for the +// Query/ListEvidences RPC method. +type QueryListEvidencesRequest struct { + // start_height is the starting height that the querier specifies + // such that the RPC will only return evidences since this height + StartHeight uint64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} +func (m *QueryListEvidencesRequest) Reset() { *m = QueryListEvidencesRequest{} } +func (m *QueryListEvidencesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListEvidencesRequest) ProtoMessage() {} +func (*QueryListEvidencesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{25} } - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *QueryListEvidencesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (c *queryClient) ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) { - out := new(QueryListPublicRandomnessResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPublicRandomness", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEvidencesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *QueryListEvidencesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEvidencesRequest.Merge(m, src) +} +func (m *QueryListEvidencesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListEvidencesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEvidencesRequest.DiscardUnknown(m) } -func (c *queryClient) ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) { - out := new(QueryListPubRandCommitResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPubRandCommit", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryListEvidencesRequest proto.InternalMessageInfo + +func (m *QueryListEvidencesRequest) GetStartHeight() uint64 { + if m != nil { + return m.StartHeight } - return out, nil + return 0 } -func (c *queryClient) Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) { - out := new(QueryBlockResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Block", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryListEvidencesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return out, nil + return nil } -func (c *queryClient) ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) { - out := new(QueryListBlocksResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListBlocks", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QueryListEvidencesResponse is the response type for the +// Query/ListEvidences RPC method. +type QueryListEvidencesResponse struct { + // blocks is the list of evidences + Evidences []*EvidenceResponse `protobuf:"bytes,1,rep,name=evidences,proto3" json:"evidences,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (c *queryClient) VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) { - out := new(QueryVotesAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/VotesAtHeight", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryListEvidencesResponse) Reset() { *m = QueryListEvidencesResponse{} } +func (m *QueryListEvidencesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListEvidencesResponse) ProtoMessage() {} +func (*QueryListEvidencesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{26} +} +func (m *QueryListEvidencesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEvidencesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *QueryListEvidencesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEvidencesResponse.Merge(m, src) +} +func (m *QueryListEvidencesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListEvidencesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEvidencesResponse.DiscardUnknown(m) } -func (c *queryClient) Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) { - out := new(QueryEvidenceResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Evidence", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryListEvidencesResponse proto.InternalMessageInfo + +func (m *QueryListEvidencesResponse) GetEvidences() []*EvidenceResponse { + if m != nil { + return m.Evidences } - return out, nil + return nil } -func (c *queryClient) ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) { - out := new(QueryListEvidencesResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListEvidences", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryListEvidencesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return out, nil + return nil } -func (c *queryClient) SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) { - out := new(QuerySigningInfoResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC +// method +type QuerySigningInfoRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + // (in BIP340 format) of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` } -func (c *queryClient) SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) { - out := new(QuerySigningInfosResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfos", in, out, opts...) - if err != nil { - return nil, err +func (m *QuerySigningInfoRequest) Reset() { *m = QuerySigningInfoRequest{} } +func (m *QuerySigningInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfoRequest) ProtoMessage() {} +func (*QuerySigningInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{27} +} +func (m *QuerySigningInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfoRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil } - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ListPublicRandomness is a range query for public randomness of a given finality provider - // NOTE: Babylon only has the knowledge of public randomness that is already revealed by - // finality providers, i.e., the finality provider already provides a finality signature - // at the corresponding height - // TODO: remove public randomness storage? - ListPublicRandomness(context.Context, *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) - // ListPubRandCommit is a range query for public randomness commitments of a given finality provider - ListPubRandCommit(context.Context, *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) - // Block queries a block at a given height - Block(context.Context, *QueryBlockRequest) (*QueryBlockResponse, error) - // ListBlocks is a range query for blocks at a given status - ListBlocks(context.Context, *QueryListBlocksRequest) (*QueryListBlocksResponse, error) - // VotesAtHeight queries finality providers who have signed the block at given height. - VotesAtHeight(context.Context, *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) - // Evidence queries the first evidence which can be used for extracting the BTC SK - Evidence(context.Context, *QueryEvidenceRequest) (*QueryEvidenceResponse, error) - // ListEvidences queries is a range query for evidences - ListEvidences(context.Context, *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) - // SigningInfo queries the signing info of given finality provider BTC public key - SigningInfo(context.Context, *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) - // SigningInfos queries the signing info of all the active finality providers - SigningInfos(context.Context, *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { +func (m *QuerySigningInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfoRequest.Merge(m, src) } - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +func (m *QuerySigningInfoRequest) XXX_Size() int { + return m.Size() } -func (*UnimplementedQueryServer) ListPublicRandomness(ctx context.Context, req *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPublicRandomness not implemented") +func (m *QuerySigningInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfoRequest.DiscardUnknown(m) } -func (*UnimplementedQueryServer) ListPubRandCommit(ctx context.Context, req *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPubRandCommit not implemented") + +var xxx_messageInfo_QuerySigningInfoRequest proto.InternalMessageInfo + +func (m *QuerySigningInfoRequest) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex + } + return "" } -func (*UnimplementedQueryServer) Block(ctx context.Context, req *QueryBlockRequest) (*QueryBlockResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Block not implemented") + +// SigningInfoResponse defines the API response containing a finality provider's signing info +// for monitoring their liveness activity. +type SigningInfoResponse struct { + // fp_btc_pk is the BTC PK of the finality provider that casts this vote + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // start_height is the block height at which finality provider become active + StartHeight int64 `protobuf:"varint,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // missed_blocks_counter defines a counter to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + MissedBlocksCounter int64 `protobuf:"varint,3,opt,name=missed_blocks_counter,json=missedBlocksCounter,proto3" json:"missed_blocks_counter,omitempty"` + // Timestamp until which the validator is jailed due to liveness downtime. + JailedUntil time.Time `protobuf:"bytes,4,opt,name=jailed_until,json=jailedUntil,proto3,stdtime" json:"jailed_until"` } -func (*UnimplementedQueryServer) ListBlocks(ctx context.Context, req *QueryListBlocksRequest) (*QueryListBlocksResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListBlocks not implemented") + +func (m *SigningInfoResponse) Reset() { *m = SigningInfoResponse{} } +func (m *SigningInfoResponse) String() string { return proto.CompactTextString(m) } +func (*SigningInfoResponse) ProtoMessage() {} +func (*SigningInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{28} } -func (*UnimplementedQueryServer) VotesAtHeight(ctx context.Context, req *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VotesAtHeight not implemented") +func (m *SigningInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedQueryServer) Evidence(ctx context.Context, req *QueryEvidenceRequest) (*QueryEvidenceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Evidence not implemented") +func (m *SigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SigningInfoResponse.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 (*UnimplementedQueryServer) ListEvidences(ctx context.Context, req *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListEvidences not implemented") +func (m *SigningInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SigningInfoResponse.Merge(m, src) } -func (*UnimplementedQueryServer) SigningInfo(ctx context.Context, req *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SigningInfo not implemented") +func (m *SigningInfoResponse) XXX_Size() int { + return m.Size() } -func (*UnimplementedQueryServer) SigningInfos(ctx context.Context, req *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SigningInfos not implemented") +func (m *SigningInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SigningInfoResponse.DiscardUnknown(m) } -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} +var xxx_messageInfo_SigningInfoResponse proto.InternalMessageInfo -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) +func (m *SigningInfoResponse) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex } - return interceptor(ctx, in, info, handler) + return "" } -func _Query_ListPublicRandomness_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListPublicRandomnessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListPublicRandomness(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListPublicRandomness", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListPublicRandomness(ctx, req.(*QueryListPublicRandomnessRequest)) +func (m *SigningInfoResponse) GetStartHeight() int64 { + if m != nil { + return m.StartHeight } - return interceptor(ctx, in, info, handler) + return 0 } -func _Query_ListPubRandCommit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListPubRandCommitRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListPubRandCommit(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListPubRandCommit", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListPubRandCommit(ctx, req.(*QueryListPubRandCommitRequest)) +func (m *SigningInfoResponse) GetMissedBlocksCounter() int64 { + if m != nil { + return m.MissedBlocksCounter } - return interceptor(ctx, in, info, handler) + return 0 } -func _Query_Block_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBlockRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Block(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Block", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Block(ctx, req.(*QueryBlockRequest)) +func (m *SigningInfoResponse) GetJailedUntil() time.Time { + if m != nil { + return m.JailedUntil } - return interceptor(ctx, in, info, handler) + return time.Time{} } -func _Query_ListBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListBlocksRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListBlocks(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListBlocks", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListBlocks(ctx, req.(*QueryListBlocksRequest)) - } - return interceptor(ctx, in, info, handler) +// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC +// method +type QuerySigningInfoResponse struct { + SigningInfo SigningInfoResponse `protobuf:"bytes,1,opt,name=signing_info,json=signingInfo,proto3" json:"signing_info"` } -func _Query_VotesAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesAtHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesAtHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/VotesAtHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesAtHeight(ctx, req.(*QueryVotesAtHeightRequest)) +func (m *QuerySigningInfoResponse) Reset() { *m = QuerySigningInfoResponse{} } +func (m *QuerySigningInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfoResponse) ProtoMessage() {} +func (*QuerySigningInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{29} +} +func (m *QuerySigningInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfoResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QuerySigningInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfoResponse.Merge(m, src) +} +func (m *QuerySigningInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfoResponse.DiscardUnknown(m) } -func _Query_Evidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryEvidenceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Evidence(ctx, in) +var xxx_messageInfo_QuerySigningInfoResponse proto.InternalMessageInfo + +func (m *QuerySigningInfoResponse) GetSigningInfo() SigningInfoResponse { + if m != nil { + return m.SigningInfo } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Evidence", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Evidence(ctx, req.(*QueryEvidenceRequest)) - } - return interceptor(ctx, in, info, handler) + return SigningInfoResponse{} } -func _Query_ListEvidences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListEvidencesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListEvidences(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListEvidences", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListEvidences(ctx, req.(*QueryListEvidencesRequest)) - } - return interceptor(ctx, in, info, handler) +// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC +// method +type QuerySigningInfosRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func _Query_SigningInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySigningInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).SigningInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/SigningInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).SigningInfo(ctx, req.(*QuerySigningInfoRequest)) - } - return interceptor(ctx, in, info, handler) +func (m *QuerySigningInfosRequest) Reset() { *m = QuerySigningInfosRequest{} } +func (m *QuerySigningInfosRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfosRequest) ProtoMessage() {} +func (*QuerySigningInfosRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{30} } - -func _Query_SigningInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySigningInfosRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).SigningInfos(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/SigningInfos", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).SigningInfos(ctx, req.(*QuerySigningInfosRequest)) +func (m *QuerySigningInfosRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfosRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) } - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "babylon.finality.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "ListPublicRandomness", - Handler: _Query_ListPublicRandomness_Handler, - }, - { - MethodName: "ListPubRandCommit", - Handler: _Query_ListPubRandCommit_Handler, - }, - { - MethodName: "Block", - Handler: _Query_Block_Handler, - }, - { - MethodName: "ListBlocks", - Handler: _Query_ListBlocks_Handler, - }, - { - MethodName: "VotesAtHeight", - Handler: _Query_VotesAtHeight_Handler, - }, - { - MethodName: "Evidence", - Handler: _Query_Evidence_Handler, - }, - { - MethodName: "ListEvidences", - Handler: _Query_ListEvidences_Handler, - }, - { - MethodName: "SigningInfo", - Handler: _Query_SigningInfo_Handler, - }, - { - MethodName: "SigningInfos", - Handler: _Query_SigningInfos_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "babylon/finality/v1/query.proto", +func (m *QuerySigningInfosRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfosRequest.Merge(m, src) } - -func (m *QueryParamsRequest) 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 *QuerySigningInfosRequest) XXX_Size() int { + return m.Size() } - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QuerySigningInfosRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfosRequest.DiscardUnknown(m) } -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} +var xxx_messageInfo_QuerySigningInfosRequest proto.InternalMessageInfo -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QuerySigningInfosRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC +// method +type QuerySigningInfosResponse struct { + // info is the signing info of all finality providers with signing info + SigningInfos []SigningInfoResponse `protobuf:"bytes,1,rep,name=signing_infos,json=signingInfos,proto3" json:"signing_infos"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) +func (m *QuerySigningInfosResponse) Reset() { *m = QuerySigningInfosResponse{} } +func (m *QuerySigningInfosResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfosResponse) ProtoMessage() {} +func (*QuerySigningInfosResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{31} +} +func (m *QuerySigningInfosResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfosResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) if err != nil { - return 0, err + return nil, err } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil } - -func (m *QueryListPublicRandomnessRequest) 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 *QuerySigningInfosResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfosResponse.Merge(m, src) } - -func (m *QueryListPublicRandomnessRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QuerySigningInfosResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfosResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfosResponse.DiscardUnknown(m) } -func (m *QueryListPublicRandomnessRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +var xxx_messageInfo_QuerySigningInfosResponse proto.InternalMessageInfo + +func (m *QuerySigningInfosResponse) GetSigningInfos() []SigningInfoResponse { + if m != nil { + return m.SigningInfos } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa + return nil +} + +func (m *QuerySigningInfosResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return len(dAtA) - i, nil + return nil } -func (m *QueryListPublicRandomnessResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func init() { + proto.RegisterEnum("babylon.finality.v1.QueriedBlockStatus", QueriedBlockStatus_name, QueriedBlockStatus_value) + proto.RegisterType((*QueryParamsRequest)(nil), "babylon.finality.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "babylon.finality.v1.QueryParamsResponse") + proto.RegisterType((*QueryFinalityProviderPowerAtHeightRequest)(nil), "babylon.finality.v1.QueryFinalityProviderPowerAtHeightRequest") + proto.RegisterType((*QueryFinalityProviderPowerAtHeightResponse)(nil), "babylon.finality.v1.QueryFinalityProviderPowerAtHeightResponse") + proto.RegisterType((*QueryFinalityProviderCurrentPowerRequest)(nil), "babylon.finality.v1.QueryFinalityProviderCurrentPowerRequest") + proto.RegisterType((*QueryFinalityProviderCurrentPowerResponse)(nil), "babylon.finality.v1.QueryFinalityProviderCurrentPowerResponse") + proto.RegisterType((*QueryActiveFinalityProvidersAtHeightRequest)(nil), "babylon.finality.v1.QueryActiveFinalityProvidersAtHeightRequest") + proto.RegisterType((*ActiveFinalityProvidersAtHeightResponse)(nil), "babylon.finality.v1.ActiveFinalityProvidersAtHeightResponse") + proto.RegisterType((*QueryActiveFinalityProvidersAtHeightResponse)(nil), "babylon.finality.v1.QueryActiveFinalityProvidersAtHeightResponse") + proto.RegisterType((*QueryActivatedHeightRequest)(nil), "babylon.finality.v1.QueryActivatedHeightRequest") + proto.RegisterType((*QueryActivatedHeightResponse)(nil), "babylon.finality.v1.QueryActivatedHeightResponse") + proto.RegisterType((*QueryListPublicRandomnessRequest)(nil), "babylon.finality.v1.QueryListPublicRandomnessRequest") + proto.RegisterType((*QueryListPublicRandomnessResponse)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse") + proto.RegisterMapType((map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse.PubRandMapEntry") + proto.RegisterType((*PubRandCommitResponse)(nil), "babylon.finality.v1.PubRandCommitResponse") + proto.RegisterType((*QueryListPubRandCommitRequest)(nil), "babylon.finality.v1.QueryListPubRandCommitRequest") + proto.RegisterType((*QueryListPubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse") + proto.RegisterMapType((map[uint64]*PubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse.PubRandCommitMapEntry") + proto.RegisterType((*QueryBlockRequest)(nil), "babylon.finality.v1.QueryBlockRequest") + proto.RegisterType((*QueryBlockResponse)(nil), "babylon.finality.v1.QueryBlockResponse") + proto.RegisterType((*QueryListBlocksRequest)(nil), "babylon.finality.v1.QueryListBlocksRequest") + proto.RegisterType((*QueryListBlocksResponse)(nil), "babylon.finality.v1.QueryListBlocksResponse") + proto.RegisterType((*QueryVotesAtHeightRequest)(nil), "babylon.finality.v1.QueryVotesAtHeightRequest") + proto.RegisterType((*QueryVotesAtHeightResponse)(nil), "babylon.finality.v1.QueryVotesAtHeightResponse") + proto.RegisterType((*QueryEvidenceRequest)(nil), "babylon.finality.v1.QueryEvidenceRequest") + proto.RegisterType((*EvidenceResponse)(nil), "babylon.finality.v1.EvidenceResponse") + proto.RegisterType((*QueryEvidenceResponse)(nil), "babylon.finality.v1.QueryEvidenceResponse") + proto.RegisterType((*QueryListEvidencesRequest)(nil), "babylon.finality.v1.QueryListEvidencesRequest") + proto.RegisterType((*QueryListEvidencesResponse)(nil), "babylon.finality.v1.QueryListEvidencesResponse") + proto.RegisterType((*QuerySigningInfoRequest)(nil), "babylon.finality.v1.QuerySigningInfoRequest") + proto.RegisterType((*SigningInfoResponse)(nil), "babylon.finality.v1.SigningInfoResponse") + proto.RegisterType((*QuerySigningInfoResponse)(nil), "babylon.finality.v1.QuerySigningInfoResponse") + proto.RegisterType((*QuerySigningInfosRequest)(nil), "babylon.finality.v1.QuerySigningInfosRequest") + proto.RegisterType((*QuerySigningInfosResponse)(nil), "babylon.finality.v1.QuerySigningInfosResponse") +} + +func init() { proto.RegisterFile("babylon/finality/v1/query.proto", fileDescriptor_32bddab77af6fdae) } + +var fileDescriptor_32bddab77af6fdae = []byte{ + // 1950 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0xdb, 0xd8, + 0x11, 0xf7, 0xb3, 0x63, 0xc7, 0x19, 0x49, 0x8d, 0xfd, 0xec, 0xb8, 0xae, 0x92, 0xc8, 0x32, 0x77, + 0x13, 0x7b, 0x9d, 0x84, 0x8c, 0x95, 0x34, 0xcd, 0x06, 0x9b, 0x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54, 0xa4, 0x1d, 0xec, 0x76, 0x26, 0xfd, 0x35, + 0x81, 0x74, 0x67, 0x23, 0x49, 0x93, 0xe9, 0x6e, 0x7b, 0x50, 0x4c, 0x4a, 0x8e, 0x58, 0x57, 0x18, + 0xd6, 0xb7, 0xa9, 0x30, 0x1c, 0x6b, 0x71, 0xfb, 0xf3, 0x57, 0x39, 0xf2, 0xc5, 0xab, 0x1c, 0x79, + 0xf9, 0x2a, 0x47, 0x3e, 0x7d, 0x9d, 0x1b, 0xf9, 0xe2, 0x75, 0x6e, 0xe4, 0x1f, 0xaf, 0x73, 0x23, + 0xcf, 0x0b, 0xc3, 0xe7, 0xd9, 0x83, 0x50, 0x30, 0x1b, 0x6d, 0xcb, 0x13, 0x6c, 0x74, 0xb8, 0xf5, + 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x4d, 0x5d, 0x1d, 0x74, 0x1d, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) + // ListPublicRandomness is a range query for public randomness of a given finality provider + // NOTE: Babylon only has the knowledge of public randomness that is already revealed by + // finality providers, i.e., the finality provider already provides a finality signature + // at the corresponding height + ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) + // ListPubRandCommit is a range query for public randomness commitments of a given finality provider + ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) + // Block queries a block at a given height + Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) + // ListBlocks is a range query for blocks at a given status + ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) + // VotesAtHeight queries finality providers who have signed the block at given height. + VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) + // Evidence queries the first evidence which can be used for extracting the BTC SK + Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) + // ListEvidences queries is a range query for evidences + ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) + // SigningInfo queries the signing info of given finality provider BTC public key + SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) + // SigningInfos queries the signing info of all the active finality providers + SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Params", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryListPublicRandomnessResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) { + out := new(QueryActiveFinalityProvidersAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ActiveFinalityProvidersAtHeight", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryListPublicRandomnessResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.PubRandMap) > 0 { - for k := range m.PubRandMap { - v := m.PubRandMap[k] - baseI := i - if v != nil { - { - size := v.Size() - i -= size - if _, err := v.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintQuery(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } +func (c *queryClient) FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) { + out := new(QueryFinalityProviderPowerAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/FinalityProviderPowerAtHeight", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *PubRandCommitResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) { + out := new(QueryFinalityProviderCurrentPowerResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/FinalityProviderCurrentPower", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *PubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) { + out := new(QueryActivatedHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ActivatedHeight", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *PubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.EpochNum != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) - i-- - dAtA[i] = 0x18 - } - if len(m.Commitment) > 0 { - i -= len(m.Commitment) - copy(dAtA[i:], m.Commitment) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) - i-- - dAtA[i] = 0x12 - } - if m.NumPubRand != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.NumPubRand)) - i-- - dAtA[i] = 0x8 +func (c *queryClient) ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) { + out := new(QueryListPublicRandomnessResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPublicRandomness", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryListPubRandCommitRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) { + out := new(QueryListPubRandCommitResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPubRandCommit", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryListPubRandCommitRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) { + out := new(QueryBlockResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Block", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryListPubRandCommitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func (c *queryClient) ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) { + out := new(QueryListBlocksResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListBlocks", in, out, opts...) + if err != nil { + return nil, err } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa + return out, nil +} + +func (c *queryClient) VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) { + out := new(QueryVotesAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/VotesAtHeight", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryListPubRandCommitResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) { + out := new(QueryEvidenceResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Evidence", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryListPubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) { + out := new(QueryListEvidencesResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListEvidences", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryListPubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.PubRandCommitMap) > 0 { - for k := range m.PubRandCommitMap { - v := m.PubRandCommitMap[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintQuery(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } +func (c *queryClient) SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) { + out := new(QuerySigningInfoResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfo", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryBlockRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) { + out := new(QuerySigningInfosResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfos", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryBlockRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + ActiveFinalityProvidersAtHeight(context.Context, *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + FinalityProviderPowerAtHeight(context.Context, *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + FinalityProviderCurrentPower(context.Context, *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + ActivatedHeight(context.Context, *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) + // ListPublicRandomness is a range query for public randomness of a given finality provider + // NOTE: Babylon only has the knowledge of public randomness that is already revealed by + // finality providers, i.e., the finality provider already provides a finality signature + // at the corresponding height + ListPublicRandomness(context.Context, *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) + // ListPubRandCommit is a range query for public randomness commitments of a given finality provider + ListPubRandCommit(context.Context, *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) + // Block queries a block at a given height + Block(context.Context, *QueryBlockRequest) (*QueryBlockResponse, error) + // ListBlocks is a range query for blocks at a given status + ListBlocks(context.Context, *QueryListBlocksRequest) (*QueryListBlocksResponse, error) + // VotesAtHeight queries finality providers who have signed the block at given height. + VotesAtHeight(context.Context, *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) + // Evidence queries the first evidence which can be used for extracting the BTC SK + Evidence(context.Context, *QueryEvidenceRequest) (*QueryEvidenceResponse, error) + // ListEvidences queries is a range query for evidences + ListEvidences(context.Context, *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) + // SigningInfo queries the signing info of given finality provider BTC public key + SigningInfo(context.Context, *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) + // SigningInfos queries the signing info of all the active finality providers + SigningInfos(context.Context, *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) } -func (m *QueryBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { } -func (m *QueryBlockResponse) 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 (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } - -func (m *QueryBlockResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (*UnimplementedQueryServer) ActiveFinalityProvidersAtHeight(ctx context.Context, req *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ActiveFinalityProvidersAtHeight not implemented") +} +func (*UnimplementedQueryServer) FinalityProviderPowerAtHeight(ctx context.Context, req *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderPowerAtHeight not implemented") +} +func (*UnimplementedQueryServer) FinalityProviderCurrentPower(ctx context.Context, req *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderCurrentPower not implemented") +} +func (*UnimplementedQueryServer) ActivatedHeight(ctx context.Context, req *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ActivatedHeight not implemented") +} +func (*UnimplementedQueryServer) ListPublicRandomness(ctx context.Context, req *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPublicRandomness not implemented") +} +func (*UnimplementedQueryServer) ListPubRandCommit(ctx context.Context, req *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPubRandCommit not implemented") +} +func (*UnimplementedQueryServer) Block(ctx context.Context, req *QueryBlockRequest) (*QueryBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Block not implemented") +} +func (*UnimplementedQueryServer) ListBlocks(ctx context.Context, req *QueryListBlocksRequest) (*QueryListBlocksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListBlocks not implemented") +} +func (*UnimplementedQueryServer) VotesAtHeight(ctx context.Context, req *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesAtHeight not implemented") +} +func (*UnimplementedQueryServer) Evidence(ctx context.Context, req *QueryEvidenceRequest) (*QueryEvidenceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Evidence not implemented") +} +func (*UnimplementedQueryServer) ListEvidences(ctx context.Context, req *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEvidences not implemented") +} +func (*UnimplementedQueryServer) SigningInfo(ctx context.Context, req *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SigningInfo not implemented") +} +func (*UnimplementedQueryServer) SigningInfos(ctx context.Context, req *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SigningInfos not implemented") } -func (m *QueryBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Block != nil { - { - size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *QueryListBlocksRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListBlocksRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_ActiveFinalityProvidersAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryActiveFinalityProvidersAtHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ActiveFinalityProvidersAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, req.(*QueryActiveFinalityProvidersAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_FinalityProviderPowerAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderPowerAtHeightRequest) + if err := dec(in); err != nil { + return nil, err } - if m.Status != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x8 + if interceptor == nil { + return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/FinalityProviderPowerAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, req.(*QueryFinalityProviderPowerAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListBlocksResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_FinalityProviderCurrentPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderCurrentPowerRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).FinalityProviderCurrentPower(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/FinalityProviderCurrentPower", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviderCurrentPower(ctx, req.(*QueryFinalityProviderCurrentPowerRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListBlocksResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +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 { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ActivatedHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ActivatedHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ActivatedHeight(ctx, req.(*QueryActivatedHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_ListPublicRandomness_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPublicRandomnessRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Blocks) > 0 { - for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Blocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if interceptor == nil { + return srv.(QueryServer).ListPublicRandomness(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListPublicRandomness", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListPublicRandomness(ctx, req.(*QueryListPublicRandomnessRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesAtHeightRequest) Marshal() (dAtA []byte, err error) { +func _Query_ListPubRandCommit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPubRandCommitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListPubRandCommit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListPubRandCommit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListPubRandCommit(ctx, req.(*QueryListPubRandCommitRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Block_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Block(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Block", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Block(ctx, req.(*QueryBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListBlocksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListBlocks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListBlocks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListBlocks(ctx, req.(*QueryListBlocksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VotesAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesAtHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VotesAtHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/VotesAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesAtHeight(ctx, req.(*QueryVotesAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Evidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEvidenceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Evidence(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Evidence", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Evidence(ctx, req.(*QueryEvidenceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListEvidences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListEvidencesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListEvidences(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListEvidences", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListEvidences(ctx, req.(*QueryListEvidencesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_SigningInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySigningInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SigningInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/SigningInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SigningInfo(ctx, req.(*QuerySigningInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_SigningInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySigningInfosRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SigningInfos(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/SigningInfos", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SigningInfos(ctx, req.(*QuerySigningInfosRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "babylon.finality.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "ActiveFinalityProvidersAtHeight", + Handler: _Query_ActiveFinalityProvidersAtHeight_Handler, + }, + { + MethodName: "FinalityProviderPowerAtHeight", + Handler: _Query_FinalityProviderPowerAtHeight_Handler, + }, + { + MethodName: "FinalityProviderCurrentPower", + Handler: _Query_FinalityProviderCurrentPower_Handler, + }, + { + MethodName: "ActivatedHeight", + Handler: _Query_ActivatedHeight_Handler, + }, + { + MethodName: "ListPublicRandomness", + Handler: _Query_ListPublicRandomness_Handler, + }, + { + MethodName: "ListPubRandCommit", + Handler: _Query_ListPubRandCommit_Handler, + }, + { + MethodName: "Block", + Handler: _Query_Block_Handler, + }, + { + MethodName: "ListBlocks", + Handler: _Query_ListBlocks_Handler, + }, + { + MethodName: "VotesAtHeight", + Handler: _Query_VotesAtHeight_Handler, + }, + { + MethodName: "Evidence", + Handler: _Query_Evidence_Handler, + }, + { + MethodName: "ListEvidences", + Handler: _Query_ListEvidences_Handler, + }, + { + MethodName: "SigningInfo", + Handler: _Query_SigningInfo_Handler, + }, + { + MethodName: "SigningInfos", + Handler: _Query_SigningInfos_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "babylon/finality/v1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2316,25 +2566,20 @@ func (m *QueryVotesAtHeightRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryVotesAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryVotesAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } -func (m *QueryVotesAtHeightResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2344,34 +2589,30 @@ func (m *QueryVotesAtHeightResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryVotesAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryVotesAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.BtcPks) > 0 { - for iNdEx := len(m.BtcPks) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.BtcPks[iNdEx].Size() - i -= size - if _, err := m.BtcPks[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QueryEvidenceRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2381,16 +2622,21 @@ func (m *QueryEvidenceRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryEvidenceRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEvidenceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } if len(m.FpBtcPkHex) > 0 { i -= len(m.FpBtcPkHex) copy(dAtA[i:], m.FpBtcPkHex) @@ -2401,7 +2647,7 @@ func (m *QueryEvidenceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EvidenceResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2411,71 +2657,44 @@ func (m *EvidenceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EvidenceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.ForkFinalitySig != nil { - { - size := m.ForkFinalitySig.Size() - i -= size - if _, err := m.ForkFinalitySig.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - if m.CanonicalFinalitySig != nil { - { - size := m.CanonicalFinalitySig.Size() - i -= size - if _, err := m.CanonicalFinalitySig.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - if len(m.ForkAppHash) > 0 { - i -= len(m.ForkAppHash) - copy(dAtA[i:], m.ForkAppHash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ForkAppHash))) - i-- - dAtA[i] = 0x2a - } - if len(m.CanonicalAppHash) > 0 { - i -= len(m.CanonicalAppHash) - copy(dAtA[i:], m.CanonicalAppHash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.CanonicalAppHash))) - i-- - dAtA[i] = 0x22 - } - if m.PubRand != nil { - { - size := m.PubRand.Size() - i -= size - if _, err := m.PubRand.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x8 } - if m.BlockHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x10 + return len(dAtA) - i, nil +} + +func (m *QueryFinalityProviderCurrentPowerRequest) 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 *QueryFinalityProviderCurrentPowerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFinalityProviderCurrentPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if len(m.FpBtcPkHex) > 0 { i -= len(m.FpBtcPkHex) copy(dAtA[i:], m.FpBtcPkHex) @@ -2486,7 +2705,7 @@ func (m *EvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryEvidenceResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderCurrentPowerResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2496,32 +2715,30 @@ func (m *QueryEvidenceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderCurrentPowerResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderCurrentPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Evidence != nil { - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) i-- - dAtA[i] = 0xa + 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 *QueryListEvidencesRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2531,12 +2748,12 @@ func (m *QueryListEvidencesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListEvidencesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListEvidencesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2553,15 +2770,15 @@ func (m *QueryListEvidencesRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro i-- dAtA[i] = 0x12 } - if m.StartHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QueryListEvidencesResponse) Marshal() (dAtA []byte, err error) { +func (m *ActiveFinalityProvidersAtHeightResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2571,12 +2788,77 @@ func (m *QueryListEvidencesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListEvidencesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *ActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.SlashedBtcHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) + i-- + dAtA[i] = 0x28 + } + if m.SlashedBabylonHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) + i-- + dAtA[i] = 0x20 + } + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x18 + } + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if m.BtcPkHex != nil { + { + size := m.BtcPkHex.Size() + i -= size + if _, err := m.BtcPkHex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) 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 *QueryActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2593,10 +2875,10 @@ func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x12 } - if len(m.Evidences) > 0 { - for iNdEx := len(m.Evidences) - 1; iNdEx >= 0; iNdEx-- { + if len(m.FinalityProviders) > 0 { + for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Evidences[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2610,7 +2892,7 @@ func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QuerySigningInfoRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryActivatedHeightRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2620,27 +2902,20 @@ func (m *QuerySigningInfoRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfoRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryActivatedHeightRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryActivatedHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *SigningInfoResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryActivatedHeightResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2650,45 +2925,25 @@ func (m *SigningInfoResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryActivatedHeightResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryActivatedHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - n13, err13 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.JailedUntil, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil):]) - if err13 != nil { - return 0, err13 - } - i -= n13 - i = encodeVarintQuery(dAtA, i, uint64(n13)) - i-- - dAtA[i] = 0x22 - if m.MissedBlocksCounter != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.MissedBlocksCounter)) - i-- - dAtA[i] = 0x18 - } - if m.StartHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) - i-- - dAtA[i] = 0x10 - } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QuerySigningInfoResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryListPublicRandomnessRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2698,30 +2953,39 @@ func (m *QuerySigningInfoResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListPublicRandomnessRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListPublicRandomnessRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.SigningInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QuerySigningInfosRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryListPublicRandomnessResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2731,12 +2995,12 @@ func (m *QuerySigningInfosRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfosRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListPublicRandomnessResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListPublicRandomnessResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2751,12 +3015,36 @@ func (m *QuerySigningInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if len(m.PubRandMap) > 0 { + for k := range m.PubRandMap { + v := m.PubRandMap[k] + baseI := i + if v != nil { + { + size := v.Size() + i -= size + if _, err := v.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintQuery(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } -func (m *QuerySigningInfosResponse) Marshal() (dAtA []byte, err error) { +func (m *PubRandCommitResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2766,12 +3054,52 @@ func (m *QuerySigningInfosResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfosResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *PubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochNum != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) + i-- + dAtA[i] = 0x18 + } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) + i-- + dAtA[i] = 0x12 + } + if m.NumPubRand != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NumPubRand)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListPubRandCommitRequest) 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 *QueryListPubRandCommitRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListPubRandCommitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2788,427 +3116,2150 @@ func (m *QuerySigningInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro i-- dAtA[i] = 0x12 } - if len(m.SigningInfos) > 0 { - for iNdEx := len(m.SigningInfos) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.SigningInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryListPubRandCommitResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *QueryListPubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListPublicRandomnessRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryListPubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryListPublicRandomnessResponse) Size() (n int) { - if m == nil { - return 0 + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - var l int - _ = l - if len(m.PubRandMap) > 0 { - for k, v := range m.PubRandMap { - _ = k - _ = v - l = 0 + if len(m.PubRandCommitMap) > 0 { + for k := range m.PubRandCommitMap { + v := m.PubRandCommitMap[k] + baseI := i if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - mapEntrySize := 1 + sovQuery(uint64(k)) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + i = encodeVarintQuery(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *PubRandCommitResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NumPubRand != 0 { - n += 1 + sovQuery(uint64(m.NumPubRand)) - } - l = len(m.Commitment) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.EpochNum != 0 { - n += 1 + sovQuery(uint64(m.EpochNum)) +func (m *QueryBlockRequest) 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 n + return dAtA[:n], nil } -func (m *QueryListPubRandCommitRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryBlockRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryListPubRandCommitResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryBlockResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - if len(m.PubRandCommitMap) > 0 { - for k, v := range m.PubRandCommitMap { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + sovQuery(uint64(k)) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return dAtA[:n], nil } -func (m *QueryBlockRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - return n +func (m *QueryBlockResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBlockResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Block != nil { - l = m.Block.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryListBlocksRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryListBlocksRequest) 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 *QueryListBlocksRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Status != 0 { - n += 1 + sovQuery(uint64(m.Status)) - } if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *QueryListBlocksResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryListBlocksResponse) 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 *QueryListBlocksResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Blocks) > 0 { - for _, e := range m.Blocks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Blocks) > 0 { + for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Blocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return n + return len(dAtA) - i, nil } -func (m *QueryVotesAtHeightRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryVotesAtHeightRequest) 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 *QueryVotesAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryVotesAtHeightResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryVotesAtHeightResponse) 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 *QueryVotesAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if len(m.BtcPks) > 0 { - for _, e := range m.BtcPks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + for iNdEx := len(m.BtcPks) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.BtcPks[iNdEx].Size() + i -= size + if _, err := m.BtcPks[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } } - return n + return len(dAtA) - i, nil } -func (m *QueryEvidenceRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryEvidenceRequest) 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 *QueryEvidenceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *EvidenceResponse) Size() (n int) { - if m == nil { - return 0 +func (m *EvidenceResponse) 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 *EvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ForkFinalitySig != nil { + { + size := m.ForkFinalitySig.Size() + i -= size + if _, err := m.ForkFinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a } - if m.BlockHeight != 0 { - n += 1 + sovQuery(uint64(m.BlockHeight)) + if m.CanonicalFinalitySig != nil { + { + size := m.CanonicalFinalitySig.Size() + i -= size + if _, err := m.CanonicalFinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 } - if m.PubRand != nil { - l = m.PubRand.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.ForkAppHash) > 0 { + i -= len(m.ForkAppHash) + copy(dAtA[i:], m.ForkAppHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ForkAppHash))) + i-- + dAtA[i] = 0x2a } - l = len(m.CanonicalAppHash) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.CanonicalAppHash) > 0 { + i -= len(m.CanonicalAppHash) + copy(dAtA[i:], m.CanonicalAppHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CanonicalAppHash))) + i-- + dAtA[i] = 0x22 } - l = len(m.ForkAppHash) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.PubRand != nil { + { + size := m.PubRand.Size() + i -= size + if _, err := m.PubRand.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - if m.CanonicalFinalitySig != nil { - l = m.CanonicalFinalitySig.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 } - if m.ForkFinalitySig != nil { - l = m.ForkFinalitySig.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryEvidenceResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryEvidenceResponse) 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 *QueryEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Evidence != nil { - l = m.Evidence.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryListEvidencesRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryListEvidencesRequest) 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 *QueryListEvidencesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEvidencesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if m.StartHeight != 0 { - n += 1 + sovQuery(uint64(m.StartHeight)) + i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListEvidencesResponse) 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 *QueryListEvidencesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.Evidences) > 0 { + for iNdEx := len(m.Evidences) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Evidences[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil } -func (m *QueryListEvidencesResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QuerySigningInfoRequest) 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 *QuerySigningInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Evidences) > 0 { - for _, e := range m.Evidences { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SigningInfoResponse) 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 *SigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n15, err15 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.JailedUntil, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil):]) + if err15 != nil { + return 0, err15 + } + i -= n15 + i = encodeVarintQuery(dAtA, i, uint64(n15)) + i-- + dAtA[i] = 0x22 + if m.MissedBlocksCounter != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.MissedBlocksCounter)) + i-- + dAtA[i] = 0x18 + } + if m.StartHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySigningInfoResponse) 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 *QuerySigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.SigningInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QuerySigningInfosRequest) 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 *QuerySigningInfosRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySigningInfosResponse) 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 *QuerySigningInfosResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SigningInfos) > 0 { + for iNdEx := len(m.SigningInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SigningInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryFinalityProviderPowerAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryFinalityProviderPowerAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + return n +} + +func (m *QueryFinalityProviderCurrentPowerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFinalityProviderCurrentPowerResponse) 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 *QueryActiveFinalityProvidersAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ActiveFinalityProvidersAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPkHex != nil { + l = m.BtcPkHex.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + if m.SlashedBabylonHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) + } + if m.SlashedBtcHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) + } + if m.Jailed { + n += 2 + } + return n +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryActivatedHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryActivatedHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryListPublicRandomnessRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListPublicRandomnessResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PubRandMap) > 0 { + for k, v := range m.PubRandMap { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovQuery(uint64(l)) + } + mapEntrySize := 1 + sovQuery(uint64(k)) + l + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *PubRandCommitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NumPubRand != 0 { + n += 1 + sovQuery(uint64(m.NumPubRand)) + } + l = len(m.Commitment) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + return n +} + +func (m *QueryListPubRandCommitRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListPubRandCommitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PubRandCommitMap) > 0 { + for k, v := range m.PubRandCommitMap { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovQuery(uint64(l)) + } + mapEntrySize := 1 + sovQuery(uint64(k)) + l + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBlockRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryBlockResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != nil { + l = m.Block.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListBlocksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListBlocksResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Blocks) > 0 { + for _, e := range m.Blocks { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryVotesAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BtcPks) > 0 { + for _, e := range m.BtcPks { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryEvidenceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *EvidenceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.PubRand != nil { + l = m.PubRand.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.CanonicalAppHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ForkAppHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.CanonicalFinalitySig != nil { + l = m.CanonicalFinalitySig.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.ForkFinalitySig != nil { + l = m.ForkFinalitySig.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEvidenceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListEvidencesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StartHeight != 0 { + n += 1 + sovQuery(uint64(m.StartHeight)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListEvidencesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Evidences) > 0 { + for _, e := range m.Evidences { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySigningInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SigningInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.StartHeight != 0 { + n += 1 + sovQuery(uint64(m.StartHeight)) + } + if m.MissedBlocksCounter != 0 { + n += 1 + sovQuery(uint64(m.MissedBlocksCounter)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil) + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySigningInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SigningInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySigningInfosRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySigningInfosResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SigningInfos) > 0 { + for _, e := range m.SigningInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *QueryFinalityProviderPowerAtHeightRequest) 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: QueryFinalityProviderPowerAtHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", 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.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 + } + } + 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 *QueryFinalityProviderPowerAtHeightResponse) 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: QueryFinalityProviderPowerAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 *QueryFinalityProviderCurrentPowerRequest) 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: QueryFinalityProviderCurrentPowerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", 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.FpBtcPkHex = 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 *QueryFinalityProviderCurrentPowerResponse) 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: QueryFinalityProviderCurrentPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: 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 *QueryActiveFinalityProvidersAtHeightRequest) 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: QueryActiveFinalityProvidersAtHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *ActiveFinalityProvidersAtHeightResponse) 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: ActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPkHex", 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 + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPkHex = &v + if err := m.BtcPkHex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 3: + 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 + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedBabylonHeight", wireType) + } + m.SlashedBabylonHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SlashedBabylonHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedBtcHeight", wireType) + } + m.SlashedBtcHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SlashedBtcHeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + 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 m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QuerySigningInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *SigningInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.StartHeight != 0 { - n += 1 + sovQuery(uint64(m.StartHeight)) - } - if m.MissedBlocksCounter != 0 { - n += 1 + sovQuery(uint64(m.MissedBlocksCounter)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil) - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QuerySigningInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.SigningInfo.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} -func (m *QuerySigningInfosRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n + return nil } - -func (m *QuerySigningInfosResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.SigningInfos) > 0 { - for _, e := range m.SigningInfos { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryActiveFinalityProvidersAtHeightResponse) 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: QueryActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalityProviders = append(m.FinalityProviders, &ActiveFinalityProvidersAtHeightResponse{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryActivatedHeightRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3231,10 +5282,10 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryActivatedHeightRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryActivatedHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3258,7 +5309,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryActivatedHeightResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3281,17 +5332,17 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryActivatedHeightResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryActivatedHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - var msglen int + m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3301,25 +5352,11 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/finality/types/query.pb.gw.go b/x/finality/types/query.pb.gw.go index 6211809d2..d51945089 100644 --- a/x/finality/types/query.pb.gw.go +++ b/x/finality/types/query.pb.gw.go @@ -51,6 +51,226 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_ActiveFinalityProvidersAtHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActiveFinalityProvidersAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ActiveFinalityProvidersAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActiveFinalityProvidersAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ActiveFinalityProvidersAtHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderPowerAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := client.FinalityProviderPowerAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderPowerAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := server.FinalityProviderPowerAtHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + msg, err := client.FinalityProviderCurrentPower(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + msg, err := server.FinalityProviderCurrentPower(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 + + msg, err := client.ActivatedHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActivatedHeightRequest + var metadata runtime.ServerMetadata + + msg, err := server.ActivatedHeight(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_ListPublicRandomness_0 = &utilities.DoubleArray{Encoding: map[string]int{"fp_btc_pk_hex": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -548,6 +768,98 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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() + 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_ActivatedHeight_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_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListPublicRandomness_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -816,6 +1128,86 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_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_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_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_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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_FinalityProviderCurrentPower_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() + 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_ActivatedHeight_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_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListPublicRandomness_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1002,6 +1394,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ActiveFinalityProvidersAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "finality", "v1", "finality_providers", "height"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FinalityProviderPowerAtHeight_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", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "power", "height"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FinalityProviderCurrentPower_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", "finality", "v1", "finality_providers", "fp_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", "finality", "v1", "activated_height"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListPublicRandomness_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", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "public_randomness_list"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ListPubRandCommit_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", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "pub_rand_commit_list"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1024,6 +1424,14 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_ActiveFinalityProvidersAtHeight_0 = runtime.ForwardResponseMessage + + forward_Query_FinalityProviderPowerAtHeight_0 = runtime.ForwardResponseMessage + + forward_Query_FinalityProviderCurrentPower_0 = runtime.ForwardResponseMessage + + forward_Query_ActivatedHeight_0 = runtime.ForwardResponseMessage + forward_Query_ListPublicRandomness_0 = runtime.ForwardResponseMessage forward_Query_ListPubRandCommit_0 = runtime.ForwardResponseMessage diff --git a/x/incentive/keeper/btc_staking_gauge.go b/x/incentive/keeper/btc_staking_gauge.go index 4992ef782..9d265d051 100644 --- a/x/incentive/keeper/btc_staking_gauge.go +++ b/x/incentive/keeper/btc_staking_gauge.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +13,7 @@ import ( // RewardBTCStaking distributes rewards to finality providers/delegations at a given height according // to the filtered reward distribution cache (that only contains voted finality providers) // (adapted from https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/x/distribution/keeper/allocation.go#L12-L64) -func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *bstypes.VotingPowerDistCache) { +func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *ftypes.VotingPowerDistCache) { gauge := k.GetBTCStakingGauge(ctx, height) if gauge == nil { // failing to get a reward gauge at previous height is a programming error