Skip to content

Commit

Permalink
[sui-framework] change stake subsidy schedule (MystenLabs#9251)
Browse files Browse the repository at this point in the history
## Description 

This PR changes various constants related to stake subsidies advised by
@econmysten .

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
emmazzz authored Mar 14, 2023
1 parent 68e1cf7 commit 8aed250
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ validator_report_records:
stake_subsidy:
epoch_counter: 0
balance:
value: 975000000000000000
current_epoch_amount: 1000000
value: 100000000000000000
current_epoch_amount: 1000000000000000
safe_mode: false
epoch_start_timestamp_ms: 10

18 changes: 14 additions & 4 deletions crates/sui-framework/docs/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

<a name="0x2_genesis_INIT_STAKE_SUBSIDY_AMOUNT"></a>

Stake subisidy to be given out in the very first epoch. Placeholder value.
Stake subisidy to be given out in the very first epoch in Mist (1 million * 10^9).


<pre><code><b>const</b> <a href="genesis.md#0x2_genesis_INIT_STAKE_SUBSIDY_AMOUNT">INIT_STAKE_SUBSIDY_AMOUNT</a>: u64 = 1000000;
<pre><code><b>const</b> <a href="genesis.md#0x2_genesis_INIT_STAKE_SUBSIDY_AMOUNT">INIT_STAKE_SUBSIDY_AMOUNT</a>: u64 = 1000000000000000;
</code></pre>


Expand All @@ -46,6 +46,15 @@ The initial balance of the Subsidy fund in Mist (1 Billion * 10^9)



<a name="0x2_genesis_INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY"></a>



<pre><code><b>const</b> <a href="genesis.md#0x2_genesis_INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY">INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY</a>: u64 = 100000000000000000;
</code></pre>



<a name="0x2_genesis_create"></a>

## Function `create`
Expand Down Expand Up @@ -90,7 +99,7 @@ all the information we need in the system.
ctx: &<b>mut</b> TxContext,
) {
<b>let</b> sui_supply = <a href="sui.md#0x2_sui_new">sui::new</a>(ctx);
<b>let</b> subsidy_fund = <a href="balance.md#0x2_balance_split">balance::split</a>(&<b>mut</b> sui_supply, <a href="genesis.md#0x2_genesis_INIT_STAKE_SUBSIDY_FUND_BALANCE">INIT_STAKE_SUBSIDY_FUND_BALANCE</a>);
<b>let</b> subsidy_fund = <a href="balance.md#0x2_balance_split">balance::split</a>(&<b>mut</b> sui_supply, <a href="genesis.md#0x2_genesis_INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY">INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY</a>);
<b>let</b> storage_fund = <a href="balance.md#0x2_balance_zero">balance::zero</a>();
<b>let</b> validators = <a href="_empty">vector::empty</a>();
<b>let</b> count = <a href="_length">vector::length</a>(&validator_pubkeys);
Expand Down Expand Up @@ -140,7 +149,8 @@ all the information we need in the system.
primary_address,
worker_address,
// Initialize all validators <b>with</b> uniform stake taken from the subsidy fund.
<a href="_some">option::some</a>(<a href="balance.md#0x2_balance_split">balance::split</a>(&<b>mut</b> subsidy_fund, initial_validator_stake_mist)),
// TODO: change this back <b>to</b> take from subsidy fund instead.
<a href="_some">option::some</a>(<a href="balance.md#0x2_balance_split">balance::split</a>(&<b>mut</b> sui_supply, initial_validator_stake_mist)),
gas_price,
commission_rate,
<b>true</b>, // <a href="validator.md#0x2_validator">validator</a> is active right away
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework/docs/stake_subsidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@



<pre><code><b>const</b> <a href="stake_subsidy.md#0x2_stake_subsidy_STAKE_SUBSIDY_PERIOD_LENGTH">STAKE_SUBSIDY_PERIOD_LENGTH</a>: u64 = 30;
<pre><code><b>const</b> <a href="stake_subsidy.md#0x2_stake_subsidy_STAKE_SUBSIDY_PERIOD_LENGTH">STAKE_SUBSIDY_PERIOD_LENGTH</a>: u64 = 10;
</code></pre>


Expand Down
11 changes: 7 additions & 4 deletions crates/sui-framework/sources/governance/genesis.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ module sui::genesis {
use sui::validator;
use std::option;

/// Stake subisidy to be given out in the very first epoch. Placeholder value.
const INIT_STAKE_SUBSIDY_AMOUNT: u64 = 1000000;
/// Stake subisidy to be given out in the very first epoch in Mist (1 million * 10^9).
const INIT_STAKE_SUBSIDY_AMOUNT: u64 = 1_000_000_000_000_000;

/// The initial balance of the Subsidy fund in Mist (1 Billion * 10^9)
const INIT_STAKE_SUBSIDY_FUND_BALANCE: u64 = 1_000_000_000_000_000_000;

const INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY: u64 = 100_000_000_000_000_000;

/// This function will be explicitly called once at genesis.
/// It will create a singleton SuiSystemState object, which contains
/// all the information we need in the system.
Expand Down Expand Up @@ -48,7 +50,7 @@ module sui::genesis {
ctx: &mut TxContext,
) {
let sui_supply = sui::new(ctx);
let subsidy_fund = balance::split(&mut sui_supply, INIT_STAKE_SUBSIDY_FUND_BALANCE);
let subsidy_fund = balance::split(&mut sui_supply, INIT_STAKE_SUBSIDY_FUND_BALANCE_TEST_ONLY);
let storage_fund = balance::zero();
let validators = vector::empty();
let count = vector::length(&validator_pubkeys);
Expand Down Expand Up @@ -98,7 +100,8 @@ module sui::genesis {
primary_address,
worker_address,
// Initialize all validators with uniform stake taken from the subsidy fund.
option::some(balance::split(&mut subsidy_fund, initial_validator_stake_mist)),
// TODO: change this back to take from subsidy fund instead.
option::some(balance::split(&mut sui_supply, initial_validator_stake_mist)),
gas_price,
commission_rate,
true, // validator is active right away
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-framework/sources/governance/stake_subsidy.move
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module sui::stake_subsidy {

struct StakeSubsidy has store {
/// This counter may be different from the current epoch number if
/// in some epochs we decide to skip the subsidy.
/// in some epochs we decide to skip the subsidy.
epoch_counter: u64,
/// Balance of SUI set aside for stake subsidies that will be drawn down over time.
balance: Balance<SUI>,
Expand All @@ -23,7 +23,7 @@ module sui::stake_subsidy {

// Placeholder numbers.
const STAKE_SUBSIDY_DECREASE_RATE: u128 = 1000; // in basis point
const STAKE_SUBSIDY_PERIOD_LENGTH: u64 = 30; // in number of epochs
const STAKE_SUBSIDY_PERIOD_LENGTH: u64 = 10; // in number of epochs

public(friend) fun create(balance: Balance<SUI>, initial_stake_subsidy_amount: u64): StakeSubsidy {
StakeSubsidy {
Expand Down

0 comments on commit 8aed250

Please sign in to comment.