Add pico-inflation feature

This commit is contained in:
Michael Vines
2020-09-25 16:19:03 -07:00
parent 718f33260b
commit aa5c008fa8
8 changed files with 59 additions and 32 deletions

View File

@@ -1097,13 +1097,18 @@ impl Bank {
let validator_point_value = self.pay_validator_rewards(validator_rewards);
// this sysvar could be retired...
self.update_sysvar_account(&sysvar::rewards::id(), |account| {
sysvar::rewards::create_account(
self.inherit_sysvar_account_balance(account),
validator_point_value,
)
});
if !self
.feature_set
.is_active(&feature_set::pico_inflation::id())
{
// this sysvar can be retired once `pico_inflation` is enabled on all clusters
self.update_sysvar_account(&sysvar::rewards::id(), |account| {
sysvar::rewards::create_account(
self.inherit_sysvar_account_balance(account),
validator_point_value,
)
});
}
let validator_rewards_paid =
self.stakes.read().unwrap().vote_balance_and_staked() - vote_balance_and_staked;
@@ -3555,6 +3560,13 @@ impl Bank {
// The entire code path herein must be idempotent
fn apply_feature_activations(&mut self, init_finish_or_warp: bool, initiate_callback: bool) {
let new_feature_activations = self.compute_active_feature_set(!init_finish_or_warp);
if new_feature_activations.contains(&feature_set::pico_inflation::id()) {
*self.inflation.write().unwrap() = Inflation::new_fixed(0.0001); // 0.01% inflation
self.fee_rate_governor.burn_percent = 50; // 50% fee burn
self.rent_collector.rent.burn_percent = 50; // 50% rent burn
}
self.ensure_builtins(init_finish_or_warp, &new_feature_activations);
self.reinvoke_entered_epoch_callback(initiate_callback);
self.recheck_cross_program_support();

View File

@@ -17,12 +17,17 @@ pub mod consistent_recent_blockhashes_sysvar {
solana_sdk::declare_id!("3h1BQWPDS5veRsq6mDBWruEpgPxRJkfwGexg5iiQ9mYg");
}
pub mod pico_inflation {
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
(instructions_sysvar_enabled::id(), "instructions sysvar"),
(secp256k1_program_enabled::id(), "secp256k1 program"),
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
(pico_inflation::id(), "pico-inflation"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@@ -261,7 +261,7 @@ mod test_bank_serialize {
// These some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "FaZaic5p7bvdsKDxGJmaPVyp12AbAmURyYoGiUdx1Ksu")]
#[frozen_abi(digest = "5rd8RyVSLH3hm12xJDVCJWgc1gyqb4Ukt2hJLJNfsB5v")]
#[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperFuture {
#[serde(serialize_with = "wrapper_future")]