Skip to content

Commit

Permalink
feat(sc-platform): Remove stake subsidy fund (#1186)
Browse files Browse the repository at this point in the history
* feat(iota-framework): updating SystemEpochInfoEvent with new fields, renamed leftover_storage_fund_inflow to burnt_leftover_amount

* feat(iota-indexer): updating indexer epoch info types with new fields, renamed leftover_storage_fund_inflow to burnt_leftover_amount
Updating migration db scripts

* fix migration script

* feat(iota-indexer/migrations): revert epochs script changes, add new, separate migration to alter epochs table

* feat: Remove `stake_subsidy_amount` from epochs table

* feat: Remove stake subsidy fund

* fix: Calculate APY API

* fix: Remove stake subsidy fields from e2e tests

* fix: Remove stake subsidy fields in all e2e tests

* refactor: Rename stake subsidy test

* fix: Correct comment about subsidy fund

* feat: Regenerate framework snapshot

* feat: Remove subsidy fields from graphql schema

* fix: Update test snapshots with removed subsidy fund

* fix: Remove unused insta snapshots

* feat: Remove subsidy fields from graphql query

* feat: Update graphql rpc `examples.md`

* fix(iota-indexer, iota-types): cargo fmt

* feat: Update iota system docs again

* feat(iota-framework-snapshot): Update snapshot

* feat(iota-framework-snapshot): Update snapshot

* feat(iota-json-rpc): Remove subsidy fields

* fix(iota-config): Update test data after serde_yaml update

* fix(iota-swarm-config): Update test snapshots

---------

Co-authored-by: Dkwcs <[email protected]>
Co-authored-by: Mirko Zichichi <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent 351ce4a commit 9196ddd
Show file tree
Hide file tree
Showing 51 changed files with 40 additions and 1,439 deletions.
1 change: 0 additions & 1 deletion crates/iota-benchmark/tests/simtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
61 changes: 0 additions & 61 deletions crates/iota-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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(),
}
}

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/iota-framework-snapshot/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"1": {
"git_revision": "b0d6faa10d",
"git_revision": "9492657c34",
"package_ids": [
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000002",
Expand Down
40 changes: 0 additions & 40 deletions crates/iota-framework/docs/iota-system/genesis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Link from '@docusaurus/Link';
<b>use</b> <Link to="../iota-framework/tx_context#0x2_tx_context">0x2::tx_context</Link>;
<b>use</b> <Link to="iota_system#0x3_iota_system">0x3::iota_system</Link>;
<b>use</b> <Link to="iota_system_state_inner#0x3_iota_system_state_inner">0x3::iota_system_state_inner</Link>;
<b>use</b> <Link to="stake_subsidy#0x3_stake_subsidy">0x3::stake_subsidy</Link>;
<b>use</b> <Link to="timelocked_staking#0x3_timelocked_staking">0x3::timelocked_staking</Link>;
<b>use</b> <Link to="validator#0x3_validator">0x3::validator</Link>;
<b>use</b> <Link to="validator_set#0x3_validator_set">0x3::validator_set</Link>;
Expand Down Expand Up @@ -200,34 +199,6 @@ epoch_duration_ms: u64</code>
</dt>
<dd>

</dd>
<dt>
<code>
stake_subsidy_start_epoch: u64</code>
</dt>
<dd>

</dd>
<dt>
<code>
stake_subsidy_initial_distribution_amount: u64</code>
</dt>
<dd>

</dd>
<dt>
<code>
stake_subsidy_period_length: u64</code>
</dt>
<dd>

</dd>
<dt>
<code>
stake_subsidy_decrease_rate: u16</code>
</dt>
<dd>

</dd>
<dt>
<code>
Expand Down Expand Up @@ -437,7 +408,6 @@ all the information we need in the system.

<b>assert</b>!(iota_treasury_cap.total_supply() == pre_minted_supply, <Link to="genesis#0x3_genesis_EWrongPreMintedSupply">EWrongPreMintedSupply</Link>);

<b>let</b> subsidy_fund = <Link to="../iota-framework/balance#0x2_balance_zero">balance::zero</Link>();
<b>let</b> <Link to="storage_fund#0x3_storage_fund">storage_fund</Link> = <Link to="../iota-framework/balance#0x2_balance_zero">balance::zero</Link>();

// Create all the `Validator` structs
Expand Down Expand Up @@ -507,7 +477,6 @@ all the information we need in the system.

<b>let</b> system_parameters = <Link to="iota_system_state_inner#0x3_iota_system_state_inner_create_system_parameters">iota_system_state_inner::create_system_parameters</Link>(
genesis_chain_parameters.epoch_duration_ms,
genesis_chain_parameters.stake_subsidy_start_epoch,

// Validator committee parameters
genesis_chain_parameters.max_validator_count,
Expand All @@ -519,14 +488,6 @@ all the information we need in the system.
ctx,
);

<b>let</b> <Link to="stake_subsidy#0x3_stake_subsidy">stake_subsidy</Link> = <Link to="stake_subsidy#0x3_stake_subsidy_create">stake_subsidy::create</Link>(
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,
);

<Link to="iota_system#0x3_iota_system_create">iota_system::create</Link>(
iota_system_state_id,
iota_treasury_cap,
Expand All @@ -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,
<Link to="stake_subsidy#0x3_stake_subsidy">stake_subsidy</Link>,
system_timelock_cap,
ctx,
);
Expand Down
5 changes: 1 addition & 4 deletions crates/iota-framework/docs/iota-system/iota_system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ the IotaSystemStateInner version, or vice versa.
<b>use</b> <Link to="../iota-framework/transfer#0x2_transfer">0x2::transfer</Link>;
<b>use</b> <Link to="../iota-framework/tx_context#0x2_tx_context">0x2::tx_context</Link>;
<b>use</b> <Link to="iota_system_state_inner#0x3_iota_system_state_inner">0x3::iota_system_state_inner</Link>;
<b>use</b> <Link to="stake_subsidy#0x3_stake_subsidy">0x3::stake_subsidy</Link>;
<b>use</b> <Link to="staking_pool#0x3_staking_pool">0x3::staking_pool</Link>;
<b>use</b> <Link to="validator#0x3_validator">0x3::validator</Link>;
<b>use</b> <Link to="validator_cap#0x3_validator_cap">0x3::validator_cap</Link>;
Expand Down Expand Up @@ -209,7 +208,7 @@ This function will be called only once in genesis.


<pre><code>
<b>public</b>(<b>friend</b>) <b>fun</b> <Link to="iota_system#0x3_iota_system_create">create</Link>(id: <Link to="../iota-framework/object#0x2_object_UID">object::UID</Link>, iota_treasury_cap: <Link to="../iota-framework/iota#0x2_iota_IotaTreasuryCap">iota::IotaTreasuryCap</Link>, validators: <Link to="../move-stdlib/vector#0x1_vector">vector</Link>&lt;<Link to="validator#0x3_validator_Validator">validator::Validator</Link>&gt;, <Link to="storage_fund#0x3_storage_fund">storage_fund</Link>: <Link to="../iota-framework/balance#0x2_balance_Balance">balance::Balance</Link>&lt;<Link to="../iota-framework/iota#0x2_iota_IOTA">iota::IOTA</Link>&gt;, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: <Link to="iota_system_state_inner#0x3_iota_system_state_inner_SystemParameters">iota_system_state_inner::SystemParameters</Link>, <Link to="stake_subsidy#0x3_stake_subsidy">stake_subsidy</Link>: <Link to="stake_subsidy#0x3_stake_subsidy_StakeSubsidy">stake_subsidy::StakeSubsidy</Link>, system_timelock_cap: <Link to="../iota-framework/timelock#0x2_timelock_SystemTimelockCap">timelock::SystemTimelockCap</Link>, ctx: &<b>mut</b> <Link to="../iota-framework/tx_context#0x2_tx_context_TxContext">tx_context::TxContext</Link>)
<b>public</b>(<b>friend</b>) <b>fun</b> <Link to="iota_system#0x3_iota_system_create">create</Link>(id: <Link to="../iota-framework/object#0x2_object_UID">object::UID</Link>, iota_treasury_cap: <Link to="../iota-framework/iota#0x2_iota_IotaTreasuryCap">iota::IotaTreasuryCap</Link>, validators: <Link to="../move-stdlib/vector#0x1_vector">vector</Link>&lt;<Link to="validator#0x3_validator_Validator">validator::Validator</Link>&gt;, <Link to="storage_fund#0x3_storage_fund">storage_fund</Link>: <Link to="../iota-framework/balance#0x2_balance_Balance">balance::Balance</Link>&lt;<Link to="../iota-framework/iota#0x2_iota_IOTA">iota::IOTA</Link>&gt;, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: <Link to="iota_system_state_inner#0x3_iota_system_state_inner_SystemParameters">iota_system_state_inner::SystemParameters</Link>, system_timelock_cap: <Link to="../iota-framework/timelock#0x2_timelock_SystemTimelockCap">timelock::SystemTimelockCap</Link>, ctx: &<b>mut</b> <Link to="../iota-framework/tx_context#0x2_tx_context_TxContext">tx_context::TxContext</Link>)
</code></pre>


Expand All @@ -227,7 +226,6 @@ This function will be called only once in genesis.
protocol_version: u64,
epoch_start_timestamp_ms: u64,
parameters: SystemParameters,
<Link to="stake_subsidy#0x3_stake_subsidy">stake_subsidy</Link>: StakeSubsidy,
system_timelock_cap: SystemTimelockCap,
ctx: &<b>mut</b> TxContext,
) \{
Expand All @@ -238,7 +236,6 @@ This function will be called only once in genesis.
protocol_version,
epoch_start_timestamp_ms,
parameters,
<Link to="stake_subsidy#0x3_stake_subsidy">stake_subsidy</Link>,
ctx,
);
<b>let</b> version = <Link to="iota_system_state_inner#0x3_iota_system_state_inner_genesis_system_state_version">iota_system_state_inner::genesis_system_state_version</Link>();
Expand Down
Loading

0 comments on commit 9196ddd

Please sign in to comment.