From 9cd91215033b8a2dd64d21e374ff108bc838b3ca Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 6 Dec 2023 16:20:32 +0100 Subject: [PATCH] Add ManaParameters::annual_decay_factor_percentage (#1755) * Add ManaParameters::annual_decay_factor_percentage * Out of date docs * fmt --- sdk/src/types/block/mana/parameters.rs | 11 ++++++++--- sdk/src/types/block/protocol/mod.rs | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sdk/src/types/block/mana/parameters.rs b/sdk/src/types/block/mana/parameters.rs index fd5ffd44c8..65e8ca8d04 100644 --- a/sdk/src/types/block/mana/parameters.rs +++ b/sdk/src/types/block/mana/parameters.rs @@ -21,11 +21,13 @@ use crate::types::block::{ pub struct ManaParameters { /// The number of bits used to represent Mana. pub(crate) bits_count: u8, - /// The amount of potential Mana generated by 1 IOTA in 1 slot. + /// The amount of potential Mana generated by 1 microIOTA in 1 slot multiplied by 2^generation_rate_exponent. pub(crate) generation_rate: u8, - /// The scaling of `mana_generation_rate` expressed as an exponent of 2. + /// The scaling of `generation_rate` expressed as an exponent of 2. + /// The actual generation rate of Mana is given by generation_rate * 2^(-generation_rate_exponent). pub(crate) generation_rate_exponent: u8, /// A lookup table of epoch index diff to mana decay factor. + /// The actual decay factor is given by decay_factors[epoch_diff] * 2^(-decay_factors_exponent). #[packable(unpack_error_with = |_| Error::InvalidManaDecayFactors)] #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::boxed_slice_prefix"))] #[getset(skip)] @@ -34,8 +36,10 @@ pub struct ManaParameters { pub(crate) decay_factors_exponent: u8, /// An integer approximation of the sum of decay over epochs. pub(crate) decay_factor_epochs_sum: u32, - /// The scaling of `mana_decay_factor_epochs_sum` expressed as an exponent of 2. + /// The scaling of `decay_factor_epochs_sum` expressed as an exponent of 2. pub(crate) decay_factor_epochs_sum_exponent: u8, + // Decay factor for 1 year. + pub(crate) annual_decay_factor_percentage: u8, } impl ManaParameters { @@ -99,6 +103,7 @@ impl Default for ManaParameters { decay_factors_exponent: Default::default(), decay_factor_epochs_sum: Default::default(), decay_factor_epochs_sum_exponent: Default::default(), + annual_decay_factor_percentage: Default::default(), } } } diff --git a/sdk/src/types/block/protocol/mod.rs b/sdk/src/types/block/protocol/mod.rs index 2c200bc596..43a6ebd316 100644 --- a/sdk/src/types/block/protocol/mod.rs +++ b/sdk/src/types/block/protocol/mod.rs @@ -91,7 +91,8 @@ pub struct ProtocolParameters { /// Defines the target size of the committee. If there's fewer candidates the actual committee size could be /// smaller in a given epoch. pub(crate) target_committee_size: u8, - /// Defines the number of heavier slots that a chain needs to be ahead of the current chain to be considered for switching. + /// Defines the number of heavier slots that a chain needs to be ahead of the current chain to be considered for + /// switching. pub(crate) chain_switching_threshold: u8, }