Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iota-framework): replace storage_fund with storage deposits #960

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ expression: common_costs_actual
"SharedCounterAssertValue": {
"computationCost": "1000000",
"storageCost": "2591600",
"storageRebate": "1587564",
"nonRefundableStorageFee": "16036"
"storageRebate": "1603600",
"nonRefundableStorageFee": "0"
},
"SharedCounterCreate": {
"computationCost": "1000000",
Expand All @@ -30,8 +30,8 @@ expression: common_costs_actual
"SharedCounterIncrement": {
"computationCost": "1000000",
"storageCost": "2591600",
"storageRebate": "1587564",
"nonRefundableStorageFee": "16036"
"storageRebate": "1603600",
"nonRefundableStorageFee": "0"
},
"SplitCoin": {
"computationCost": "1000000",
Expand Down
4 changes: 2 additions & 2 deletions crates/iota-framework/docs/iota-system/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ all the information we need in the system.
} = token_distribution_schedule;

<b>let</b> subsidy_fund = iota_supply.split(stake_subsidy_fund_micros);
<b>let</b> <a href="storage_fund.md#0x3_storage_fund">storage_fund</a> = <a href="../iota-framework/balance.md#0x2_balance_zero">balance::zero</a>();
<b>let</b> storage_fund = <a href="../iota-framework/balance.md#0x2_balance_zero">balance::zero</a>();

// Create all the `Validator` structs
<b>let</b> <b>mut</b> validators = <a href="../move-stdlib/vector.md#0x1_vector">vector</a>[];
Expand Down Expand Up @@ -459,7 +459,7 @@ all the information we need in the system.
iota_system_state_id,
iota_treasury_cap,
validators,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>,
storage_fund,
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
system_parameters,
Expand Down
6 changes: 3 additions & 3 deletions crates/iota-framework/docs/iota-system/iota_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Create a new IotaSystemState object and make it shared.
This function will be called only once in genesis.


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


Expand All @@ -180,7 +180,7 @@ This function will be called only once in genesis.
id: UID,
iota_treasury_cap: IotaTreasuryCap,
validators: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Validator&gt;,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>: Balance&lt;IOTA&gt;,
<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>: Balance&lt;IOTA&gt;,
protocol_version: u64,
epoch_start_timestamp_ms: u64,
parameters: SystemParameters,
Expand All @@ -190,7 +190,7 @@ This function will be called only once in genesis.
<b>let</b> system_state = <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_create">iota_system_state_inner::create</a>(
iota_treasury_cap,
validators,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>,
<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>,
protocol_version,
epoch_start_timestamp_ms,
parameters,
Expand Down
54 changes: 27 additions & 27 deletions crates/iota-framework/docs/iota-system/iota_system_state_inner.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ title: Module `0x3::iota_system_state_inner`
- [Function `validator_staking_pool_id`](#0x3_iota_system_state_inner_validator_staking_pool_id)
- [Function `validator_staking_pool_mappings`](#0x3_iota_system_state_inner_validator_staking_pool_mappings)
- [Function `get_reporters_of`](#0x3_iota_system_state_inner_get_reporters_of)
- [Function `get_storage_fund_total_balance`](#0x3_iota_system_state_inner_get_storage_fund_total_balance)
- [Function `get_storage_fund_object_rebates`](#0x3_iota_system_state_inner_get_storage_fund_object_rebates)
- [Function `get_storage_deposits_total_balance`](#0x3_iota_system_state_inner_get_storage_deposits_total_balance)
- [Function `get_storage_deposits_object_rebates`](#0x3_iota_system_state_inner_get_storage_deposits_object_rebates)
- [Function `pool_exchange_rates`](#0x3_iota_system_state_inner_pool_exchange_rates)
- [Function `active_validator_addresses`](#0x3_iota_system_state_inner_active_validator_addresses)
- [Function `extract_coin_balance`](#0x3_iota_system_state_inner_extract_coin_balance)
Expand All @@ -79,7 +79,7 @@ title: Module `0x3::iota_system_state_inner`
<b>use</b> <a href="../iota-framework/vec_set.md#0x2_vec_set">0x2::vec_set</a>;
<b>use</b> <a href="stake_subsidy.md#0x3_stake_subsidy">0x3::stake_subsidy</a>;
<b>use</b> <a href="staking_pool.md#0x3_staking_pool">0x3::staking_pool</a>;
<b>use</b> <a href="storage_fund.md#0x3_storage_fund">0x3::storage_fund</a>;
<b>use</b> <a href="storage_deposits.md#0x3_storage_deposits">0x3::storage_deposits</a>;
<b>use</b> <a href="validator.md#0x3_validator">0x3::validator</a>;
<b>use</b> <a href="validator_cap.md#0x3_validator_cap">0x3::validator_cap</a>;
<b>use</b> <a href="validator_set.md#0x3_validator_set">0x3::validator_set</a>;
Expand Down Expand Up @@ -293,7 +293,7 @@ The top-level object containing all information of the Iota system.
Contains all information about the validators.
</dd>
<dt>
<code><a href="storage_fund.md#0x3_storage_fund">storage_fund</a>: <a href="storage_fund.md#0x3_storage_fund_StorageFund">storage_fund::StorageFund</a></code>
<code><a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>: <a href="storage_deposits.md#0x3_storage_deposits_StorageDeposits">storage_deposits::StorageDeposits</a></code>
</dt>
<dd>
The storage fund.
Expand Down Expand Up @@ -431,7 +431,7 @@ Uses SystemParametersV2 as the parameters.
Contains all information about the validators.
</dd>
<dt>
<code><a href="storage_fund.md#0x3_storage_fund">storage_fund</a>: <a href="storage_fund.md#0x3_storage_fund_StorageFund">storage_fund::StorageFund</a></code>
<code><a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>: <a href="storage_deposits.md#0x3_storage_deposits_StorageDeposits">storage_deposits::StorageDeposits</a></code>
</dt>
<dd>
The storage fund.
Expand Down Expand Up @@ -747,7 +747,7 @@ Create a new IotaSystemState object and make it shared.
This function will be called only once in genesis.


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_create">create</a>(iota_treasury_cap: <a href="../iota-framework/iota.md#0x2_iota_IotaTreasuryCap">iota::IotaTreasuryCap</a>, validators: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="validator.md#0x3_validator_Validator">validator::Validator</a>&gt;, initial_storage_fund: <a href="../iota-framework/balance.md#0x2_balance_Balance">balance::Balance</a>&lt;<a href="../iota-framework/iota.md#0x2_iota_IOTA">iota::IOTA</a>&gt;, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_SystemParameters">iota_system_state_inner::SystemParameters</a>, <a href="stake_subsidy.md#0x3_stake_subsidy">stake_subsidy</a>: <a href="stake_subsidy.md#0x3_stake_subsidy_StakeSubsidy">stake_subsidy::StakeSubsidy</a>, ctx: &<b>mut</b> <a href="../iota-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInner">iota_system_state_inner::IotaSystemStateInner</a>
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_create">create</a>(iota_treasury_cap: <a href="../iota-framework/iota.md#0x2_iota_IotaTreasuryCap">iota::IotaTreasuryCap</a>, validators: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="validator.md#0x3_validator_Validator">validator::Validator</a>&gt;, initial_storage_deposits: <a href="../iota-framework/balance.md#0x2_balance_Balance">balance::Balance</a>&lt;<a href="../iota-framework/iota.md#0x2_iota_IOTA">iota::IOTA</a>&gt;, protocol_version: u64, epoch_start_timestamp_ms: u64, parameters: <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_SystemParameters">iota_system_state_inner::SystemParameters</a>, <a href="stake_subsidy.md#0x3_stake_subsidy">stake_subsidy</a>: <a href="stake_subsidy.md#0x3_stake_subsidy_StakeSubsidy">stake_subsidy::StakeSubsidy</a>, ctx: &<b>mut</b> <a href="../iota-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInner">iota_system_state_inner::IotaSystemStateInner</a>
</code></pre>


Expand All @@ -759,7 +759,7 @@ This function will be called only once in genesis.
<pre><code><b>public</b>(package) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_create">create</a>(
iota_treasury_cap: IotaTreasuryCap,
validators: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Validator&gt;,
initial_storage_fund: Balance&lt;IOTA&gt;,
initial_storage_deposits: Balance&lt;IOTA&gt;,
protocol_version: u64,
epoch_start_timestamp_ms: u64,
parameters: <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_SystemParameters">SystemParameters</a>,
Expand All @@ -775,7 +775,7 @@ This function will be called only once in genesis.
system_state_version: <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_genesis_system_state_version">genesis_system_state_version</a>(),
iota_treasury_cap,
validators,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>: <a href="storage_fund.md#0x3_storage_fund_new">storage_fund::new</a>(initial_storage_fund),
<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>: <a href="storage_deposits.md#0x3_storage_deposits_new">storage_deposits::new</a>(initial_storage_deposits),
parameters,
reference_gas_price,
validator_report_records: <a href="../iota-framework/vec_map.md#0x2_vec_map_empty">vec_map::empty</a>(),
Expand Down Expand Up @@ -862,7 +862,7 @@ This function will be called only once in genesis.
system_state_version: _,
iota_treasury_cap,
validators,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>,
<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>,
parameters,
reference_gas_price,
validator_report_records,
Expand Down Expand Up @@ -891,7 +891,7 @@ This function will be called only once in genesis.
system_state_version: 2,
iota_treasury_cap,
validators,
<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>,
<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>,
parameters: <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_SystemParametersV2">SystemParametersV2</a> {
epoch_duration_ms,
stake_subsidy_start_epoch,
Expand Down Expand Up @@ -2063,8 +2063,8 @@ Update candidate validator's public key of network key.

This function should be called at the end of an epoch, and advances the system to the next epoch.
It does the following things:
1. Add storage charge to the storage fund.
2. Burn the storage rebates from the storage fund. These are already refunded to transaction sender's
1. Add storage charge to the storage deposits.
2. Burn the storage rebates from the storage deposits. These are already refunded to transaction sender's
gas coins.
3. Distribute computation charge to validator stake.
4. Update all validators.
Expand Down Expand Up @@ -2114,8 +2114,8 @@ gas coins.
self.safe_mode_non_refundable_storage_fee = 0;

<b>let</b> total_validators_stake = self.validators.total_stake();
<b>let</b> storage_fund_balance = self.<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>.total_balance();
<b>let</b> total_stake = storage_fund_balance + total_validators_stake;
<b>let</b> storage_deposits_balance = self.<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>.total_balance();
<b>let</b> total_stake = storage_deposits_balance + total_validators_stake;

<b>let</b> storage_charge = storage_reward.value();
<b>let</b> computation_charge = computation_reward.value();
Expand All @@ -2138,7 +2138,7 @@ gas coins.
<b>let</b> total_stake_u128 = total_stake <b>as</b> u128;
<b>let</b> computation_charge_u128 = computation_charge <b>as</b> u128;

<b>let</b> storage_fund_reward_amount = storage_fund_balance <b>as</b> u128 * computation_charge_u128 / total_stake_u128;
<b>let</b> storage_fund_reward_amount = storage_deposits_balance <b>as</b> u128 * computation_charge_u128 / total_stake_u128;
<b>let</b> <b>mut</b> storage_fund_reward = computation_reward.split(storage_fund_reward_amount <b>as</b> u64);

self.epoch = self.epoch + 1;
Expand Down Expand Up @@ -2181,7 +2181,7 @@ gas coins.
self.iota_treasury_cap.burn_balance(leftover_staking_rewards, ctx);

<b>let</b> refunded_storage_rebate =
self.<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>.<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_advance_epoch">advance_epoch</a>(
self.<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>.<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_advance_epoch">advance_epoch</a>(
storage_reward,
storage_rebate_amount,
non_refundable_storage_fee_amount,
Expand All @@ -2196,7 +2196,7 @@ gas coins.
total_stake: new_total_stake,
storage_charge,
storage_rebate: storage_rebate_amount,
storage_fund_balance: self.<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>.total_balance(),
storage_fund_balance: self.<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>.total_balance(),
stake_subsidy_amount,
total_gas_fees: computation_charge,
total_stake_rewards_distributed: computation_reward_distributed + storage_fund_reward_distributed,
Expand Down Expand Up @@ -2453,13 +2453,13 @@ Returns all the validators who are currently reporting <code>addr</code>

</details>

<a name="0x3_iota_system_state_inner_get_storage_fund_total_balance"></a>
<a name="0x3_iota_system_state_inner_get_storage_deposits_total_balance"></a>

## Function `get_storage_fund_total_balance`
## Function `get_storage_deposits_total_balance`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_fund_total_balance">get_storage_fund_total_balance</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">iota_system_state_inner::IotaSystemStateInnerV2</a>): u64
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_deposits_total_balance">get_storage_deposits_total_balance</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">iota_system_state_inner::IotaSystemStateInnerV2</a>): u64
</code></pre>


Expand All @@ -2468,22 +2468,22 @@ Returns all the validators who are currently reporting <code>addr</code>
<summary>Implementation</summary>


<pre><code><b>public</b>(package) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_fund_total_balance">get_storage_fund_total_balance</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">IotaSystemStateInnerV2</a>): u64 {
self.<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>.total_balance()
<pre><code><b>public</b>(package) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_deposits_total_balance">get_storage_deposits_total_balance</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">IotaSystemStateInnerV2</a>): u64 {
self.<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>.total_balance()
}
</code></pre>



</details>

<a name="0x3_iota_system_state_inner_get_storage_fund_object_rebates"></a>
<a name="0x3_iota_system_state_inner_get_storage_deposits_object_rebates"></a>

## Function `get_storage_fund_object_rebates`
## Function `get_storage_deposits_object_rebates`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_fund_object_rebates">get_storage_fund_object_rebates</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">iota_system_state_inner::IotaSystemStateInnerV2</a>): u64
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_deposits_object_rebates">get_storage_deposits_object_rebates</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">iota_system_state_inner::IotaSystemStateInnerV2</a>): u64
</code></pre>


Expand All @@ -2492,8 +2492,8 @@ Returns all the validators who are currently reporting <code>addr</code>
<summary>Implementation</summary>


<pre><code><b>public</b>(package) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_fund_object_rebates">get_storage_fund_object_rebates</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">IotaSystemStateInnerV2</a>): u64 {
self.<a href="storage_fund.md#0x3_storage_fund">storage_fund</a>.total_object_storage_rebates()
<pre><code><b>public</b>(package) <b>fun</b> <a href="iota_system_state_inner.md#0x3_iota_system_state_inner_get_storage_deposits_object_rebates">get_storage_deposits_object_rebates</a>(self: &<a href="iota_system_state_inner.md#0x3_iota_system_state_inner_IotaSystemStateInnerV2">IotaSystemStateInnerV2</a>): u64 {
self.<a href="storage_deposits.md#0x3_storage_deposits">storage_deposits</a>.total_object_storage_rebates()
}
</code></pre>

Expand Down
Loading
Loading