This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[unimpl-ed] Show insufficient purge_zero_lamport_account logic #8176
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2126,6 +2126,57 @@ pub mod tests { | |
| assert_load_account(&accounts, current_slot, pubkey, zero_lamport); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_accounts_purge_chained() { | ||
| solana_logger::setup(); | ||
|
|
||
| let some_lamport = 223; | ||
| let zero_lamport = 0; | ||
| let dummy_lamport = 999; | ||
| let no_data = 0; | ||
| let owner = Account::default().owner; | ||
|
|
||
| let account = Account::new(some_lamport, no_data, &owner); | ||
| let account2 = Account::new(some_lamport + 100_001, no_data, &owner); | ||
| let account3 = Account::new(some_lamport + 100_002, no_data, &owner); | ||
| let zero_lamport_account = Account::new(zero_lamport, no_data, &owner); | ||
|
|
||
| let pubkey = Pubkey::new_rand(); | ||
| let purged_pubkey1 = Pubkey::new_rand(); | ||
| let purged_pubkey2 = Pubkey::new_rand(); | ||
|
|
||
| let dummy_account = Account::new(dummy_lamport, no_data, &owner); | ||
| let dummy_pubkey = Pubkey::default(); | ||
|
|
||
| let accounts = AccountsDB::new_single(); | ||
|
|
||
| let mut current_slot = 1; | ||
| accounts.store(current_slot, &[(&pubkey, &account)]); | ||
| accounts.store(current_slot, &[(&purged_pubkey1, &account2)]); | ||
| accounts.add_root(current_slot); | ||
|
|
||
| current_slot += 1; | ||
| accounts.store(current_slot, &[(&purged_pubkey1, &zero_lamport_account)]); | ||
| accounts.store(current_slot, &[(&purged_pubkey2, &account3)]); | ||
| accounts.add_root(current_slot); | ||
|
|
||
| current_slot += 1; | ||
| accounts.store(current_slot, &[(&purged_pubkey2, &zero_lamport_account)]); | ||
| accounts.add_root(current_slot); | ||
|
|
||
| current_slot += 1; | ||
| accounts.store(current_slot, &[(&dummy_pubkey, &dummy_account)]); | ||
|
Contributor
Author
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 is needed because of another bug |
||
| accounts.add_root(current_slot); | ||
|
|
||
| purge_zero_lamport_accounts(&accounts, current_slot); | ||
|
Contributor
Author
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. Commenting out this |
||
| let accounts = reconstruct_accounts_db_via_serialization(&accounts, current_slot); | ||
|
|
||
| assert_load_account(&accounts, current_slot, pubkey, some_lamport); | ||
| assert_load_account(&accounts, current_slot, purged_pubkey1, 0); | ||
| assert_load_account(&accounts, current_slot, purged_pubkey2, 0); | ||
|
Contributor
Author
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 assertion fails as follows: This should pass, while |
||
| assert_load_account(&accounts, current_slot, dummy_pubkey, dummy_lamport); | ||
| } | ||
|
|
||
| #[test] | ||
| #[ignore] | ||
| fn test_store_account_stress() { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
The problem of current
purge_zero_lamport_accountis that it cannot recognize these chained/dependent/cascading relationship of zero lamport accounts.In this database settings, no storage should be removed. But currently that function incorrectly removes a storage entry for this line's store. So, the old version (=not yet purged) of
purged_pubkey2re-appears incorrectly, causing this assertion failure.Uh oh!
There was an error while loading. Please reload this page.
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.
I'm not an algorithm expert at all; however the cost of these DAG dependency aware purging logic should be costly. It think that logic at least require individual checks and/or recursive checks. And it basically will be light-weight stop-the-world GC. Also, this could be DOS-friendly.
Because I couldn't come up with a simple and encouraging logic, this PR doesn't come with actual implementation...
I think we have two paths:
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.
@sakridge I think the path 2. sounds more reasonable. Could you share your thoughts on this bug? Also, is there any better solution in your mind? :)
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.
For #2, it isn't clear to me how that exactly simplifies the problem, because don't you still have to track whether these accounts are shielding others even if they are in different stores or not?