Skip to content
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

Rpc: Filter accounts with invalid mints from get_parsed_token_accounts #11844

Merged
merged 2 commits into from
Aug 26, 2020

Conversation

CriesofCarrots
Copy link
Contributor

@CriesofCarrots CriesofCarrots commented Aug 26, 2020

Problem

Several token rpc endpoints can return mixed parsed and unparsed token accounts when jsonParsed encoding is requested: this happens if the token account's mint cannot be found or is not valid, resulting in a no mint_decimals error when account-decoder attempts to parse the account. Account-decoder then defaults to unparsed.

This is problematic for clients that would like to know all results will be in the same format.

Summary of Changes

  • Filter accounts in get_parsed_token_accounts such that all accounts return are parsed. Users that want to access all accounts, regardless of mint validity, will need to use another encoding.

@CriesofCarrots CriesofCarrots requested a review from jstarry August 26, 2020 00:02
@CriesofCarrots
Copy link
Contributor Author

@jstarry , the biggest question mark in my mind about this approach is whether to special-case getProgramAccounts. Right now, a getProgramAccounts request for the SPL Token program id + jsonParsed encoding will also filter out accounts without a valid Mint (uses the same method). Thoughts?

@codecov
Copy link

codecov bot commented Aug 26, 2020

Codecov Report

Merging #11844 into master will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #11844   +/-   ##
=======================================
  Coverage    82.1%    82.1%           
=======================================
  Files         330      330           
  Lines       77588    77601   +13     
=======================================
+ Hits        63701    63735   +34     
+ Misses      13887    13866   -21     

@jstarry
Copy link
Member

jstarry commented Aug 26, 2020

@jstarry , the biggest question mark in my mind about this approach is whether to special-case getProgramAccounts. Right now, a getProgramAccounts request for the SPL Token program id + jsonParsed encoding will also filter out accounts without a valid Mint (uses the same method). Thoughts?

@CriesofCarrots I could see a case either way but I'm in favor of filtering them out. Like you said: "users that want to access all accounts, regardless of mint validity, will need to use another encoding."

That being said, I think we should add a disclaimer to the docs that explains that invalid accounts will not be returned.

jstarry
jstarry previously approved these changes Aug 26, 2020
@mergify mergify bot dismissed jstarry’s stale review August 26, 2020 16:22

Pull request has been modified.

@CriesofCarrots CriesofCarrots added v1.2 automerge Merge this Pull Request automatically once CI passes labels Aug 26, 2020
@mergify
Copy link
Contributor

mergify bot commented Aug 26, 2020

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label Aug 26, 2020
@CriesofCarrots CriesofCarrots merged commit 1988ee9 into solana-labs:master Aug 26, 2020
mergify bot pushed a commit that referenced this pull request Aug 26, 2020
#11844)

* Filter out accounts with invalid mints from get_parsed_token_accounts

* Explicit docs

(cherry picked from commit 1988ee9)
mergify bot pushed a commit that referenced this pull request Aug 26, 2020
#11844)

* Filter out accounts with invalid mints from get_parsed_token_accounts

* Explicit docs

(cherry picked from commit 1988ee9)
mergify bot added a commit that referenced this pull request Aug 26, 2020
#11844) (#11859)

* Filter out accounts with invalid mints from get_parsed_token_accounts

* Explicit docs

(cherry picked from commit 1988ee9)

Co-authored-by: Tyera Eulberg <[email protected]>
mergify bot added a commit that referenced this pull request Aug 26, 2020
#11844) (#11858)

* Filter out accounts with invalid mints from get_parsed_token_accounts

* Explicit docs

(cherry picked from commit 1988ee9)

Co-authored-by: Tyera Eulberg <[email protected]>
@CriesofCarrots CriesofCarrots deleted the no-invalid-mints branch September 1, 2020 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants