Skip to content

Commit

Permalink
Update ledger-tool --deactivate-feature-gate to deactivate feature ga…
Browse files Browse the repository at this point in the history
…te in child bank (#4465)

wip: ledger-tool --deactivate-feature-gate deactivates the feature in the new child bank

Co-authored-by: brooks <[email protected]>
  • Loading branch information
willhickey and brooksprumo authored Jan 15, 2025
1 parent b2e14ef commit 65aad08
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,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);
}

Expand Down Expand Up @@ -2141,32 +2171,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))
Expand Down

0 comments on commit 65aad08

Please sign in to comment.