diff --git a/crates/iota-benchmark/tests/simtest.rs b/crates/iota-benchmark/tests/simtest.rs index 6ea42019989..cffba166d56 100644 --- a/crates/iota-benchmark/tests/simtest.rs +++ b/crates/iota-benchmark/tests/simtest.rs @@ -425,7 +425,6 @@ mod test { SupportedProtocolVersions::new_for_testing(starting_version, max_ver), ) .with_objects(init_framework.into_iter().map(|p| p.genesis_object())) - .with_stake_subsidy_start_epoch(10) .build() .await; diff --git a/crates/iota-config/src/genesis.rs b/crates/iota-config/src/genesis.rs index 0128171148d..9d2f63b7f19 100644 --- a/crates/iota-config/src/genesis.rs +++ b/crates/iota-config/src/genesis.rs @@ -347,12 +347,6 @@ pub struct GenesisChainParameters { pub chain_start_timestamp_ms: u64, pub epoch_duration_ms: u64, - // Stake Subsidy parameters - pub stake_subsidy_start_epoch: u64, - pub stake_subsidy_initial_distribution_amount: u64, - pub stake_subsidy_period_length: u64, - pub stake_subsidy_decrease_rate: u16, - // Validator committee parameters pub max_validator_count: u64, pub min_validator_joining_stake: u64, @@ -377,27 +371,6 @@ pub struct GenesisCeremonyParameters { /// The duration of an epoch, in milliseconds. #[serde(default = "GenesisCeremonyParameters::default_epoch_duration_ms")] pub epoch_duration_ms: u64, - - /// The starting epoch in which stake subsidies start being paid out. - #[serde(default = "GenesisCeremonyParameters::default_stake_subsidy_start_epoch")] - pub stake_subsidy_start_epoch: u64, - - /// The amount of stake subsidy to be drawn down per distribution. - /// This amount decays and decreases over time. - #[serde( - default = "GenesisCeremonyParameters::default_initial_stake_subsidy_distribution_amount" - )] - pub stake_subsidy_initial_distribution_amount: u64, - - /// Number of distributions to occur before the distribution amount decays. - #[serde(default = "GenesisCeremonyParameters::default_stake_subsidy_period_length")] - pub stake_subsidy_period_length: u64, - - /// The rate at which the distribution amount decays at the end of each - /// period. Expressed in basis points. - #[serde(default = "GenesisCeremonyParameters::default_stake_subsidy_decrease_rate")] - pub stake_subsidy_decrease_rate: u16, - // Most other parameters (e.g. initial gas schedule) should be derived from protocol_version. } impl GenesisCeremonyParameters { @@ -406,12 +379,7 @@ impl GenesisCeremonyParameters { chain_start_timestamp_ms: Self::default_timestamp_ms(), protocol_version: ProtocolVersion::MAX, allow_insertion_of_extra_objects: true, - stake_subsidy_start_epoch: Self::default_stake_subsidy_start_epoch(), epoch_duration_ms: Self::default_epoch_duration_ms(), - stake_subsidy_initial_distribution_amount: - Self::default_initial_stake_subsidy_distribution_amount(), - stake_subsidy_period_length: Self::default_stake_subsidy_period_length(), - stake_subsidy_decrease_rate: Self::default_stake_subsidy_decrease_rate(), } } @@ -431,40 +399,11 @@ impl GenesisCeremonyParameters { 24 * 60 * 60 * 1000 } - fn default_stake_subsidy_start_epoch() -> u64 { - // Set to highest possible value so that the stake subsidy fund never pays out - // rewards. - u64::MAX - } - - fn default_initial_stake_subsidy_distribution_amount() -> u64 { - // 0 IOTA in nanos - 0 - } - - fn default_stake_subsidy_period_length() -> u64 { - // Set to highest possible value so that the "decrease stake subsidy amount" - // code path is never entered which makes it easier to reason about the - // stake subsidy fund. - u64::MAX - } - - fn default_stake_subsidy_decrease_rate() -> u16 { - // Due to how stake_subsidy_period_length is set, this values is not important, - // since the distribution amount is never decreased. - 0 - } - pub fn to_genesis_chain_parameters(&self) -> GenesisChainParameters { GenesisChainParameters { protocol_version: self.protocol_version.as_u64(), - stake_subsidy_start_epoch: self.stake_subsidy_start_epoch, chain_start_timestamp_ms: self.chain_start_timestamp_ms, epoch_duration_ms: self.epoch_duration_ms, - stake_subsidy_initial_distribution_amount: self - .stake_subsidy_initial_distribution_amount, - stake_subsidy_period_length: self.stake_subsidy_period_length, - stake_subsidy_decrease_rate: self.stake_subsidy_decrease_rate, max_validator_count: iota_types::governance::MAX_VALIDATOR_COUNT, min_validator_joining_stake: iota_types::governance::MIN_VALIDATOR_JOINING_STAKE_NANOS, validator_low_stake_threshold: diff --git a/crates/iota-config/src/node.rs b/crates/iota-config/src/node.rs index 0a557394b5b..c21f1fdf7a5 100644 --- a/crates/iota-config/src/node.rs +++ b/crates/iota-config/src/node.rs @@ -1016,7 +1016,7 @@ mod tests { let g = Genesis::new_from_file("path/to/file"); let s = serde_yaml::to_string(&g).unwrap(); - assert_eq!("---\ngenesis-file-location: path/to/file\n", s); + assert_eq!("genesis-file-location: path/to/file\n", s); let loaded_genesis: Genesis = serde_yaml::from_str(&s).unwrap(); assert_eq!(g, loaded_genesis); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move index eac1cdee63c..87a7e8a5e3d 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move @@ -41,11 +41,6 @@ module iota_system::genesis { chain_start_timestamp_ms: u64, epoch_duration_ms: u64, - stake_subsidy_start_epoch: u64, - stake_subsidy_initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move index eac1cdee63c..87a7e8a5e3d 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move @@ -41,11 +41,6 @@ module iota_system::genesis { chain_start_timestamp_ms: u64, epoch_duration_ms: u64, - stake_subsidy_start_epoch: u64, - stake_subsidy_initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move index eac1cdee63c..87a7e8a5e3d 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move @@ -41,11 +41,6 @@ module iota_system::genesis { chain_start_timestamp_ms: u64, epoch_duration_ms: u64, - stake_subsidy_start_epoch: u64, - stake_subsidy_initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move index eac1cdee63c..87a7e8a5e3d 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move @@ -41,11 +41,6 @@ module iota_system::genesis { chain_start_timestamp_ms: u64, epoch_duration_ms: u64, - stake_subsidy_start_epoch: u64, - stake_subsidy_initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, diff --git a/crates/iota-framework-snapshot/bytecode_snapshot/1/0x0000000000000000000000000000000000000000000000000000000000000003 b/crates/iota-framework-snapshot/bytecode_snapshot/1/0x0000000000000000000000000000000000000000000000000000000000000003 index e4cd405e5d5..30978b439d3 100644 Binary files a/crates/iota-framework-snapshot/bytecode_snapshot/1/0x0000000000000000000000000000000000000000000000000000000000000003 and b/crates/iota-framework-snapshot/bytecode_snapshot/1/0x0000000000000000000000000000000000000000000000000000000000000003 differ diff --git a/crates/iota-framework-snapshot/manifest.json b/crates/iota-framework-snapshot/manifest.json index dddbc285c89..7b2040259a3 100644 --- a/crates/iota-framework-snapshot/manifest.json +++ b/crates/iota-framework-snapshot/manifest.json @@ -1,6 +1,6 @@ { "1": { - "git_revision": "b0d6faa10d", + "git_revision": "9492657c34", "package_ids": [ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000002", diff --git a/crates/iota-framework/docs/iota-system/genesis.mdx b/crates/iota-framework/docs/iota-system/genesis.mdx index c47301a1371..85eb8b6a3b3 100644 --- a/crates/iota-framework/docs/iota-system/genesis.mdx +++ b/crates/iota-framework/docs/iota-system/genesis.mdx @@ -28,7 +28,6 @@ import Link from '@docusaurus/Link'; use 0x2::tx_context; use 0x3::iota_system; use 0x3::iota_system_state_inner; -use 0x3::stake_subsidy; use 0x3::timelocked_staking; use 0x3::validator; use 0x3::validator_set; @@ -200,34 +199,6 @@ epoch_duration_ms: u64
-
-
- -stake_subsidy_start_epoch: u64 -
-
- -
-
- -stake_subsidy_initial_distribution_amount: u64 -
-
- -
-
- -stake_subsidy_period_length: u64 -
-
- -
-
- -stake_subsidy_decrease_rate: u16 -
-
-
@@ -437,7 +408,6 @@ all the information we need in the system. assert!(iota_treasury_cap.total_supply() == pre_minted_supply, EWrongPreMintedSupply); - let subsidy_fund = balance::zero(); let storage_fund = balance::zero(); // Create all the `Validator` structs @@ -507,7 +477,6 @@ all the information we need in the system. let system_parameters = iota_system_state_inner::create_system_parameters( genesis_chain_parameters.epoch_duration_ms, - genesis_chain_parameters.stake_subsidy_start_epoch, // Validator committee parameters genesis_chain_parameters.max_validator_count, @@ -519,14 +488,6 @@ all the information we need in the system. ctx, ); - let stake_subsidy = stake_subsidy::create( - subsidy_fund, - genesis_chain_parameters.stake_subsidy_initial_distribution_amount, - genesis_chain_parameters.stake_subsidy_period_length, - genesis_chain_parameters.stake_subsidy_decrease_rate, - ctx, - ); - iota_system::create( iota_system_state_id, iota_treasury_cap, @@ -535,7 +496,6 @@ all the information we need in the system. genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, system_parameters, - stake_subsidy, system_timelock_cap, ctx, ); diff --git a/crates/iota-framework/docs/iota-system/iota_system.mdx b/crates/iota-framework/docs/iota-system/iota_system.mdx index 2da937348ba..b9366862741 100644 --- a/crates/iota-framework/docs/iota-system/iota_system.mdx +++ b/crates/iota-framework/docs/iota-system/iota_system.mdx @@ -121,7 +121,6 @@ the IotaSystemStateInner version, or vice versa. use 0x2::transfer; use 0x2::tx_context; use 0x3::iota_system_state_inner; -use 0x3::stake_subsidy; use 0x3::staking_pool; use 0x3::validator; use 0x3::validator_cap; @@ -209,7 +208,7 @@ This function will be called only once in genesis.

-public(friend) fun create(id: object::UID, iota_treasury_cap: iota::IotaTreasuryCap, validators: vector<validator::Validator>, storage_fund: balance::Balance<iota::IOTA>, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: iota_system_state_inner::SystemParameters, stake_subsidy: stake_subsidy::StakeSubsidy, system_timelock_cap: timelock::SystemTimelockCap, ctx: &mut tx_context::TxContext)
+public(friend) fun create(id: object::UID, iota_treasury_cap: iota::IotaTreasuryCap, validators: vector<validator::Validator>, storage_fund: balance::Balance<iota::IOTA>, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: iota_system_state_inner::SystemParameters, system_timelock_cap: timelock::SystemTimelockCap, ctx: &mut tx_context::TxContext)
 
@@ -227,7 +226,6 @@ This function will be called only once in genesis. protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: SystemParameters, - stake_subsidy: StakeSubsidy, system_timelock_cap: SystemTimelockCap, ctx: &mut TxContext, ) \{ @@ -238,7 +236,6 @@ This function will be called only once in genesis. protocol_version, epoch_start_timestamp_ms, parameters, - stake_subsidy, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); diff --git a/crates/iota-framework/docs/iota-system/iota_system_state_inner.mdx b/crates/iota-framework/docs/iota-system/iota_system_state_inner.mdx index 232472f96a8..f249892397c 100644 --- a/crates/iota-framework/docs/iota-system/iota_system_state_inner.mdx +++ b/crates/iota-framework/docs/iota-system/iota_system_state_inner.mdx @@ -82,7 +82,6 @@ import Link from '@docusaurus/Link'; use 0x2::tx_context; use 0x2::vec_map; use 0x2::vec_set; -use 0x3::stake_subsidy; use 0x3::staking_pool; use 0x3::storage_fund; use 0x3::validator; @@ -119,13 +118,6 @@ epoch_duration_ms: u64
-stake_subsidy_start_epoch: u64 -
-
- The starting epoch in which stake subsidies start being paid out -
-
- max_validator_count: u64
@@ -207,13 +199,6 @@ epoch_duration_ms: u64
-stake_subsidy_start_epoch: u64 -
-
- The starting epoch in which stake subsidies start being paid out -
-
- min_validator_count: u64
@@ -367,13 +352,6 @@ validator_report_records: stake_subsidy: stake_subsidy::StakeSubsidy - -
- Schedule of stake subsidies given out each epoch. -
-
- safe_mode: bool
@@ -524,13 +502,6 @@ validator_report_records: stake_subsidy: stake_subsidy::StakeSubsidy - -
- Schedule of stake subsidies given out each epoch. -
-
- safe_mode: bool
@@ -656,13 +627,6 @@ storage_fund_balance: u64
-
-
- -stake_subsidy_amount: u64 -
-
-
@@ -858,7 +822,7 @@ This function will be called only once in genesis.

