Rewrite stake accounts for clear migration (#13461)

* Reduce overage stake by rewritng stake accounts

* Write tests and finish implemention

* Create and use new feature gate

* Clean up logging

* Fix typo

* Simplify enable_rewrite_stake

* Fix typo...

* Even simplify gating

* Add metrics
This commit is contained in:
Ryo Onodera
2020-11-20 05:15:06 +09:00
committed by GitHub
parent 9668dd85d4
commit 43d5e47ea9
4 changed files with 328 additions and 16 deletions

View File

@ -2052,7 +2052,15 @@ fn main() {
feature_account_balance,
),
);
base_bank.store_account(
&feature_set::rewrite_stake::id(),
&feature::create_account(
&Feature { activated_at: None },
feature_account_balance,
),
);
let mut store_failed_count = 0;
if base_bank
.get_account(&feature_set::secp256k1_program_enabled::id())
.is_some()
@ -2064,6 +2072,21 @@ fn main() {
&Account::default(),
);
} else {
store_failed_count += 1;
}
if base_bank
.get_account(&feature_set::instructions_sysvar_enabled::id())
.is_some()
{
base_bank.store_account(
&feature_set::instructions_sysvar_enabled::id(),
&Account::default(),
);
} else {
store_failed_count += 1;
}
if store_failed_count >= 1 {
// we have no choice; maybe locally created blank cluster with
// not-Development cluster type.
let old_cap = base_bank.set_capitalization();
@ -2073,7 +2096,10 @@ fn main() {
requested: increasing {} from {} to {}",
feature_account_balance, old_cap, new_cap,
);
assert_eq!(old_cap + feature_account_balance, new_cap);
assert_eq!(
old_cap + feature_account_balance * store_failed_count,
new_cap
);
}
}