-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove activated feature for removing inactive delegations from stakes cache #21732
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2792,9 +2792,10 @@ impl Bank { | |||||||||||||||||||
|
||||||||||||||||||||
fn burn_and_purge_account(&self, program_id: &Pubkey, mut account: AccountSharedData) { | ||||||||||||||||||||
self.capitalization.fetch_sub(account.lamports(), Relaxed); | ||||||||||||||||||||
// Resetting account balance to 0 is needed to really purge from AccountsDb and | ||||||||||||||||||||
// flush the Stakes cache | ||||||||||||||||||||
// Both resetting account balance to 0 and zeroing the account data | ||||||||||||||||||||
// is needed to really purge from AccountsDb and flush the Stakes cache | ||||||||||||||||||||
account.set_lamports(0); | ||||||||||||||||||||
account.data_as_mut_slice().fill(0); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ryoqun can you take a look at this? When the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change will only affect consensus if we create a new builtin for an active stake account. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha, you're editing scary part. thanks for pinging :) to be sure, account with lamport=0 should always be same account hash regardless of its data contents. that's why this doesn't need feature-gated, right? i mean, there's a risk of differing bank hash in Line 2814 in 1149c18
add_precompiled_account ) under mixed-version cluster condition unless the above premise holds true.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly, the account hash shouldn't change. The risk in builtin/precompiled accounts is that the stakes cache state is corrupted so maybe worth adding a new feature gate in your opinion? There is a new change (#21654) that prunes corrupt state from the stakes cache but I'd rather not test it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
i don't think it's worth adding a new feature gate. i always forget the following impracticality of these attacks... xD: Lines 2807 to 2814 in 1149c18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // Both resetting account balance to 0 and zeroing the account data
// is needed to really purge from AccountsDb and flush the Stakes cache
account.set_lamports(0);
account.data_as_mut_slice().fill(0); What does above comment actually mean? This causes stakes cache to be inconsistent with accounts-db. Whereas previously if lamports = 0, the delegation was removed from stakes cache as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the code comment could be better expressed, because as it is right now, it may falsely imply that setting account balance to 0 may not always remove the account from AccountsDb, which to my understanding it is not true. But that issue aside and ignoring accounts-db for the moment, regarding the stakes-cache:
Is there any scenario that we don't want to remove the delegation from the stakes-cache when account's |
||||||||||||||||||||
self.store_account(program_id, &account); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -4763,11 +4764,7 @@ impl Bank { | |||||||||||||||||||
.accounts | ||||||||||||||||||||
.store_slow_cached(self.slot(), pubkey, account); | ||||||||||||||||||||
|
||||||||||||||||||||
self.stakes_cache.check_and_store( | ||||||||||||||||||||
pubkey, | ||||||||||||||||||||
account, | ||||||||||||||||||||
self.stakes_remove_delegation_if_inactive_enabled(), | ||||||||||||||||||||
); | ||||||||||||||||||||
self.stakes_cache.check_and_store(pubkey, account); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub fn force_flush_accounts_cache(&self) { | ||||||||||||||||||||
|
@@ -5509,11 +5506,7 @@ impl Bank { | |||||||||||||||||||
for (_i, (pubkey, account)) in | ||||||||||||||||||||
(0..message.account_keys_len()).zip(loaded_transaction.accounts.iter()) | ||||||||||||||||||||
{ | ||||||||||||||||||||
self.stakes_cache.check_and_store( | ||||||||||||||||||||
pubkey, | ||||||||||||||||||||
account, | ||||||||||||||||||||
self.stakes_remove_delegation_if_inactive_enabled(), | ||||||||||||||||||||
); | ||||||||||||||||||||
self.stakes_cache.check_and_store(pubkey, account); | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
@@ -5777,11 +5770,6 @@ impl Bank { | |||||||||||||||||||
.is_active(&feature_set::leave_nonce_on_success::id()) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub fn stakes_remove_delegation_if_inactive_enabled(&self) -> bool { | ||||||||||||||||||||
self.feature_set | ||||||||||||||||||||
.is_active(&feature_set::stakes_remove_delegation_if_inactive::id()) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub fn send_to_tpu_vote_port_enabled(&self) -> bool { | ||||||||||||||||||||
self.feature_set | ||||||||||||||||||||
.is_active(&feature_set::send_to_tpu_vote_port::id()) | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ comment grooming