-
Notifications
You must be signed in to change notification settings - Fork 107
fix: add account closure tracking to prevent mainnet refetch (#402) #409
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
Conversation
|
@MicaiahReid hi ser, can you review this pr ? thank you |
MicaiahReid
left a comment
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.
Hi @AvhiMaz, thanks for the PR!
Sadly I don't think this PR is really hitting the crux of the issue.
Your PR tracks "closed accounts" and adds the close_account fn to update this index of closed accounts.
However, the close_account method is never actually called. Closing an account isn't meant to be something a use has to manually do - by closed accounts I'm referring to one that is automatically garbage collected by the VM. When an account sends a transaction such that it no longer has any lamports (i.e. transfers all of its funds away), it will automatically be closed.
So, when a transaction is closed in this way, we need to be sure that it isn't fetched from remote again.
I haven't been able to implement/test this, but I think the way to do this is to update our update_account_registries function to push to the closed_accounts list if the accound being passed to the function is empty (aka Account::default). This empty account will be garbage collected, so it's closed, but since we know it's been fetched before we know we don't want to fetch it again.
You're welcome to try this, or I can take over if you'd like.
Let me know!
|
hi @MicaiahReid, i tried to implement what you said. if you think i'm on the right path, let me know, otherwise you can take it from here. thank you. |
43bcb3a to
b146654
Compare
MicaiahReid
left a comment
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 think this is looking good! I've added a quick test to this PR :)
And a few small comments
crates/core/src/surfnet/locker.rs
Outdated
| /// | ||
| /// Once marked as closed, this account will not be fetched from mainnet even if it doesn't exist | ||
| /// in the local cache. This prevents closed accounts from being inadvertently restored. | ||
| pub fn close_account(&self, pubkey: Pubkey) -> SurfpoolResult<()> { |
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 think we can remove this method, it's not used currently, and I don't think we'll need to
crates/core/src/surfnet/locker.rs
Outdated
|
|
||
| // Collect missing pubkeys (local_results is already in correct order from pubkeys) | ||
| // Get the closed accounts set | ||
| let closed_accounts = self.with_svm_reader(|svm_reader| svm_reader.closed_accounts.clone()); |
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 think you can just used your self. get_closed_accounts() helper here instead of with_svm_reader
crates/core/src/surfnet/locker.rs
Outdated
| Ok(result.with_new_value(remote_account)) | ||
| // Check if the account has been explicitly closed - if so, don't fetch from remote | ||
| let is_closed = | ||
| self.with_svm_reader(|svm_reader| svm_reader.closed_accounts.contains(pubkey)); |
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 think you can just used your self. get_closed_accounts() helper here instead of with_svm_reader
MicaiahReid
left a comment
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.
Awesome work, thanks @AvhiMaz!!
you can run the ci/cd. if there are any errors, i’m ready to fix them 🫡 |
91b98c4 to
e57b2c1
Compare
|
@MicaiahReid there was a formatting issue. i rebased with the main branch and pushed it. hopefully the issue is resolved now. |
|
thanks @AvhiMaz ! do you think you could refresh your branch with latest |
Distinguish between user-initiated closure and reset/stream operations. - Add closed_accounts HashSet to SurfnetSvm - Check closed accounts before mainnet fetch in retrieval logic - Add close_account/unclose_account methods - Update reset_account to unclose before reset Signed-off-by: AvhiMaz <avhimazumder5@outlook.com>
Signed-off-by: AvhiMaz <avhimazumder5@outlook.com>
Signed-off-by: AvhiMaz <avhimazumder5@outlook.com>
e57b2c1 to
6899317
Compare
Signed-off-by: AvhiMaz <avhimazumder5@outlook.com>
|
hi @lgalabru
ig its ready to merge, thanks! |
Distinguish between user-initiated closure and reset/stream operations.
Fixes #402