This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Set account to default if the balance reaches 0 in a checkpoint bank#1932
Merged
pgarg66 merged 1 commit intosolana-labs:masterfrom Nov 27, 2018
Merged
Set account to default if the balance reaches 0 in a checkpoint bank#1932pgarg66 merged 1 commit intosolana-labs:masterfrom
pgarg66 merged 1 commit intosolana-labs:masterfrom
Conversation
rob-solana
reviewed
Nov 27, 2018
|
|
||
| let account = bank.get_account(&alice.pubkey()).unwrap(); | ||
| let default_account = Account::default(); | ||
| assert_eq!(account.tokens, default_account.tokens); |
Contributor
There was a problem hiding this comment.
these assertions should also apply to a brand new bank, too, right?
can you compare bank.get_account() and Default::default() directly, instead of comparing each field?
Contributor
Author
There was a problem hiding this comment.
Yes, assertions should apply to fresh bank accounts.
I tried comparing get_account() to default(). It's not implemented.
rob-solana
approved these changes
Nov 27, 2018
Contributor
rob-solana
left a comment
There was a problem hiding this comment.
nits, otherwise, yay!
garious
approved these changes
Nov 27, 2018
Contributor
|
I was hoping you'd add a pre-condition, that asking for an account in an un-checkpointed Bank gives you exactly the same answers (though maybe that's captured in another test) |
Contributor
Author
|
Sorry, I'll push a new change with the additional checks. |
Contributor
Author
vkomenda
referenced
this pull request
in vkomenda/solana
Aug 29, 2021
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.16.1 to 1.18.0. - [Release notes](https://github.com/solana-labs/solana-web3.js/releases) - [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json) - [Commits](solana-foundation/solana-web3.js@v1.16.1...v1.18.0) --- updated-dependencies: - dependency-name: "@solana/web3.js" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
Checkpoint'ed bank doesn't drop the account when the balance reaches 0. It updates the balance to 0, and retains the account. However, it also retains the program assignments and userdata for the account, consuming RAM and resources.
Summary of Changes
When the balance drop to 0, replace the account with Account::default()
Fixes #1931