Skip to content

Commit

Permalink
Add chain parameters for configuring LQT distributions (#5018)
Browse files Browse the repository at this point in the history
Closes #5012.

Testing shouldn't be required at this stage.

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

> This is consensus-breaking, because validators will disagree about,
e.g. what people are voting on.
  • Loading branch information
cronokirby authored Jan 28, 2025
1 parent 0d8fa13 commit 881cd26
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/core/app/src/params/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl AppParameters {
distributions_params:
DistributionsParameters {
staking_issuance_per_block: _,
liquidity_tournament_incentive_per_block: _,
},
fee_params:
FeeParameters {
Expand Down Expand Up @@ -163,6 +164,7 @@ impl AppParameters {
distributions_params:
DistributionsParameters {
staking_issuance_per_block: _,
liquidity_tournament_incentive_per_block: _,
},
fee_params:
FeeParameters {
Expand Down
5 changes: 5 additions & 0 deletions crates/core/component/distributions/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
)]
pub struct DistributionsParameters {
pub staking_issuance_per_block: u64,
pub liquidity_tournament_incentive_per_block: u64,
}

impl DomainType for DistributionsParameters {
Expand All @@ -21,6 +22,7 @@ impl TryFrom<pb::DistributionsParameters> for DistributionsParameters {
fn try_from(msg: pb::DistributionsParameters) -> anyhow::Result<Self> {
Ok(DistributionsParameters {
staking_issuance_per_block: msg.staking_issuance_per_block,
liquidity_tournament_incentive_per_block: msg.liquidity_tournament_incentive_per_block,
})
}
}
Expand All @@ -29,6 +31,8 @@ impl From<DistributionsParameters> for pb::DistributionsParameters {
fn from(params: DistributionsParameters) -> Self {
pb::DistributionsParameters {
staking_issuance_per_block: params.staking_issuance_per_block,
liquidity_tournament_incentive_per_block: params
.liquidity_tournament_incentive_per_block,
}
}
}
Expand All @@ -37,6 +41,7 @@ impl Default for DistributionsParameters {
fn default() -> Self {
Self {
staking_issuance_per_block: 1_000_000,
liquidity_tournament_incentive_per_block: 0,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pub struct DistributionsParameters {
/// The amount of staking token issued per block.
#[prost(uint64, tag = "1")]
pub staking_issuance_per_block: u64,
/// The amount of staking token flowing from the community pool to the liquidity tournament each block.
#[prost(uint64, tag = "2")]
pub liquidity_tournament_incentive_per_block: u64,
}
impl ::prost::Name for DistributionsParameters {
const NAME: &'static str = "DistributionsParameters";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ impl serde::Serialize for DistributionsParameters {
if self.staking_issuance_per_block != 0 {
len += 1;
}
if self.liquidity_tournament_incentive_per_block != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.distributions.v1.DistributionsParameters", len)?;
if self.staking_issuance_per_block != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("stakingIssuancePerBlock", ToString::to_string(&self.staking_issuance_per_block).as_str())?;
}
if self.liquidity_tournament_incentive_per_block != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("liquidityTournamentIncentivePerBlock", ToString::to_string(&self.liquidity_tournament_incentive_per_block).as_str())?;
}
struct_ser.end()
}
}
Expand All @@ -27,11 +35,14 @@ impl<'de> serde::Deserialize<'de> for DistributionsParameters {
const FIELDS: &[&str] = &[
"staking_issuance_per_block",
"stakingIssuancePerBlock",
"liquidity_tournament_incentive_per_block",
"liquidityTournamentIncentivePerBlock",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
StakingIssuancePerBlock,
LiquidityTournamentIncentivePerBlock,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand All @@ -55,6 +66,7 @@ impl<'de> serde::Deserialize<'de> for DistributionsParameters {
{
match value {
"stakingIssuancePerBlock" | "staking_issuance_per_block" => Ok(GeneratedField::StakingIssuancePerBlock),
"liquidityTournamentIncentivePerBlock" | "liquidity_tournament_incentive_per_block" => Ok(GeneratedField::LiquidityTournamentIncentivePerBlock),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand All @@ -75,6 +87,7 @@ impl<'de> serde::Deserialize<'de> for DistributionsParameters {
V: serde::de::MapAccess<'de>,
{
let mut staking_issuance_per_block__ = None;
let mut liquidity_tournament_incentive_per_block__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::StakingIssuancePerBlock => {
Expand All @@ -85,13 +98,22 @@ impl<'de> serde::Deserialize<'de> for DistributionsParameters {
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::LiquidityTournamentIncentivePerBlock => {
if liquidity_tournament_incentive_per_block__.is_some() {
return Err(serde::de::Error::duplicate_field("liquidityTournamentIncentivePerBlock"));
}
liquidity_tournament_incentive_per_block__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
}
}
Ok(DistributionsParameters {
staking_issuance_per_block: staking_issuance_per_block__.unwrap_or_default(),
liquidity_tournament_incentive_per_block: liquidity_tournament_incentive_per_block__.unwrap_or_default(),
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package penumbra.core.component.distributions.v1;
message DistributionsParameters {
// The amount of staking token issued per block.
uint64 staking_issuance_per_block = 1;
// The amount of staking token flowing from the community pool to the liquidity tournament each block.
uint64 liquidity_tournament_incentive_per_block = 2;
}

// Genesis data for the distributions module.
Expand Down

0 comments on commit 881cd26

Please sign in to comment.