Skip to content

Commit

Permalink
backport: chore(x/incentive): add missing data to genesis (#519) (#532)
Browse files Browse the repository at this point in the history
Co-authored-by: RafilxTenfen <[email protected]>
  • Loading branch information
GAtom22 and RafilxTenfen authored Feb 28, 2025
1 parent ab3ee89 commit 7bfda1e
Show file tree
Hide file tree
Showing 34 changed files with 2,605 additions and 420 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- [#558](https://github.com/babylonlabs-io/babylon/pull/558) Change BLS public key format from hex to base64 in bls_key.json.
- [#466](https://github.com/babylonlabs-io/babylon/pull/466) Add e2e test to
- [#519](https://github.com/babylonlabs-io/babylon/pull/519) Add missing data in `InitGenesis` and `ExportGenesis` in `x/incentive` module
block bank send and still create BTC delegations
- [#538](https://github.com/babylonlabs-io/babylon/pull/538) Upgrade to wasmd v0.54.x and wasmvm v2.2.x
- [#527](https://github.com/babylonlabs-io/babylon/pull/527) Create BSL signer on start command with flags.
Expand Down
302 changes: 188 additions & 114 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

52 changes: 51 additions & 1 deletion proto/babylon/incentive/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,60 @@ package babylon.incentive;

import "gogoproto/gogo.proto";
import "babylon/incentive/params.proto";
import "babylon/incentive/incentive.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types";

// GenesisState defines the incentive module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
// params the current params of the state.
Params params = 1 [ (gogoproto.nullable) = false ];
// BTC staking gauge on every height
repeated BTCStakingGaugeEntry btc_staking_gauges = 2
[ (gogoproto.nullable) = false ];
// RewardGauges the reward gauge for each BTC staker and finality provider
repeated RewardGaugeEntry reward_gauges = 3 [ (gogoproto.nullable) = false ];
// Withdraw addresses of the delegators
repeated WithdrawAddressEntry withdraw_addresses = 4
[ (gogoproto.nullable) = false ];
}

// BTCStakingGaugeEntry represents a gauge for BTC staking rewards at a specific
// height.
message BTCStakingGaugeEntry {
// Block height at which this gauge is set
uint64 height = 1;
// The gauge object storing rewards info
Gauge gauge = 2;
}

// RewardGaugeEntry represents a reward gauge for a specific stakeholder.
message RewardGaugeEntry {
// Type of stakeholder
StakeholderType stakeholder_type = 1;
// Address of the stakeholder
string address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// The reward gauge object
RewardGauge reward_gauge = 3;
}

// WithdrawAddressEntry holds the record of a withdraw address belonging to a
// delegator address.
message WithdrawAddressEntry {
// Address of the delegator
string delegator_address = 1
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// Withdraw address
string withdraw_address = 2
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// StakeholderType represents the different types of stakeholders.
enum StakeholderType {
option (gogoproto.goproto_enum_prefix) = false;
// Finality provider stakeholder type
FINALITY_PROVIDER = 0;
// BTC delegation stakeholder type
BTC_DELEGATION = 1;
}
43 changes: 23 additions & 20 deletions proto/babylon/incentive/incentive.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ import "cosmos/base/v1beta1/coin.proto";
option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types";

// Gauge is an object that stores rewards to be distributed
// code adapted from https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto
// code adapted from
// https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto
message Gauge {
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// RewardGauge is an object that stores rewards distributed to a BTC staking stakeholder
// code adapted from https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto
// RewardGauge is an object that stores rewards distributed to a BTC staking
// stakeholder code adapted from
// https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto
message RewardGauge {
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// withdrawn_coins are coins that have been withdrawn by the stakeholder already
repeated cosmos.base.v1beta1.Coin withdrawn_coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// withdrawn_coins are coins that have been withdrawn by the stakeholder
// already
repeated cosmos.base.v1beta1.Coin withdrawn_coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
24 changes: 13 additions & 11 deletions proto/babylon/incentive/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types";

// Params defines the parameters for the module, including portions of rewards
// distributed to each type of stakeholder. Note that sum of the portions should
// be strictly less than 1 so that the rest will go to Comet validators/delegations
// adapted from https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/proto/cosmos/distribution/v1beta1/distribution.proto
// be strictly less than 1 so that the rest will go to Comet
// validators/delegations adapted from
// https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/proto/cosmos/distribution/v1beta1/distribution.proto
message Params {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_stringer) = false;

// btc_staking_portion is the portion of rewards that goes to Finality Providers/delegations
// NOTE: the portion of each Finality Provider/delegation is calculated by using its voting
// power and finality provider's commission
string btc_staking_portion = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// btc_staking_portion is the portion of rewards that goes to Finality
// Providers/delegations NOTE: the portion of each Finality
// Provider/delegation is calculated by using its voting power and finality
// provider's commission
string btc_staking_portion = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
135 changes: 75 additions & 60 deletions proto/babylon/incentive/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,101 +11,116 @@ option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/babylon/incentive/params";
}
// RewardGauge queries the reward gauge of a given stakeholder address
rpc RewardGauges(QueryRewardGaugesRequest) returns (QueryRewardGaugesResponse) {
option (google.api.http).get = "/babylon/incentive/address/{address}/reward_gauge";
}
// BTCStakingGauge queries the BTC staking gauge of a given height
rpc BTCStakingGauge(QueryBTCStakingGaugeRequest) returns (QueryBTCStakingGaugeResponse) {
option (google.api.http).get = "/babylon/incentive/btc_staking_gauge/{height}";
}

// DelegatorWithdrawAddress queries withdraw address of a delegator.
rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {
option (google.api.http).get = "/babylon/incentive/delegators/{delegator_address}/withdraw_address";
}
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/babylon/incentive/params";
}
// RewardGauge queries the reward gauge of a given stakeholder address
rpc RewardGauges(QueryRewardGaugesRequest)
returns (QueryRewardGaugesResponse) {
option (google.api.http).get =
"/babylon/incentive/address/{address}/reward_gauge";
}
// BTCStakingGauge queries the BTC staking gauge of a given height
rpc BTCStakingGauge(QueryBTCStakingGaugeRequest)
returns (QueryBTCStakingGaugeResponse) {
option (google.api.http).get =
"/babylon/incentive/btc_staking_gauge/{height}";
}

// DelegatorWithdrawAddress queries withdraw address of a delegator.
rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest)
returns (QueryDelegatorWithdrawAddressResponse) {
option (google.api.http).get =
"/babylon/incentive/delegators/{delegator_address}/withdraw_address";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
// params holds all the parameters of this module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryRewardGaugesRequest is request type for the Query/RewardGauges RPC method.
// QueryRewardGaugesRequest is request type for the Query/RewardGauges RPC
// method.
message QueryRewardGaugesRequest {
// address is the address of the stakeholder in bech32 string
string address = 1;
// address is the address of the stakeholder in bech32 string
string address = 1;
}

// RewardGaugesResponse is an object that stores rewards distributed to a BTC staking stakeholder
// RewardGaugesResponse is an object that stores rewards distributed to a BTC
// staking stakeholder
message RewardGaugesResponse {
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// withdrawn_coins are coins that have been withdrawn by the stakeholder already
repeated cosmos.base.v1beta1.Coin withdrawn_coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// coins are coins that have been in the gauge
// Can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// withdrawn_coins are coins that have been withdrawn by the stakeholder
// already
repeated cosmos.base.v1beta1.Coin withdrawn_coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// QueryRewardGaugesResponse is response type for the Query/RewardGauges RPC method.
// QueryRewardGaugesResponse is response type for the Query/RewardGauges RPC
// method.
message QueryRewardGaugesResponse {
// reward_gauges is the map of reward gauges, where key is the stakeholder type
// and value is the reward gauge holding all rewards for the stakeholder in that type
map<string, RewardGaugesResponse> reward_gauges = 1;
// reward_gauges is the map of reward gauges, where key is the stakeholder
// type and value is the reward gauge holding all rewards for the stakeholder
// in that type
map<string, RewardGaugesResponse> reward_gauges = 1;
}

// QueryBTCStakingGaugeRequest is request type for the Query/BTCStakingGauge RPC method.
// QueryBTCStakingGaugeRequest is request type for the Query/BTCStakingGauge RPC
// method.
message QueryBTCStakingGaugeRequest {
// height is the queried Babylon height
uint64 height = 1;
// height is the queried Babylon height
uint64 height = 1;
}

// BTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method.
// BTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC
// method.
message BTCStakingGaugeResponse {
// coins that have been in the gauge
// can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

// coins that have been in the gauge
// can have multiple coin denoms
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method.
// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge
// RPC method.
message QueryBTCStakingGaugeResponse {
// gauge is the BTC staking gauge at the queried height
BTCStakingGaugeResponse gauge = 1;
// gauge is the BTC staking gauge at the queried height
BTCStakingGaugeResponse gauge = 1;
}

// QueryDelegatorWithdrawAddressRequest is the request type for the
// Query/DelegatorWithdrawAddress RPC method.
message QueryDelegatorWithdrawAddressRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// delegator_address defines the delegator address to query for.
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// delegator_address defines the delegator address to query for.
string delegator_address = 1
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// QueryDelegatorWithdrawAddressResponse is the response type for the
// Query/DelegatorWithdrawAddress RPC method.
message QueryDelegatorWithdrawAddressResponse {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// withdraw_address defines the delegator address to query for.
string withdraw_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// withdraw_address defines the delegator address to query for.
string withdraw_address = 1
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}
Loading

0 comments on commit 7bfda1e

Please sign in to comment.