From f13625ae523643c1cb2b323af3a8d2c5e718e533 Mon Sep 17 00:00:00 2001 From: Will Hickey Date: Wed, 15 Jan 2025 11:23:02 -0600 Subject: [PATCH] Update ledger-tool --deactivate-feature-gate to deactivate feature gate in child bank (#4465) wip: ledger-tool --deactivate-feature-gate deactivates the feature in the new child bank Co-authored-by: brooks (cherry picked from commit 65aad08aa17e4e326a58f39e716701e0be87c66c) --- ledger-tool/src/main.rs | 56 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 6756806ad4ecb3..97bab8ff808037 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -2129,6 +2129,36 @@ fn main() { _ => Some(value_t_or_exit!(arg_matches, "hashes_per_tick", u64)), }); } + + for address in feature_gates_to_deactivate { + let mut account = + child_bank.get_account(&address).unwrap_or_else(|| { + eprintln!( + "Error: Feature-gate account does not exist, unable to \ + deactivate it: {address}" + ); + exit(1); + }); + + match feature::from_account(&account) { + Some(feature) => { + if feature.activated_at.is_none() { + warn!("Feature gate is not yet activated: {address}"); + } else { + child_bank.deactivate_feature(&address); + } + } + None => { + eprintln!("Error: Account is not a `Feature`: {address}"); + exit(1); + } + } + + account.set_lamports(0); + child_bank.store_account(&address, &account); + debug!("Feature gate deactivated: {address}"); + } + bank = Arc::new(child_bank); } @@ -2163,32 +2193,6 @@ fn main() { debug!("Account removed: {address}"); } - for address in feature_gates_to_deactivate { - let mut account = bank.get_account(&address).unwrap_or_else(|| { - eprintln!( - "Error: Feature-gate account does not exist, unable to \ - deactivate it: {address}" - ); - exit(1); - }); - - match feature::from_account(&account) { - Some(feature) => { - if feature.activated_at.is_none() { - warn!("Feature gate is not yet activated: {address}"); - } - } - None => { - eprintln!("Error: Account is not a `Feature`: {address}"); - exit(1); - } - } - - account.set_lamports(0); - bank.store_account(&address, &account); - debug!("Feature gate deactivated: {address}"); - } - if !vote_accounts_to_destake.is_empty() { for (address, mut account) in bank .get_program_accounts(&stake::program::id(), &ScanConfig::new(false))