-public(friend) fun create(iota_treasury_cap: iota::IotaTreasuryCap, validators: vector<validator::Validator>, initial_storage_fund: balance::Balance<iota::IOTA>, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: iota_system_state_inner::SystemParameters, stake_subsidy: stake_subsidy::StakeSubsidy, ctx: &mut tx_context::TxContext): iota_system_state_inner::IotaSystemStateInner
+public(friend) fun create(iota_treasury_cap: iota::IotaTreasuryCap, validators: vector<validator::Validator>, initial_storage_fund: balance::Balance<iota::IOTA>, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: iota_system_state_inner::SystemParameters, ctx: &mut tx_context::TxContext): iota_system_state_inner::IotaSystemStateInner
 
@@ -875,7 +839,6 @@ This function will be called only once in genesis. protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: SystemParameters, - stake_subsidy: StakeSubsidy, ctx: &mut TxContext, ): IotaSystemStateInner \{ let validators = validator_set::new(validators, ctx); @@ -891,7 +854,6 @@ This function will be called only once in genesis. parameters, reference_gas_price, validator_report_records: vec_map::empty(), - stake_subsidy, safe_mode: false, safe_mode_storage_charges: balance::zero(), safe_mode_computation_rewards: balance::zero(), @@ -915,7 +877,7 @@ This function will be called only once in genesis.

-public(friend) fun create_system_parameters(epoch_duration_ms: u64, stake_subsidy_start_epoch: u64, max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, validator_very_low_stake_threshold: u64, validator_low_stake_grace_period: u64, ctx: &mut tx_context::TxContext): iota_system_state_inner::SystemParameters
+public(friend) fun create_system_parameters(epoch_duration_ms: u64, max_validator_count: u64, min_validator_joining_stake: u64, validator_low_stake_threshold: u64, validator_very_low_stake_threshold: u64, validator_low_stake_grace_period: u64, ctx: &mut tx_context::TxContext): iota_system_state_inner::SystemParameters
 
@@ -927,7 +889,6 @@ This function will be called only once in genesis.

 public(package) fun create_system_parameters(
     epoch_duration_ms: u64,
-    stake_subsidy_start_epoch: u64,
 
     // Validator committee parameters
     max_validator_count: u64,
@@ -939,7 +900,6 @@ This function will be called only once in genesis.
 ): SystemParameters \{
     SystemParameters \{
         epoch_duration_ms,
-        stake_subsidy_start_epoch,
         max_validator_count,
         min_validator_joining_stake,
         validator_low_stake_threshold,
@@ -982,7 +942,6 @@ This function will be called only once in genesis.
         parameters,
         reference_gas_price,
         validator_report_records,
-        stake_subsidy,
         safe_mode,
         safe_mode_storage_charges,
         safe_mode_computation_rewards,
@@ -993,7 +952,6 @@ This function will be called only once in genesis.
     } = self;
     let SystemParameters \{
         epoch_duration_ms,
-        stake_subsidy_start_epoch,
         max_validator_count,
         min_validator_joining_stake,
         validator_low_stake_threshold,
@@ -1010,7 +968,6 @@ This function will be called only once in genesis.
         storage_fund,
         parameters: SystemParametersV2 \{
             epoch_duration_ms,
-            stake_subsidy_start_epoch,
             min_validator_count: 4,
             max_validator_count,
             min_validator_joining_stake,
@@ -1021,7 +978,6 @@ This function will be called only once in genesis.
         },
         reference_gas_price,
         validator_report_records,
-        stake_subsidy,
         safe_mode,
         safe_mode_storage_charges,
         safe_mode_computation_rewards,
@@ -2291,7 +2247,6 @@ or smaller than the computation reward.
     epoch_start_timestamp_ms: u64, // Timestamp of the epoch start
     ctx: &mut TxContext,
 ) : Balance<IOTA> \{
-    let prev_epoch_start_timestamp = self.epoch_start_timestamp_ms;
     self.epoch_start_timestamp_ms = epoch_start_timestamp_ms;
 
     let bps_denominator_u64 = BASIS_POINT_DENOMINATOR as u64;
@@ -2311,23 +2266,6 @@ or smaller than the computation reward.
     let storage_charge_value = storage_charge.value();
     let computation_charge = computation_reward.value();
 
-    // Include stake subsidy in the rewards given out to validators and stakers.
-    // Delay distributing any stake subsidies until after `stake_subsidy_start_epoch`.
-    // And if this epoch is shorter than the regular epoch duration, don't distribute any stake subsidy.
-    let stake_subsidy =
-        if (ctx.epoch() >= self.parameters.stake_subsidy_start_epoch  &&
-            epoch_start_timestamp_ms >= prev_epoch_start_timestamp + self.parameters.epoch_duration_ms)
-        \{
-            self.stake_subsidy.advance_epoch()
-        } else \{
-            balance::zero()
-        };
-
-    // The stake subsidy fund is disabled through parameter choices in GenesisCeremonyParameters,
-    // so it is always a zero balance now. It will be fully removed in a later step.
-    let stake_subsidy_amount = stake_subsidy.value();
-    computation_reward.join(stake_subsidy);
-
     let (mut total_validator_rewards, minted_tokens_amount, burnt_tokens_amount) = match_computation_reward_to_target_reward(
         validator_target_reward,
         computation_reward,
@@ -2384,8 +2322,6 @@ or smaller than the computation reward.
             storage_charge: storage_charge_value,
             storage_rebate: storage_rebate_amount,
             storage_fund_balance: self.storage_fund.total_balance(),
-            // TODO: remove(obsolete)
-            stake_subsidy_amount,
             total_gas_fees: computation_charge,
             total_stake_rewards_distributed: total_validator_rewards_distributed,
             burnt_leftover_amount,
diff --git a/crates/iota-framework/docs/iota-system/stake_subsidy.mdx b/crates/iota-framework/docs/iota-system/stake_subsidy.mdx
deleted file mode 100644
index 6737ca846ca..00000000000
--- a/crates/iota-framework/docs/iota-system/stake_subsidy.mdx
+++ /dev/null
@@ -1,231 +0,0 @@
----
-title: Module `0x3::stake_subsidy`
----
-import Link from '@docusaurus/Link';
-
-
-
-
--  [Struct `StakeSubsidy`](#0x3_stake_subsidy_StakeSubsidy)
--  [Constants](#@Constants_0)
--  [Function `create`](#0x3_stake_subsidy_create)
--  [Function `advance_epoch`](#0x3_stake_subsidy_advance_epoch)
--  [Function `current_epoch_subsidy_amount`](#0x3_stake_subsidy_current_epoch_subsidy_amount)
-
-
-

-use 0x2::bag;
-use 0x2::balance;
-use 0x2::iota;
-use 0x2::math;
-use 0x2::tx_context;
-
- - - - - -## Struct `StakeSubsidy` - - - -

-struct StakeSubsidy has store
-
- - - -
-Fields - - -
-
- -balance: balance::Balance<iota::IOTA> -
-
- Balance of IOTA set aside for stake subsidies that will be drawn down over time. -
-
- -distribution_counter: u64 -
-
- Count of the number of times stake subsidies have been distributed. -
-
- -current_distribution_amount: u64 -
-
- The amount of stake subsidy to be drawn down per distribution. - This amount decays and decreases over time. -
-
- -stake_subsidy_period_length: u64 -
-
- Number of distributions to occur before the distribution amount decays. -
-
- -stake_subsidy_decrease_rate: u16 -
-
- The rate at which the distribution amount decays at the end of each - period. Expressed in basis points. -
-
- -extra_fields: bag::Bag -
-
- Any extra fields that's not defined statically. -
-
- - -
- - - -## Constants - - - - - - -

-const BASIS_POINT_DENOMINATOR: u128 = 10000;
-
- - - - - - - -

-const ESubsidyDecreaseRateTooLarge: u64 = 0;
-
- - - - - -## Function `create` - - - -

-public(friend) fun create(balance: balance::Balance<iota::IOTA>, initial_distribution_amount: u64, stake_subsidy_period_length: u64, stake_subsidy_decrease_rate: u16, ctx: &mut tx_context::TxContext): stake_subsidy::StakeSubsidy
-
- - - -
-Implementation - - -

-public(package) fun create(
-    balance: Balance<IOTA>,
-    initial_distribution_amount: u64,
-    stake_subsidy_period_length: u64,
-    stake_subsidy_decrease_rate: u16,
-    ctx: &mut TxContext,
-): StakeSubsidy \{
-    // Rate can't be higher than 100%.
-    assert!(
-        stake_subsidy_decrease_rate <= BASIS_POINT_DENOMINATOR as u16,
-        ESubsidyDecreaseRateTooLarge,
-    );
-
-    StakeSubsidy \{
-        balance,
-        distribution_counter: 0,
-        current_distribution_amount: initial_distribution_amount,
-        stake_subsidy_period_length,
-        stake_subsidy_decrease_rate,
-        extra_fields: bag::new(ctx),
-    }
-}
-
- - - -
- - - -## Function `advance_epoch` - -Advance the epoch counter and draw down the subsidy for the epoch. - - -

-public(friend) fun advance_epoch(self: &mut stake_subsidy::StakeSubsidy): balance::Balance<iota::IOTA>
-
- - - -
-Implementation - - -

-public(package) fun advance_epoch(self: &mut StakeSubsidy): Balance<IOTA> \{
-    // Take the minimum of the reward amount and the remaining balance in
-    // order to ensure we don't overdraft the remaining stake subsidy
-    // balance
-    let to_withdraw = math::min(self.current_distribution_amount, self.balance.value());
-
-    // Drawn down the subsidy for this epoch.
-    let stake_subsidy = self.balance.split(to_withdraw);
-
-    self.distribution_counter = self.distribution_counter + 1;
-
-    // Decrease the subsidy amount only when the current period ends.
-    if (self.distribution_counter % self.stake_subsidy_period_length == 0) \{
-        let decrease_amount = self.current_distribution_amount as u128
-            * (self.stake_subsidy_decrease_rate as u128) / BASIS_POINT_DENOMINATOR;
-        self.current_distribution_amount = self.current_distribution_amount - (decrease_amount as u64)
-    };
-
-    stake_subsidy
-}
-
- - - -
- - - -## Function `current_epoch_subsidy_amount` - -Returns the amount of stake subsidy to be added at the end of the current epoch. - - -

-public fun current_epoch_subsidy_amount(self: &stake_subsidy::StakeSubsidy): u64
-
- - - -
-Implementation - - -

-public fun current_epoch_subsidy_amount(self: &StakeSubsidy): u64 \{
-    math::min(self.current_distribution_amount, self.balance.value())
-}
-
- - - -
diff --git a/crates/iota-framework/packages/iota-system/sources/genesis.move b/crates/iota-framework/packages/iota-system/sources/genesis.move index fd0260adc15..d3d641d8f22 100644 --- a/crates/iota-framework/packages/iota-system/sources/genesis.move +++ b/crates/iota-framework/packages/iota-system/sources/genesis.move @@ -13,7 +13,6 @@ module iota_system::genesis { use iota_system::validator::{Self, Validator}; use iota_system::validator_set; use iota_system::iota_system_state_inner; - use iota_system::stake_subsidy; use iota_system::timelocked_staking; public struct GenesisValidatorMetadata has drop, copy { @@ -44,12 +43,6 @@ module iota_system::genesis { chain_start_timestamp_ms: u64, epoch_duration_ms: u64, - // Stake Subsidy parameters - stake_subsidy_start_epoch: u64, - stake_subsidy_initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - // Validator committee parameters max_validator_count: u64, min_validator_joining_stake: u64, @@ -106,7 +99,6 @@ module iota_system::genesis { assert!(iota_treasury_cap.total_supply() == pre_minted_supply, EWrongPreMintedSupply); - let subsidy_fund = balance::zero(); let storage_fund = balance::zero(); // Create all the `Validator` structs @@ -176,7 +168,6 @@ module iota_system::genesis { let system_parameters = iota_system_state_inner::create_system_parameters( genesis_chain_parameters.epoch_duration_ms, - genesis_chain_parameters.stake_subsidy_start_epoch, // Validator committee parameters genesis_chain_parameters.max_validator_count, @@ -188,14 +179,6 @@ module iota_system::genesis { ctx, ); - let stake_subsidy = stake_subsidy::create( - subsidy_fund, - genesis_chain_parameters.stake_subsidy_initial_distribution_amount, - genesis_chain_parameters.stake_subsidy_period_length, - genesis_chain_parameters.stake_subsidy_decrease_rate, - ctx, - ); - iota_system::create( iota_system_state_id, iota_treasury_cap, @@ -204,7 +187,6 @@ module iota_system::genesis { genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, system_parameters, - stake_subsidy, system_timelock_cap, ctx, ); diff --git a/crates/iota-framework/packages/iota-system/sources/iota_system.move b/crates/iota-framework/packages/iota-system/sources/iota_system.move index 704c8164e85..2a7453e75ce 100644 --- a/crates/iota-framework/packages/iota-system/sources/iota_system.move +++ b/crates/iota-framework/packages/iota-system/sources/iota_system.move @@ -50,7 +50,6 @@ module iota_system::iota_system { use iota_system::validator::Validator; use iota_system::validator_cap::UnverifiedValidatorOperationCap; use iota_system::iota_system_state_inner::{Self, SystemParameters, IotaSystemStateInner, IotaSystemStateInnerV2}; - use iota_system::stake_subsidy::StakeSubsidy; use iota_system::staking_pool::PoolTokenExchangeRate; use iota::dynamic_field; @@ -87,7 +86,6 @@ module iota_system::iota_system { protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: SystemParameters, - stake_subsidy: StakeSubsidy, system_timelock_cap: SystemTimelockCap, ctx: &mut TxContext, ) { @@ -98,7 +96,6 @@ module iota_system::iota_system { protocol_version, epoch_start_timestamp_ms, parameters, - stake_subsidy, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); @@ -706,12 +703,6 @@ module iota_system::iota_system { self.get_storage_fund_object_rebates() } - #[test_only] - public fun get_stake_subsidy_distribution_counter(wrapper: &mut IotaSystemState): u64 { - let self = load_system_state(wrapper); - self.get_stake_subsidy_distribution_counter() - } - /// Returns the total iota supply. public fun get_total_iota_supply(wrapper: &mut IotaSystemState): u64 { let self = load_system_state(wrapper); diff --git a/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move b/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move index 23eb13034d5..8588938d0ca 100644 --- a/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move +++ b/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move @@ -10,7 +10,6 @@ module iota_system::iota_system_state_inner { use iota_system::validator::{Self, Validator}; use iota_system::validator_set::{Self, ValidatorSet}; use iota_system::validator_cap::{UnverifiedValidatorOperationCap, ValidatorOperationCap}; - use iota_system::stake_subsidy::StakeSubsidy; use iota_system::storage_fund::{Self, StorageFund}; use iota_system::staking_pool::PoolTokenExchangeRate; use iota::vec_map::{Self, VecMap}; @@ -38,9 +37,6 @@ module iota_system::iota_system_state_inner { /// The duration of an epoch, in milliseconds. epoch_duration_ms: u64, - /// The starting epoch in which stake subsidies start being paid out - stake_subsidy_start_epoch: u64, - /// Maximum number of active validators at any moment. /// We do not allow the number of validators in any epoch to go above this. max_validator_count: u64, @@ -70,9 +66,6 @@ module iota_system::iota_system_state_inner { /// The duration of an epoch, in milliseconds. epoch_duration_ms: u64, - /// The starting epoch in which stake subsidies start being paid out - stake_subsidy_start_epoch: u64, - /// Minimum number of active validators at any moment. min_validator_count: u64, @@ -129,8 +122,6 @@ module iota_system::iota_system_state_inner { /// Note that in case we want to support validator address change in future, /// the reports should be based on validator ids validator_report_records: VecMap>, - /// Schedule of stake subsidies given out each epoch. - stake_subsidy: StakeSubsidy, /// Whether the system is running in a downgraded safe mode due to a non-recoverable bug. /// This is set whenever we failed to execute advance_epoch, and ended up executing advance_epoch_safe_mode. @@ -179,8 +170,6 @@ module iota_system::iota_system_state_inner { /// Note that in case we want to support validator address change in future, /// the reports should be based on validator ids validator_report_records: VecMap>, - /// Schedule of stake subsidies given out each epoch. - stake_subsidy: StakeSubsidy, /// Whether the system is running in a downgraded safe mode due to a non-recoverable bug. /// This is set whenever we failed to execute advance_epoch, and ended up executing advance_epoch_safe_mode. @@ -210,7 +199,6 @@ module iota_system::iota_system_state_inner { storage_charge: u64, storage_rebate: u64, storage_fund_balance: u64, - stake_subsidy_amount: u64, total_gas_fees: u64, total_stake_rewards_distributed: u64, burnt_leftover_amount: u64, @@ -243,7 +231,6 @@ module iota_system::iota_system_state_inner { protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: SystemParameters, - stake_subsidy: StakeSubsidy, ctx: &mut TxContext, ): IotaSystemStateInner { let validators = validator_set::new(validators, ctx); @@ -259,7 +246,6 @@ module iota_system::iota_system_state_inner { parameters, reference_gas_price, validator_report_records: vec_map::empty(), - stake_subsidy, safe_mode: false, safe_mode_storage_charges: balance::zero(), safe_mode_computation_rewards: balance::zero(), @@ -273,7 +259,6 @@ module iota_system::iota_system_state_inner { public(package) fun create_system_parameters( epoch_duration_ms: u64, - stake_subsidy_start_epoch: u64, // Validator committee parameters max_validator_count: u64, @@ -285,7 +270,6 @@ module iota_system::iota_system_state_inner { ): SystemParameters { SystemParameters { epoch_duration_ms, - stake_subsidy_start_epoch, max_validator_count, min_validator_joining_stake, validator_low_stake_threshold, @@ -306,7 +290,6 @@ module iota_system::iota_system_state_inner { parameters, reference_gas_price, validator_report_records, - stake_subsidy, safe_mode, safe_mode_storage_charges, safe_mode_computation_rewards, @@ -317,7 +300,6 @@ module iota_system::iota_system_state_inner { } = self; let SystemParameters { epoch_duration_ms, - stake_subsidy_start_epoch, max_validator_count, min_validator_joining_stake, validator_low_stake_threshold, @@ -334,7 +316,6 @@ module iota_system::iota_system_state_inner { storage_fund, parameters: SystemParametersV2 { epoch_duration_ms, - stake_subsidy_start_epoch, min_validator_count: 4, max_validator_count, min_validator_joining_stake, @@ -345,7 +326,6 @@ module iota_system::iota_system_state_inner { }, reference_gas_price, validator_report_records, - stake_subsidy, safe_mode, safe_mode_storage_charges, safe_mode_computation_rewards, @@ -840,7 +820,6 @@ module iota_system::iota_system_state_inner { epoch_start_timestamp_ms: u64, // Timestamp of the epoch start ctx: &mut TxContext, ) : Balance { - let prev_epoch_start_timestamp = self.epoch_start_timestamp_ms; self.epoch_start_timestamp_ms = epoch_start_timestamp_ms; let bps_denominator_u64 = BASIS_POINT_DENOMINATOR as u64; @@ -860,23 +839,6 @@ module iota_system::iota_system_state_inner { let storage_charge_value = storage_charge.value(); let computation_charge = computation_reward.value(); - // Include stake subsidy in the rewards given out to validators and stakers. - // Delay distributing any stake subsidies until after `stake_subsidy_start_epoch`. - // And if this epoch is shorter than the regular epoch duration, don't distribute any stake subsidy. - let stake_subsidy = - if (ctx.epoch() >= self.parameters.stake_subsidy_start_epoch && - epoch_start_timestamp_ms >= prev_epoch_start_timestamp + self.parameters.epoch_duration_ms) - { - self.stake_subsidy.advance_epoch() - } else { - balance::zero() - }; - - // The stake subsidy fund is disabled through parameter choices in GenesisCeremonyParameters, - // so it is always a zero balance now. It will be fully removed in a later step. - let stake_subsidy_amount = stake_subsidy.value(); - computation_reward.join(stake_subsidy); - let (mut total_validator_rewards, minted_tokens_amount, burnt_tokens_amount) = match_computation_reward_to_target_reward( validator_target_reward, computation_reward, @@ -933,8 +895,6 @@ module iota_system::iota_system_state_inner { storage_charge: storage_charge_value, storage_rebate: storage_rebate_amount, storage_fund_balance: self.storage_fund.total_balance(), - // TODO: remove(obsolete) - stake_subsidy_amount, total_gas_fees: computation_charge, total_stake_rewards_distributed: total_validator_rewards_distributed, burnt_leftover_amount, @@ -1104,11 +1064,6 @@ module iota_system::iota_system_state_inner { validators(self).get_candidate_validator_ref(validator_address) } - #[test_only] - public(package) fun get_stake_subsidy_distribution_counter(self: &IotaSystemStateInnerV2): u64 { - self.stake_subsidy.get_distribution_counter() - } - #[test_only] public(package) fun set_epoch_for_testing(self: &mut IotaSystemStateInnerV2, epoch_num: u64) { self.epoch = epoch_num diff --git a/crates/iota-framework/packages/iota-system/sources/stake_subsidy.move b/crates/iota-framework/packages/iota-system/sources/stake_subsidy.move deleted file mode 100644 index 411503f899e..00000000000 --- a/crates/iota-framework/packages/iota-system/sources/stake_subsidy.move +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -module iota_system::stake_subsidy { - use iota::balance::Balance; - use iota::math; - use iota::iota::IOTA; - use iota::bag::Bag; - use iota::bag; - - /* friend iota_system::genesis; */ - /* friend iota_system::iota_system_state_inner; */ - - /* #[test_only] */ - /* friend iota_system::governance_test_utils; */ - - public struct StakeSubsidy has store { - /// Balance of IOTA set aside for stake subsidies that will be drawn down over time. - balance: Balance, - - /// Count of the number of times stake subsidies have been distributed. - distribution_counter: u64, - - /// The amount of stake subsidy to be drawn down per distribution. - /// This amount decays and decreases over time. - current_distribution_amount: u64, - - /// Number of distributions to occur before the distribution amount decays. - stake_subsidy_period_length: u64, - - /// The rate at which the distribution amount decays at the end of each - /// period. Expressed in basis points. - stake_subsidy_decrease_rate: u16, - - /// Any extra fields that's not defined statically. - extra_fields: Bag, - } - - const BASIS_POINT_DENOMINATOR: u128 = 10000; - - const ESubsidyDecreaseRateTooLarge: u64 = 0; - - public(package) fun create( - balance: Balance, - initial_distribution_amount: u64, - stake_subsidy_period_length: u64, - stake_subsidy_decrease_rate: u16, - ctx: &mut TxContext, - ): StakeSubsidy { - // Rate can't be higher than 100%. - assert!( - stake_subsidy_decrease_rate <= BASIS_POINT_DENOMINATOR as u16, - ESubsidyDecreaseRateTooLarge, - ); - - StakeSubsidy { - balance, - distribution_counter: 0, - current_distribution_amount: initial_distribution_amount, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, - extra_fields: bag::new(ctx), - } - } - - /// Advance the epoch counter and draw down the subsidy for the epoch. - public(package) fun advance_epoch(self: &mut StakeSubsidy): Balance { - // Take the minimum of the reward amount and the remaining balance in - // order to ensure we don't overdraft the remaining stake subsidy - // balance - let to_withdraw = math::min(self.current_distribution_amount, self.balance.value()); - - // Drawn down the subsidy for this epoch. - let stake_subsidy = self.balance.split(to_withdraw); - - self.distribution_counter = self.distribution_counter + 1; - - // Decrease the subsidy amount only when the current period ends. - if (self.distribution_counter % self.stake_subsidy_period_length == 0) { - let decrease_amount = self.current_distribution_amount as u128 - * (self.stake_subsidy_decrease_rate as u128) / BASIS_POINT_DENOMINATOR; - self.current_distribution_amount = self.current_distribution_amount - (decrease_amount as u64) - }; - - stake_subsidy - } - - /// Returns the amount of stake subsidy to be added at the end of the current epoch. - public fun current_epoch_subsidy_amount(self: &StakeSubsidy): u64 { - math::min(self.current_distribution_amount, self.balance.value()) - } - - #[test_only] - /// Returns the number of distributions that have occurred. - public(package) fun get_distribution_counter(self: &StakeSubsidy): u64 { - self.distribution_counter - } -} diff --git a/crates/iota-framework/packages/iota-system/tests/governance_test_utils.move b/crates/iota-framework/packages/iota-system/tests/governance_test_utils.move index 31118abc210..de7c351f492 100644 --- a/crates/iota-framework/packages/iota-system/tests/governance_test_utils.move +++ b/crates/iota-framework/packages/iota-system/tests/governance_test_utils.move @@ -13,7 +13,6 @@ module iota_system::governance_test_utils { use iota_system::validator::{Self, Validator}; use iota_system::iota_system::{Self, IotaSystemState}; use iota_system::iota_system_state_inner; - use iota_system::stake_subsidy; use iota::test_scenario::{Self, Scenario}; use iota::test_utils; use iota::balance::Balance; @@ -64,7 +63,6 @@ module iota_system::governance_test_utils { ) { let system_parameters = iota_system_state_inner::create_system_parameters( 42, // epoch_duration_ms, doesn't matter what number we put here - 18446744073709551615, // stake_subsidy_start_epoch 150, // max_validator_count 1, // min_validator_joining_stake @@ -77,21 +75,13 @@ module iota_system::governance_test_utils { let mut iota_treasury_cap = iota::create_for_testing(ctx); // We mint the given amount so the system appears to have a total supply of iota_supply_amount, - // but we don't put it in the subsidy fund. + // but we burn it since we cannot put it anywhere. let iota_total_supply_balance = iota_treasury_cap.mint_balance( iota_supply_amount * MICROS_PER_IOTA, ctx, ); iota_total_supply_balance.destroy_for_testing(); - let stake_subsidy = stake_subsidy::create( - balance::zero(), - 0, // stake subsidy initial distribution amount - 18446744073709551615, // stake_subsidy_period_length - 0, // stake_subsidy_decrease_rate - ctx, - ); - let storage_fund = iota_treasury_cap.mint_balance( storage_fund_amount * MICROS_PER_IOTA, ctx, @@ -105,7 +95,6 @@ module iota_system::governance_test_utils { 1, // protocol version 0, // chain_start_timestamp_ms system_parameters, - stake_subsidy, timelock::new_system_timelock_cap_for_testing(), ctx, ) diff --git a/crates/iota-framework/packages/iota-system/tests/rewards_distribution_tests.move b/crates/iota-framework/packages/iota-system/tests/rewards_distribution_tests.move index 84fd41857ad..ab24aeb7482 100644 --- a/crates/iota-framework/packages/iota-system/tests/rewards_distribution_tests.move +++ b/crates/iota-framework/packages/iota-system/tests/rewards_distribution_tests.move @@ -69,7 +69,7 @@ module iota_system::rewards_distribution_tests { } #[test] - fun test_stake_subsidy() { + fun test_rewards_with_big_amounts() { set_up_iota_system_state_with_big_amounts(); let mut scenario_val = test_scenario::begin(VALIDATOR_ADDR_1); let scenario = &mut scenario_val; diff --git a/crates/iota-genesis-builder/src/lib.rs b/crates/iota-genesis-builder/src/lib.rs index c887d543c25..361ead33317 100644 --- a/crates/iota-genesis-builder/src/lib.rs +++ b/crates/iota-genesis-builder/src/lib.rs @@ -446,10 +446,6 @@ impl Builder { protocol_version, chain_start_timestamp_ms, epoch_duration_ms, - stake_subsidy_start_epoch, - stake_subsidy_initial_distribution_amount, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, max_validator_count, min_validator_joining_stake, validator_low_stake_threshold, @@ -547,10 +543,6 @@ impl Builder { ); assert_eq!(system_state.parameters.epoch_duration_ms, epoch_duration_ms); - assert_eq!( - system_state.parameters.stake_subsidy_start_epoch, - stake_subsidy_start_epoch, - ); assert_eq!( system_state.parameters.max_validator_count, max_validator_count, @@ -572,20 +564,6 @@ impl Builder { validator_low_stake_grace_period, ); - assert_eq!(system_state.stake_subsidy.distribution_counter, 0); - assert_eq!( - system_state.stake_subsidy.current_distribution_amount, - stake_subsidy_initial_distribution_amount, - ); - assert_eq!( - system_state.stake_subsidy.stake_subsidy_period_length, - stake_subsidy_period_length, - ); - assert_eq!( - system_state.stake_subsidy.stake_subsidy_decrease_rate, - stake_subsidy_decrease_rate, - ); - assert!(!system_state.safe_mode); assert_eq!( system_state.epoch_start_timestamp_ms, diff --git a/crates/iota-graphql-rpc/docs/examples.md b/crates/iota-graphql-rpc/docs/examples.md index e186b5db8ef..1ba129a1ee2 100644 --- a/crates/iota-graphql-rpc/docs/examples.md +++ b/crates/iota-graphql-rpc/docs/examples.md @@ -771,7 +771,6 @@ > systemStateVersion > systemParameters { > durationMs -> stakeSubsidyStartEpoch > minValidatorCount > maxValidatorCount > minValidatorJoiningStake @@ -779,14 +778,6 @@ > validatorVeryLowStakeThreshold > validatorLowStakeGracePeriod > } -> systemStakeSubsidy { -> balance -> distributionCounter -> currentDistributionAmount -> periodLength -> decreaseRate -> -> } > } >}
diff --git a/crates/iota-graphql-rpc/examples/iota_system_state_summary/iota_system_state_summary.graphql b/crates/iota-graphql-rpc/examples/iota_system_state_summary/iota_system_state_summary.graphql index 4b0129b16ed..4936777a36e 100644 --- a/crates/iota-graphql-rpc/examples/iota_system_state_summary/iota_system_state_summary.graphql +++ b/crates/iota-graphql-rpc/examples/iota_system_state_summary/iota_system_state_summary.graphql @@ -17,7 +17,6 @@ systemStateVersion systemParameters { durationMs - stakeSubsidyStartEpoch minValidatorCount maxValidatorCount minValidatorJoiningStake @@ -25,13 +24,5 @@ validatorVeryLowStakeThreshold validatorLowStakeGracePeriod } - systemStakeSubsidy { - balance - distributionCounter - currentDistributionAmount - periodLength - decreaseRate - - } } } diff --git a/crates/iota-graphql-rpc/schema/current_progress_schema.graphql b/crates/iota-graphql-rpc/schema/current_progress_schema.graphql index 616f6261d52..465812e8e6c 100644 --- a/crates/iota-graphql-rpc/schema/current_progress_schema.graphql +++ b/crates/iota-graphql-rpc/schema/current_progress_schema.graphql @@ -1066,10 +1066,6 @@ type Epoch { """ totalStakeRewards: BigInt """ - The amount added to total gas fees to make up the total stake rewards. - """ - totalStakeSubsidies: BigInt - """ The storage fund available in this epoch. This fund is used to redistribute storage fees from past transactions to future validators. @@ -1116,10 +1112,6 @@ type Epoch { """ systemParameters: SystemParameters """ - Parameters related to the subsidy that supplements staking rewards - """ - systemStakeSubsidy: StakeSubsidy - """ A commitment by the committee at the end of epoch on the contents of the live object set at that time. This can be used to verify state snapshots. @@ -3482,37 +3474,6 @@ enum StakeStatus { UNSTAKED } -""" -Parameters that control the distribution of the stake subsidy. -""" -type StakeSubsidy { - """ - IOTA set aside for stake subsidies -- reduces over time as stake - subsidies are paid out over time. - """ - balance: BigInt - """ - Number of times stake subsidies have been distributed subsidies are - distributed with other staking rewards, at the end of the epoch. - """ - distributionCounter: Int - """ - Amount of stake subsidy deducted from the balance per distribution -- - decays over time. - """ - currentDistributionAmount: BigInt - """ - Maximum number of stake subsidy distributions that occur with the same - distribution amount (before the amount is reduced). - """ - periodLength: Int - """ - Percentage of the current distribution amount to deduct at the end of - the current subsidy period, expressed in basis points. - """ - decreaseRate: Int -} - """ Represents a `0x3::staking_pool::StakedIota` Move object on-chain. """ @@ -3732,10 +3693,6 @@ type SystemParameters { """ durationMs: BigInt """ - The epoch at which stake subsidies start being paid out. - """ - stakeSubsidyStartEpoch: Int - """ The minimum number of active validators that the system supports. """ minValidatorCount: Int diff --git a/crates/iota-graphql-rpc/schema/draft_target_schema.graphql b/crates/iota-graphql-rpc/schema/draft_target_schema.graphql index ff077416b9a..dab8ef54ca6 100644 --- a/crates/iota-graphql-rpc/schema/draft_target_schema.graphql +++ b/crates/iota-graphql-rpc/schema/draft_target_schema.graphql @@ -592,7 +592,6 @@ type Epoch { totalCheckpoints: BigInt totalGasFees: BigInt totalStakeRewards: BigInt - totalStakeSubsidies: BigInt fundSize: BigInt netInflow: BigInt fundInflow: BigInt @@ -603,7 +602,6 @@ type Epoch { safeMode: SafeMode systemStateVersion: BigInt systemParameters: SystemParameters - systemStakeSubsidy: StakeSubsidy checkpoints( first: Int, @@ -642,7 +640,6 @@ type ProtocolConfigFeatureFlag { type SystemParameters { durationMs: BigInt - stakeSubsidyStartEpoch: Int minValidatorCount: Int maxValidatorCount: Int @@ -653,14 +650,6 @@ type SystemParameters { validatorLowStakeGracePeriod: Int } -type StakeSubsidy { - balance: BigInt - distributionCounter: Int - currentDistributionAmount: BigInt - periodLength: Int - decreaseRate: Int -} - type ValidatorSet { totalStake: BigInt diff --git a/crates/iota-graphql-rpc/src/types/epoch.rs b/crates/iota-graphql-rpc/src/types/epoch.rs index 390669484db..c8ee8137c7d 100644 --- a/crates/iota-graphql-rpc/src/types/epoch.rs +++ b/crates/iota-graphql-rpc/src/types/epoch.rs @@ -144,11 +144,6 @@ impl Epoch { .map(BigInt::from) } - /// The amount added to total gas fees to make up the total stake rewards. - async fn total_stake_subsidies(&self) -> Option { - self.stored.stake_subsidy_amount.map(BigInt::from) - } - /// The storage fund available in this epoch. /// This fund is used to redistribute storage fees from past transactions /// to future validators. diff --git a/crates/iota-graphql-rpc/src/types/mod.rs b/crates/iota-graphql-rpc/src/types/mod.rs index 7c1c026ab15..bc7d250b44e 100644 --- a/crates/iota-graphql-rpc/src/types/mod.rs +++ b/crates/iota-graphql-rpc/src/types/mod.rs @@ -42,7 +42,6 @@ pub(crate) mod protocol_config; pub(crate) mod query; pub(crate) mod safe_mode; pub(crate) mod stake; -pub(crate) mod stake_subsidy; pub(crate) mod storage_fund; pub(crate) mod string_input; pub(crate) mod system_parameters; diff --git a/crates/iota-graphql-rpc/src/types/stake_subsidy.rs b/crates/iota-graphql-rpc/src/types/stake_subsidy.rs deleted file mode 100644 index 4073c251747..00000000000 --- a/crates/iota-graphql-rpc/src/types/stake_subsidy.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use async_graphql::*; - -use super::big_int::BigInt; - -/// Parameters that control the distribution of the stake subsidy. -#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] -pub(crate) struct StakeSubsidy { - /// IOTA set aside for stake subsidies -- reduces over time as stake - /// subsidies are paid out over time. - pub balance: Option, - - /// Number of times stake subsidies have been distributed subsidies are - /// distributed with other staking rewards, at the end of the epoch. - pub distribution_counter: Option, - - /// Amount of stake subsidy deducted from the balance per distribution -- - /// decays over time. - pub current_distribution_amount: Option, - - /// Maximum number of stake subsidy distributions that occur with the same - /// distribution amount (before the amount is reduced). - pub period_length: Option, - - /// Percentage of the current distribution amount to deduct at the end of - /// the current subsidy period, expressed in basis points. - pub decrease_rate: Option, -} diff --git a/crates/iota-graphql-rpc/src/types/system_parameters.rs b/crates/iota-graphql-rpc/src/types/system_parameters.rs index f506aa69ef6..091fa23661f 100644 --- a/crates/iota-graphql-rpc/src/types/system_parameters.rs +++ b/crates/iota-graphql-rpc/src/types/system_parameters.rs @@ -11,9 +11,6 @@ pub(crate) struct SystemParameters { /// Target duration of an epoch, in milliseconds. pub duration_ms: Option, - /// The epoch at which stake subsidies start being paid out. - pub stake_subsidy_start_epoch: Option, - /// The minimum number of active validators that the system supports. pub min_validator_count: Option, diff --git a/crates/iota-graphql-rpc/src/types/system_state_summary.rs b/crates/iota-graphql-rpc/src/types/system_state_summary.rs index 10d330d0fe8..ad3057f131b 100644 --- a/crates/iota-graphql-rpc/src/types/system_state_summary.rs +++ b/crates/iota-graphql-rpc/src/types/system_state_summary.rs @@ -6,8 +6,8 @@ use async_graphql::*; use iota_types::iota_system_state::iota_system_state_summary::IotaSystemStateSummary as NativeSystemStateSummary; use super::{ - big_int::BigInt, gas::GasCostSummary, safe_mode::SafeMode, stake_subsidy::StakeSubsidy, - storage_fund::StorageFund, system_parameters::SystemParameters, + big_int::BigInt, gas::GasCostSummary, safe_mode::SafeMode, storage_fund::StorageFund, + system_parameters::SystemParameters, }; #[derive(Clone, Debug)] @@ -58,7 +58,6 @@ impl SystemStateSummary { async fn system_parameters(&self) -> Option { Some(SystemParameters { duration_ms: Some(BigInt::from(self.native.epoch_duration_ms)), - stake_subsidy_start_epoch: Some(self.native.stake_subsidy_start_epoch), // TODO min validator count can be extracted, but it requires some JSON RPC changes, // so we decided to wait on it for now. min_validator_count: None, @@ -77,17 +76,4 @@ impl SystemStateSummary { )), }) } - - /// Parameters related to the subsidy that supplements staking rewards - async fn system_stake_subsidy(&self) -> Option { - Some(StakeSubsidy { - balance: Some(BigInt::from(self.native.stake_subsidy_balance)), - distribution_counter: Some(self.native.stake_subsidy_distribution_counter), - current_distribution_amount: Some(BigInt::from( - self.native.stake_subsidy_current_distribution_amount, - )), - period_length: Some(self.native.stake_subsidy_period_length), - decrease_rate: Some(self.native.stake_subsidy_decrease_rate as u64), - }) - } } diff --git a/crates/iota-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap b/crates/iota-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap index 24d4617eb8c..5ed09165e63 100644 --- a/crates/iota-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap +++ b/crates/iota-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap @@ -1070,10 +1070,6 @@ type Epoch { """ totalStakeRewards: BigInt """ - The amount added to total gas fees to make up the total stake rewards. - """ - totalStakeSubsidies: BigInt - """ The storage fund available in this epoch. This fund is used to redistribute storage fees from past transactions to future validators. @@ -1120,10 +1116,6 @@ type Epoch { """ systemParameters: SystemParameters """ - Parameters related to the subsidy that supplements staking rewards - """ - systemStakeSubsidy: StakeSubsidy - """ A commitment by the committee at the end of epoch on the contents of the live object set at that time. This can be used to verify state snapshots. @@ -3486,37 +3478,6 @@ enum StakeStatus { UNSTAKED } -""" -Parameters that control the distribution of the stake subsidy. -""" -type StakeSubsidy { - """ - IOTA set aside for stake subsidies -- reduces over time as stake - subsidies are paid out over time. - """ - balance: BigInt - """ - Number of times stake subsidies have been distributed subsidies are - distributed with other staking rewards, at the end of the epoch. - """ - distributionCounter: Int - """ - Amount of stake subsidy deducted from the balance per distribution -- - decays over time. - """ - currentDistributionAmount: BigInt - """ - Maximum number of stake subsidy distributions that occur with the same - distribution amount (before the amount is reduced). - """ - periodLength: Int - """ - Percentage of the current distribution amount to deduct at the end of - the current subsidy period, expressed in basis points. - """ - decreaseRate: Int -} - """ Represents a `0x3::staking_pool::StakedIota` Move object on-chain. """ @@ -3736,10 +3697,6 @@ type SystemParameters { """ durationMs: BigInt """ - The epoch at which stake subsidies start being paid out. - """ - stakeSubsidyStartEpoch: Int - """ The minimum number of active validators that the system supports. """ minValidatorCount: Int diff --git a/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/down.sql b/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/down.sql new file mode 100644 index 00000000000..94f7229f3b8 --- /dev/null +++ b/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/down.sql @@ -0,0 +1,2 @@ +ALTER TABLE epochs +ADD COLUMN stake_subsidy_amount BIGINT; diff --git a/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/up.sql b/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/up.sql new file mode 100644 index 00000000000..8a6cf370e46 --- /dev/null +++ b/crates/iota-indexer/migrations/2024-07-16-092139_remove_stake_subsidy_amount/up.sql @@ -0,0 +1,2 @@ +ALTER TABLE epochs +DROP COLUMN stake_subsidy_amount; diff --git a/crates/iota-indexer/src/apis/governance_api.rs b/crates/iota-indexer/src/apis/governance_api.rs index e94720e8131..15655d366cd 100644 --- a/crates/iota-indexer/src/apis/governance_api.rs +++ b/crates/iota-indexer/src/apis/governance_api.rs @@ -51,14 +51,10 @@ impl GovernanceReadApi { let system_state_summary: IotaSystemStateSummary = self.get_latest_iota_system_state().await?; let epoch = system_state_summary.epoch; - let stake_subsidy_start_epoch = system_state_summary.stake_subsidy_start_epoch; let exchange_rate_table = exchange_rates(self, system_state_summary).await?; - let apys = iota_json_rpc::governance_api::calculate_apys( - stake_subsidy_start_epoch, - exchange_rate_table, - ); + let apys = iota_json_rpc::governance_api::calculate_apys(exchange_rate_table); Ok(ValidatorApys { apys, epoch }) } diff --git a/crates/iota-indexer/src/models/epoch.rs b/crates/iota-indexer/src/models/epoch.rs index 5e0c0cd7916..779624480c2 100644 --- a/crates/iota-indexer/src/models/epoch.rs +++ b/crates/iota-indexer/src/models/epoch.rs @@ -10,6 +10,7 @@ use crate::{errors::IndexerError, schema::epochs, types::IndexedEpochInfo}; #[derive(Queryable, Insertable, Debug, Clone, Default)] #[diesel(table_name = epochs)] +#[diesel(check_for_backend(diesel::pg::Pg))] pub struct StoredEpochInfo { pub epoch: i64, pub first_checkpoint_id: i64, @@ -24,8 +25,6 @@ pub struct StoredEpochInfo { pub epoch_end_timestamp: Option, pub storage_charge: Option, pub storage_rebate: Option, - // TODO: remove(obsolete) - pub stake_subsidy_amount: Option, pub total_gas_fees: Option, pub total_stake_rewards_distributed: Option, pub burnt_leftover_amount: Option, @@ -36,6 +35,7 @@ pub struct StoredEpochInfo { #[derive(Queryable, Selectable, Clone)] #[diesel(table_name = epochs)] +#[diesel(check_for_backend(diesel::pg::Pg))] pub struct QueryableEpochInfo { pub epoch: i64, pub first_checkpoint_id: i64, @@ -49,8 +49,6 @@ pub struct QueryableEpochInfo { pub epoch_end_timestamp: Option, pub storage_charge: Option, pub storage_rebate: Option, - // TODO: remove(obsolete) - pub stake_subsidy_amount: Option, pub total_gas_fees: Option, pub total_stake_rewards_distributed: Option, pub burnt_leftover_amount: Option, @@ -88,7 +86,6 @@ impl StoredEpochInfo { epoch_end_timestamp: e.epoch_end_timestamp.map(|v| v as i64), storage_charge: e.storage_charge.map(|v| v as i64), storage_rebate: e.storage_rebate.map(|v| v as i64), - stake_subsidy_amount: e.stake_subsidy_amount.map(|v| v as i64), total_gas_fees: e.total_gas_fees.map(|v| v as i64), total_stake_rewards_distributed: e.total_stake_rewards_distributed.map(|v| v as i64), burnt_leftover_amount: e.burnt_leftover_amount.map(|v| v as i64), @@ -124,7 +121,6 @@ impl From<&StoredEpochInfo> for Option { epoch_end_timestamp: info.epoch_end_timestamp.map(|v| v as u64)?, storage_charge: info.storage_charge.map(|v| v as u64)?, storage_rebate: info.storage_rebate.map(|v| v as u64)?, - stake_subsidy_amount: info.stake_subsidy_amount.map(|v| v as u64)?, total_gas_fees: info.total_gas_fees.map(|v| v as u64)?, total_stake_rewards_distributed: info .total_stake_rewards_distributed diff --git a/crates/iota-indexer/src/schema.patch b/crates/iota-indexer/src/schema.patch index 414a955703d..4eca2333f51 100644 --- a/crates/iota-indexer/src/schema.patch +++ b/crates/iota-indexer/src/schema.patch @@ -1,7 +1,8 @@ diff --git a/crates/iota-indexer/src/schema.rs b/crates/iota-indexer/src/schema.rs --- a/crates/iota-indexer/src/schema.rs +++ b/crates/iota-indexer/src/schema.rs -@@ -1 +1,3 @@ +@@ -1 +1,4 @@ +// Copyright (c) Mysten Labs, Inc. ++// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 // @generated automatically by Diesel CLI. diff --git a/crates/iota-indexer/src/schema.rs b/crates/iota-indexer/src/schema.rs index fc0f1aaa0f8..dae5b630010 100644 --- a/crates/iota-indexer/src/schema.rs +++ b/crates/iota-indexer/src/schema.rs @@ -48,7 +48,6 @@ diesel::table! { epoch_end_timestamp -> Nullable, storage_charge -> Nullable, storage_rebate -> Nullable, - stake_subsidy_amount -> Nullable, total_gas_fees -> Nullable, total_stake_rewards_distributed -> Nullable, burnt_leftover_amount -> Nullable, diff --git a/crates/iota-indexer/src/store/pg_indexer_store.rs b/crates/iota-indexer/src/store/pg_indexer_store.rs index b0091ae8744..e7f23657d3e 100644 --- a/crates/iota-indexer/src/store/pg_indexer_store.rs +++ b/crates/iota-indexer/src/store/pg_indexer_store.rs @@ -723,7 +723,6 @@ impl PgIndexerStore { epochs::epoch_end_timestamp.eq(excluded(epochs::epoch_end_timestamp)), epochs::storage_charge.eq(excluded(epochs::storage_charge)), epochs::storage_rebate.eq(excluded(epochs::storage_rebate)), - epochs::stake_subsidy_amount.eq(excluded(epochs::stake_subsidy_amount)), epochs::total_gas_fees.eq(excluded(epochs::total_gas_fees)), epochs::total_stake_rewards_distributed .eq(excluded(epochs::total_stake_rewards_distributed)), diff --git a/crates/iota-indexer/src/types.rs b/crates/iota-indexer/src/types.rs index 7efe63a4c99..ea73d4024f7 100644 --- a/crates/iota-indexer/src/types.rs +++ b/crates/iota-indexer/src/types.rs @@ -100,8 +100,6 @@ pub struct IndexedEpochInfo { pub epoch_end_timestamp: Option, pub storage_charge: Option, pub storage_rebate: Option, - // TODO: remove(obsolete) - pub stake_subsidy_amount: Option, pub total_gas_fees: Option, pub total_stake_rewards_distributed: Option, pub burnt_leftover_amount: Option, @@ -149,7 +147,6 @@ impl IndexedEpochInfo { storage_charge: Some(event.storage_charge), storage_rebate: Some(event.storage_rebate), burnt_leftover_amount: Some(event.burnt_leftover_amount), - stake_subsidy_amount: Some(event.stake_subsidy_amount), total_gas_fees: Some(event.total_gas_fees), total_stake_rewards_distributed: Some(event.total_stake_rewards_distributed), epoch_commitments: last_checkpoint_summary diff --git a/crates/iota-json-rpc-types/src/iota_extended.rs b/crates/iota-json-rpc-types/src/iota_extended.rs index 76580170e95..794c675cfbc 100644 --- a/crates/iota-json-rpc-types/src/iota_extended.rs +++ b/crates/iota-json-rpc-types/src/iota_extended.rs @@ -88,9 +88,6 @@ pub struct EndOfEpochInfo { pub storage_fund_balance: u64, #[schemars(with = "BigInt")] #[serde_as(as = "BigInt")] - pub stake_subsidy_amount: u64, - #[schemars(with = "BigInt")] - #[serde_as(as = "BigInt")] pub total_gas_fees: u64, #[schemars(with = "BigInt")] #[serde_as(as = "BigInt")] diff --git a/crates/iota-json-rpc/src/coin_api.rs b/crates/iota-json-rpc/src/coin_api.rs index 238e6ba1ff4..5e0f03ec470 100644 --- a/crates/iota-json-rpc/src/coin_api.rs +++ b/crates/iota-json-rpc/src/coin_api.rs @@ -1310,8 +1310,7 @@ mod tests { id::UID, iota_system_state::{ iota_system_state_inner_v1::{ - IotaSystemStateInnerV1, StakeSubsidyV1, StorageFundV1, SystemParametersV1, - ValidatorSetV1, + IotaSystemStateInnerV1, StorageFundV1, SystemParametersV1, ValidatorSetV1, }, IotaSystemState, }, @@ -1473,7 +1472,6 @@ mod tests { }, parameters: SystemParametersV1 { epoch_duration_ms: Default::default(), - stake_subsidy_start_epoch: Default::default(), max_validator_count: Default::default(), min_validator_joining_stake: Default::default(), validator_low_stake_threshold: Default::default(), @@ -1485,14 +1483,6 @@ mod tests { validator_report_records: VecMap { contents: Default::default(), }, - stake_subsidy: StakeSubsidyV1 { - balance: iota_types::balance::Balance::new(Default::default()), - distribution_counter: Default::default(), - current_distribution_amount: Default::default(), - stake_subsidy_period_length: Default::default(), - stake_subsidy_decrease_rate: Default::default(), - extra_fields: Default::default(), - }, safe_mode: Default::default(), safe_mode_storage_charges: iota_types::balance::Balance::new(Default::default()), safe_mode_computation_rewards: iota_types::balance::Balance::new(Default::default()), diff --git a/crates/iota-json-rpc/src/governance_api.rs b/crates/iota-json-rpc/src/governance_api.rs index 81a6e319326..7143d396644 100644 --- a/crates/iota-json-rpc/src/governance_api.rs +++ b/crates/iota-json-rpc/src/governance_api.rs @@ -439,10 +439,7 @@ impl GovernanceReadApiServer for GovernanceReadApi { .await .map_err(|e| error_object_from_rpc(e.into()))?; - let apys = calculate_apys( - system_state_summary.stake_subsidy_start_epoch, - exchange_rate_table, - ); + let apys = calculate_apys(exchange_rate_table); Ok(ValidatorApys { apys, @@ -451,18 +448,15 @@ impl GovernanceReadApiServer for GovernanceReadApi { } } -pub fn calculate_apys( - // TODO: Will be properly fixed in the stake subsidy removal PR. - _stake_subsidy_start_epoch: u64, - exchange_rate_table: Vec, -) -> Vec { +pub fn calculate_apys(exchange_rate_table: Vec) -> Vec { let mut apys = vec![]; for rates in exchange_rate_table.into_iter().filter(|r| r.active) { + let exchange_rates_count = rates.rates.len(); let exchange_rates = rates.rates.into_iter().map(|(_, rate)| rate); - // we need at least 2 data points to calculate apy - let average_apy = if exchange_rates.clone().count() >= 2 { + // We need at least 2 data points to calculate apy. + let average_apy = if exchange_rates_count >= 2 { // rates are sorted by epoch in descending order. let er_e = exchange_rates.clone().dropping(1); // rate e+1 @@ -515,7 +509,7 @@ fn test_apys_calculation_filter_outliers() { }) .collect(); - let apys = calculate_apys(20, exchange_rates); + let apys = calculate_apys(exchange_rates); for apy in apys { println!("{}: {}", address_map[&apy.address], apy.apy); diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap index 1131f97c10b..560f4a795b4 100644 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap +++ b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap @@ -9,10 +9,6 @@ parameters: protocol_version: 1 allow_insertion_of_extra_objects: true epoch_duration_ms: 86400000 - stake_subsidy_start_epoch: 18446744073709551615 - stake_subsidy_initial_distribution_amount: 0 - stake_subsidy_period_length: 18446744073709551615 - stake_subsidy_decrease_rate: 0 accounts: - address: "0xebb23f93d022ac213e99ac7d85b7f7e1e4a18f045b379755565cffa08804c9a1" gas_amounts: diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap index 39f2a38d39d..a25b55f501b 100644 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap +++ b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap @@ -8,7 +8,7 @@ system_state_version: 1 iota_treasury_cap: inner: id: - id: "0x55df4a856f8c07274add7993d03fe417e08761f6c8009a8dd3727404334c556e" + id: "0x3e2f7d1d26f3d94f8be18d0e3356fa702e334244e1731be70db6d6537efb94cb" total_supply: value: "751500000000000000" validators: @@ -246,13 +246,13 @@ validators: next_epoch_worker_address: ~ extra_fields: id: - id: "0x5c5aced05ccd039462a609e49e0f98cd98ef5b1917a087bf7729f7eff8537d33" + id: "0xe5350d62968644c8df8ec8e7b665d4321ce455026466f6e9de9a27241b81a7ee" size: 0 voting_power: 10000 - operation_cap_id: "0x951a98652b99eb5f4b3e1060cb78270837b8b9a8cbf83e33f89dbcf414ae4526" + operation_cap_id: "0x9359fe9a2560ec754b04003a97c5187e70341155052bdfcfe3cd350dbb334cc9" gas_price: 1000 staking_pool: - id: "0x5fbe894cc9ec9542be429d6d96c494a639fe3fd141aff63f6dfbbf3833cd7046" + id: "0xf1c8333a54f569a43534eb89c47d67018e8e3a2c19bf0c7ccaefd3d5d79e8182" activation_epoch: 0 deactivation_epoch: ~ iota_balance: 1500000000000000 @@ -260,14 +260,14 @@ validators: value: 0 pool_token_balance: 1500000000000000 exchange_rates: - id: "0x870e0e478aa1093f4ccf258a3862a6b227e4e3e12778c7303bc7eccdc85c9e73" + id: "0xe35e69f3e31f2700efaa7c656b1aba51109a7a54dc368ea7c6103c4720873ec4" size: 1 pending_stake: 0 pending_total_iota_withdraw: 0 pending_pool_token_withdraw: 0 extra_fields: id: - id: "0x8916d68b3427fee920b262b21f66cbdcc823081af42549a5fb1e5dc8106eea25" + id: "0x8513c7b4e769ce35bae25317f38fca34c97e435bb0310d1931b594ac35cc1e7b" size: 0 commission_rate: 200 next_epoch_stake: 1500000000000000 @@ -275,27 +275,27 @@ validators: next_epoch_commission_rate: 200 extra_fields: id: - id: "0xb133f4934b3ded0ebdbf91ecbfbf182a05adfadc00ab1f53746947c0f67042d4" + id: "0xf1dba5a8cb0785c207b6d3a04395636ad61d99e98815d7165c77406395c209c9" size: 0 pending_active_validators: contents: - id: "0xecd71c4bdffa56b1d65d3ac79ac1b494b91140af7f4d3feed012a4f719cd306a" + id: "0x350c14b87abe377e2217ec552e0f96ae8533b187d23411202b2a5bee201b3508" size: 0 pending_removals: [] staking_pool_mappings: - id: "0x1f6a2ccad8b1d4d6616d59f63a53c927cb38ddad6672ab5641342775ec7e5db2" + id: "0x196b0c9496f73100408450648be2d2fe5d7921084ce62281e4e3e3d3102b9303" size: 1 inactive_validators: - id: "0x352ae654408548cc5042223abf58ff0d64207140710023973a834323c63d65db" + id: "0xedf8b88c2d612deec19bb45d450af4f067f0a0d77d8d56ea8ad27fb441ce4499" size: 0 validator_candidates: - id: "0x1081035e54b748647bdcbdfb4ff1c764d138a104f5bf091244b9fe87f7bb896b" + id: "0x273862d974448f91c9673a7eff7b423f6f1e9aca533ca4793cc256edff4a776a" size: 0 at_risk_validators: contents: [] extra_fields: id: - id: "0xf059134bbd10b59f25b4132d2760948f5cb94d87bfe67f3bfe3082ffc00bd527" + id: "0xa2446bbd18953945032a7e72237272749536b1e83395757424741d7d53d3de73" size: 0 storage_fund: total_object_storage_rebates: @@ -304,7 +304,6 @@ storage_fund: value: 0 parameters: epoch_duration_ms: 86400000 - stake_subsidy_start_epoch: 18446744073709551615 max_validator_count: 150 min_validator_joining_stake: 2000000000000000 validator_low_stake_threshold: 1500000000000000 @@ -312,22 +311,11 @@ parameters: validator_low_stake_grace_period: 7 extra_fields: id: - id: "0x22943d826cf3be335016ee6761f0a81d89769af2dc34adc872e0e70180b27205" + id: "0x98dcee75b4d98a7abdb8267f168db976c6f24c0376095a2fc71163b39427817c" size: 0 reference_gas_price: 1000 validator_report_records: contents: [] -stake_subsidy: - balance: - value: 0 - distribution_counter: 0 - current_distribution_amount: 0 - stake_subsidy_period_length: 18446744073709551615 - stake_subsidy_decrease_rate: 0 - extra_fields: - id: - id: "0xe70d4fb2a7c58d5c850afff4a6831a6ee93583c2ee2b267d98827b9d46327c61" - size: 0 safe_mode: false safe_mode_storage_charges: value: 0 @@ -338,5 +326,5 @@ safe_mode_non_refundable_storage_fee: 0 epoch_start_timestamp_ms: 10 extra_fields: id: - id: "0x228575dee4eb80dafbeed59bf49199f0f1019434c368db96babe1cb8aafca6b5" + id: "0xb2d037cb77e804228b6d2d9a135cfda241a65b1b80cba7edb05edd6fdbe4bdf0" size: 0 diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap deleted file mode 100644 index f1540c076eb..00000000000 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/iota-config/tests/snapshot_tests.rs -expression: genesis.clock() ---- -id: - id: "0x0000000000000000000000000000000000000000000000000000000000000006" -timestamp_ms: 0 - diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-5.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-5.snap deleted file mode 100644 index ce70edd3c0f..00000000000 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-5.snap +++ /dev/null @@ -1,444 +0,0 @@ ---- -source: crates/iota-config/tests/snapshot_tests.rs -expression: genesis.iota_system_object() ---- -info: - id: "0x0000000000000000000000000000000000000005" -epoch: 0 -validators: - validator_stake: 1 - delegation_stake: 0 - quorum_stake_threshold: 1 - active_validators: - - metadata: - iota_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" - pubkey_bytes: - - 153 - - 242 - - 94 - - 246 - - 31 - - 128 - - 50 - - 185 - - 20 - - 99 - - 100 - - 96 - - 152 - - 44 - - 92 - - 198 - - 241 - - 52 - - 239 - - 29 - - 218 - - 231 - - 102 - - 87 - - 242 - - 203 - - 254 - - 193 - - 235 - - 252 - - 141 - - 9 - - 115 - - 116 - - 8 - - 13 - - 246 - - 252 - - 240 - - 220 - - 184 - - 188 - - 75 - - 13 - - 142 - - 10 - - 245 - - 216 - - 14 - - 187 - - 255 - - 43 - - 76 - - 89 - - 159 - - 84 - - 244 - - 45 - - 99 - - 18 - - 223 - - 195 - - 20 - - 39 - - 96 - - 120 - - 193 - - 204 - - 52 - - 126 - - 187 - - 190 - - 197 - - 25 - - 139 - - 226 - - 88 - - 81 - - 63 - - 56 - - 107 - - 147 - - 13 - - 2 - - 194 - - 116 - - 154 - - 128 - - 62 - - 35 - - 48 - - 149 - - 94 - - 189 - - 26 - - 16 - network_pubkey_bytes: - - 68 - - 88 - - 50 - - 114 - - 78 - - 89 - - 121 - - 78 - - 114 - - 97 - - 112 - - 79 - - 43 - - 103 - - 66 - - 74 - - 112 - - 49 - - 115 - - 72 - - 81 - - 50 - - 86 - - 86 - - 115 - - 81 - - 111 - - 50 - - 103 - - 104 - - 109 - - 55 - - 97 - - 65 - - 57 - - 119 - - 86 - - 120 - - 78 - - 74 - - 49 - - 51 - - 85 - - 61 - proof_of_possession_bytes: - - 153 - - 27 - - 35 - - 60 - - 191 - - 127 - - 114 - - 42 - - 232 - - 130 - - 78 - - 8 - - 171 - - 176 - - 156 - - 1 - - 218 - - 41 - - 15 - - 12 - - 200 - - 251 - - 161 - - 118 - - 204 - - 12 - - 207 - - 20 - - 169 - - 155 - - 183 - - 78 - - 162 - - 200 - - 239 - - 217 - - 147 - - 103 - - 123 - - 109 - - 224 - - 32 - - 216 - - 58 - - 188 - - 101 - - 131 - - 137 - name: - - 48 - net_address: [] - next_epoch_stake: 1 - next_epoch_delegation: 0 - next_epoch_gas_price: 1 - next_epoch_commission_rate: 0 - stake_amount: 1 - pending_stake: 0 - pending_withdraw: 0 - gas_price: 1 - delegation_staking_pool: - validator_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" - starting_epoch: 1 - iota_balance: 0 - rewards_pool: - value: 0 - delegation_token_supply: - value: 0 - pending_delegations: [] - pending_withdraws: [] - commission_rate: 0 - pending_validators: [] - pending_removals: [] - next_epoch_validators: - - iota_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" - pubkey_bytes: - - 153 - - 242 - - 94 - - 246 - - 31 - - 128 - - 50 - - 185 - - 20 - - 99 - - 100 - - 96 - - 152 - - 44 - - 92 - - 198 - - 241 - - 52 - - 239 - - 29 - - 218 - - 231 - - 102 - - 87 - - 242 - - 203 - - 254 - - 193 - - 235 - - 252 - - 141 - - 9 - - 115 - - 116 - - 8 - - 13 - - 246 - - 252 - - 240 - - 220 - - 184 - - 188 - - 75 - - 13 - - 142 - - 10 - - 245 - - 216 - - 14 - - 187 - - 255 - - 43 - - 76 - - 89 - - 159 - - 84 - - 244 - - 45 - - 99 - - 18 - - 223 - - 195 - - 20 - - 39 - - 96 - - 120 - - 193 - - 204 - - 52 - - 126 - - 187 - - 190 - - 197 - - 25 - - 139 - - 226 - - 88 - - 81 - - 63 - - 56 - - 107 - - 147 - - 13 - - 2 - - 194 - - 116 - - 154 - - 128 - - 62 - - 35 - - 48 - - 149 - - 94 - - 189 - - 26 - - 16 - network_pubkey_bytes: - - 68 - - 88 - - 50 - - 114 - - 78 - - 89 - - 121 - - 78 - - 114 - - 97 - - 112 - - 79 - - 43 - - 103 - - 66 - - 74 - - 112 - - 49 - - 115 - - 72 - - 81 - - 50 - - 86 - - 86 - - 115 - - 81 - - 111 - - 50 - - 103 - - 104 - - 109 - - 55 - - 97 - - 65 - - 57 - - 119 - - 86 - - 120 - - 78 - - 74 - - 49 - - 51 - - 85 - - 61 - proof_of_possession_bytes: - - 153 - - 27 - - 35 - - 60 - - 191 - - 127 - - 114 - - 42 - - 232 - - 130 - - 78 - - 8 - - 171 - - 176 - - 156 - - 1 - - 218 - - 41 - - 15 - - 12 - - 200 - - 251 - - 161 - - 118 - - 204 - - 12 - - 207 - - 20 - - 169 - - 155 - - 183 - - 78 - - 162 - - 200 - - 239 - - 217 - - 147 - - 103 - - 123 - - 109 - - 224 - - 32 - - 216 - - 58 - - 188 - - 101 - - 131 - - 137 - name: - - 48 - net_address: [] - next_epoch_stake: 1 - next_epoch_delegation: 0 - next_epoch_gas_price: 1 - next_epoch_commission_rate: 0 - pending_delegation_switches: - contents: [] -treasury_cap: - value: 100000000000001 -storage_fund: - value: 100000000000000 -parameters: - min_validator_stake: 100000000000000 - max_validator_candidate_count: 100 - storage_gas_price: 1 -reference_gas_price: 0 -validator_report_records: - contents: [] -next_epoch_stake_subsidy: 1000000 - diff --git a/crates/iota-types/src/event.rs b/crates/iota-types/src/event.rs index dc48d3eb8c9..2f4acfa998e 100755 --- a/crates/iota-types/src/event.rs +++ b/crates/iota-types/src/event.rs @@ -172,8 +172,6 @@ pub struct SystemEpochInfoEvent { pub storage_charge: u64, pub storage_rebate: u64, pub storage_fund_balance: u64, - // TODO: remove(obsolete) - pub stake_subsidy_amount: u64, pub total_gas_fees: u64, pub total_stake_rewards_distributed: u64, pub burnt_leftover_amount: u64, diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs index 5aa9bcc747c..fe544cef668 100644 --- a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs +++ b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs @@ -44,9 +44,6 @@ pub struct SystemParametersV1 { /// The duration of an epoch, in milliseconds. pub epoch_duration_ms: u64, - /// The starting epoch in which stake subsidies start being paid out - pub stake_subsidy_start_epoch: u64, - /// Maximum number of active validators at any moment. /// We do not allow the number of validators in any epoch to go above this. pub max_validator_count: u64, @@ -478,7 +475,6 @@ pub struct IotaSystemStateInnerV1 { pub parameters: SystemParametersV1, pub reference_gas_price: u64, pub validator_report_records: VecMap>, - pub stake_subsidy: StakeSubsidyV1, pub safe_mode: bool, pub safe_mode_storage_charges: Balance, pub safe_mode_computation_rewards: Balance, @@ -489,29 +485,6 @@ pub struct IotaSystemStateInnerV1 { // TODO: Use getters instead of all pub. } -#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] -pub struct StakeSubsidyV1 { - /// Balance of IOTA set aside for stake subsidies that will be drawn down - /// over time. - pub balance: Balance, - - /// Count of the number of times stake subsidies have been distributed. - pub distribution_counter: u64, - - /// The amount of stake subsidy to be drawn down per distribution. - /// This amount decays and decreases over time. - pub current_distribution_amount: u64, - - /// Number of distributions to occur before the distribution amount decays. - pub stake_subsidy_period_length: u64, - - /// The rate at which the distribution amount decays at the end of each - /// period. Expressed in basis points. - pub stake_subsidy_decrease_rate: u16, - - pub extra_fields: Bag, -} - impl IotaSystemStateTrait for IotaSystemStateInnerV1 { fn epoch(&self) -> u64 { self.epoch @@ -666,7 +639,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV1 { storage_fund, parameters: SystemParametersV1 { - stake_subsidy_start_epoch, epoch_duration_ms, max_validator_count, min_validator_joining_stake, @@ -680,15 +652,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV1 { VecMap { contents: validator_report_records, }, - stake_subsidy: - StakeSubsidyV1 { - balance: stake_subsidy_balance, - distribution_counter: stake_subsidy_distribution_counter, - current_distribution_amount: stake_subsidy_current_distribution_amount, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, - extra_fields: _, - }, safe_mode, safe_mode_storage_charges, safe_mode_computation_rewards, @@ -713,11 +676,7 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV1 { safe_mode_storage_rebates, safe_mode_non_refundable_storage_fee, epoch_start_timestamp_ms, - stake_subsidy_start_epoch, epoch_duration_ms, - stake_subsidy_distribution_counter, - stake_subsidy_balance: stake_subsidy_balance.value(), - stake_subsidy_current_distribution_amount, total_stake, active_validators: active_validators .into_iter() @@ -745,8 +704,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV1 { validator_low_stake_threshold, validator_very_low_stake_threshold, validator_low_stake_grace_period, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, } } } diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs index 9e7efdcec5b..b05e93b436a 100644 --- a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs +++ b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs @@ -22,7 +22,7 @@ use crate::{ iota_system_state::{ epoch_start_iota_system_state::EpochStartSystemState, get_validators_from_table_vec, - iota_system_state_inner_v1::{StakeSubsidyV1, StorageFundV1, ValidatorSetV1}, + iota_system_state_inner_v1::{StorageFundV1, ValidatorSetV1}, }, storage::ObjectStore, }; @@ -33,9 +33,6 @@ pub struct SystemParametersV2 { /// The duration of an epoch, in milliseconds. pub epoch_duration_ms: u64, - /// The starting epoch in which stake subsidies start being paid out - pub stake_subsidy_start_epoch: u64, - /// Minimum number of active validators at any moment. pub min_validator_count: u64, @@ -76,7 +73,6 @@ pub struct IotaSystemStateInnerV2 { pub parameters: SystemParametersV2, pub reference_gas_price: u64, pub validator_report_records: VecMap>, - pub stake_subsidy: StakeSubsidyV1, pub safe_mode: bool, pub safe_mode_storage_charges: Balance, pub safe_mode_computation_rewards: Balance, @@ -241,7 +237,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV2 { storage_fund, parameters: SystemParametersV2 { - stake_subsidy_start_epoch, epoch_duration_ms, min_validator_count: _, // TODO: Add it to RPC layer in the future. max_validator_count, @@ -256,15 +251,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV2 { VecMap { contents: validator_report_records, }, - stake_subsidy: - StakeSubsidyV1 { - balance: stake_subsidy_balance, - distribution_counter: stake_subsidy_distribution_counter, - current_distribution_amount: stake_subsidy_current_distribution_amount, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, - extra_fields: _, - }, safe_mode, safe_mode_storage_charges, safe_mode_computation_rewards, @@ -289,11 +275,7 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV2 { safe_mode_storage_rebates, safe_mode_non_refundable_storage_fee, epoch_start_timestamp_ms, - stake_subsidy_start_epoch, epoch_duration_ms, - stake_subsidy_distribution_counter, - stake_subsidy_balance: stake_subsidy_balance.value(), - stake_subsidy_current_distribution_amount, total_stake, active_validators: active_validators .into_iter() @@ -321,8 +303,6 @@ impl IotaSystemStateTrait for IotaSystemStateInnerV2 { validator_low_stake_threshold, validator_very_low_stake_threshold, validator_low_stake_grace_period, - stake_subsidy_period_length, - stake_subsidy_decrease_rate, } } } diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_summary.rs b/crates/iota-types/src/iota_system_state/iota_system_state_summary.rs index 72cd0c50b87..8cef0c17326 100644 --- a/crates/iota-types/src/iota_system_state/iota_system_state_summary.rs +++ b/crates/iota-types/src/iota_system_state/iota_system_state_summary.rs @@ -96,11 +96,6 @@ pub struct IotaSystemStateSummary { #[serde_as(as = "Readable, _>")] pub epoch_duration_ms: u64, - /// The starting epoch in which stake subsidies start being paid out - #[schemars(with = "BigInt")] - #[serde_as(as = "Readable, _>")] - pub stake_subsidy_start_epoch: u64, - /// Maximum number of active validators at any moment. /// We do not allow the number of validators in any epoch to go above this. #[schemars(with = "BigInt")] @@ -132,30 +127,6 @@ pub struct IotaSystemStateSummary { #[serde_as(as = "Readable, _>")] pub validator_low_stake_grace_period: u64, - // Stake subsidy information - /// Balance of IOTA set aside for stake subsidies that will be drawn down - /// over time. - #[schemars(with = "BigInt")] - #[serde_as(as = "Readable, _>")] - pub stake_subsidy_balance: u64, - /// This counter may be different from the current epoch number if - /// in some epochs we decide to skip the subsidy. - #[schemars(with = "BigInt")] - #[serde_as(as = "Readable, _>")] - pub stake_subsidy_distribution_counter: u64, - /// The amount of stake subsidy to be drawn down per epoch. - /// This amount decays and decreases over time. - #[schemars(with = "BigInt")] - #[serde_as(as = "Readable, _>")] - pub stake_subsidy_current_distribution_amount: u64, - /// Number of distributions to occur before the distribution amount decays. - #[schemars(with = "BigInt")] - #[serde_as(as = "Readable, _>")] - pub stake_subsidy_period_length: u64, - /// The rate at which the distribution amount decays at the end of each - /// period. Expressed in basis points. - pub stake_subsidy_decrease_rate: u16, - // Validator set /// Total amount of stake from all active validators at the beginning of the /// epoch. @@ -358,17 +329,11 @@ impl Default for IotaSystemStateSummary { safe_mode_non_refundable_storage_fee: 0, epoch_start_timestamp_ms: 0, epoch_duration_ms: 0, - stake_subsidy_start_epoch: 0, max_validator_count: 0, min_validator_joining_stake: 0, validator_low_stake_threshold: 0, validator_very_low_stake_threshold: 0, validator_low_stake_grace_period: 0, - stake_subsidy_balance: 0, - stake_subsidy_distribution_counter: 0, - stake_subsidy_current_distribution_amount: 0, - stake_subsidy_period_length: 0, - stake_subsidy_decrease_rate: 0, total_stake: 0, active_validators: vec![], pending_active_validators_id: ObjectID::ZERO, diff --git a/crates/iota/src/genesis_inspector.rs b/crates/iota/src/genesis_inspector.rs index 35123e8f7b6..b47483992a3 100644 --- a/crates/iota/src/genesis_inspector.rs +++ b/crates/iota/src/genesis_inspector.rs @@ -60,10 +60,6 @@ pub(crate) fn examine_genesis_checkpoint(genesis: UnsignedGenesis) { system_object.storage_fund.non_refundable_balance.value(), ), ); - entry.insert( - "Stake Subsidy".to_string(), - (STR_IOTA, system_object.stake_subsidy.balance.value()), - ); // Prepare Object Info let mut owner_map = BTreeMap::new(); diff --git a/crates/test-cluster/src/lib.rs b/crates/test-cluster/src/lib.rs index 1c8415fffe5..10905559749 100644 --- a/crates/test-cluster/src/lib.rs +++ b/crates/test-cluster/src/lib.rs @@ -879,13 +879,6 @@ impl TestClusterBuilder { self } - pub fn with_stake_subsidy_start_epoch(mut self, stake_subsidy_start_epoch: u64) -> Self { - self.get_or_init_genesis_config() - .parameters - .stake_subsidy_start_epoch = stake_subsidy_start_epoch; - self - } - pub fn with_supported_protocol_versions(mut self, c: SupportedProtocolVersions) -> Self { self.validator_supported_protocol_versions_config = ProtocolVersionsConfig::Global(c); self