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

Add account-decoder utilities #10846

Merged
merged 11 commits into from
Jul 1, 2020
Merged

Conversation

CriesofCarrots
Copy link
Contributor

@CriesofCarrots CriesofCarrots commented Jun 30, 2020

Problem

Currently, inspecting an on-chain account requires depending on a client-side, language-specific decoding library to parse the account data. If rpc methods could return decoded account data, these custom solutions would be unnecessary.

Summary of Changes

  • Add account-decoder crate to handle parsing and beautifying accounts owned by a select set of programs.
    There are a lot of similarities between what this crate does and what solana-transaction-status. Combining and renaming should be considered in the future.
  • Implement account decoding for vote and system (nonce) accounts and return via getAccountInfo and getProgramAccounts rpcs.
    Currently, client behavior remains the same; deduplication in rpc_client/cli/web3.js = follow-up work.

Toward #10475
Remaining work on that issue is parsing SPL Token accounts, which is blocked on publishing spl-token to crates.io.

@CriesofCarrots CriesofCarrots requested a review from mvines June 30, 2020 06:59
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #10846 into master will decrease coverage by 0.0%.
The diff coverage is 71.1%.

@@            Coverage Diff            @@
##           master   #10846     +/-   ##
=========================================
- Coverage    81.8%    81.8%   -0.1%     
=========================================
  Files         303      307      +4     
  Lines       71067    71233    +166     
=========================================
+ Hits        58194    58324    +130     
- Misses      12873    12909     +36     

@ryoqun
Copy link
Member

ryoqun commented Jun 30, 2020

Thanks for general refactoring! FYI, there is slight demand for general account printing coming from solana-ledger-tool too, #9490 (Yeah, my failed attempt to land this pr timely...)

account-decoder/src/lib.rs Outdated Show resolved Hide resolved
account-decoder/src/parse_vote.rs Outdated Show resolved Hide resolved
docs/src/apps/jsonrpc-api.md Outdated Show resolved Hide resolved
docs/src/apps/jsonrpc-api.md Outdated Show resolved Hide resolved
Tyera Eulberg added 3 commits June 30, 2020 18:33
mvines
mvines previously approved these changes Jul 1, 2020
account-decoder/src/lib.rs Outdated Show resolved Hide resolved
account-decoder/src/lib.rs Outdated Show resolved Hide resolved
transaction-status/src/lib.rs Show resolved Hide resolved
@mergify mergify bot dismissed mvines’s stale review July 1, 2020 03:39

Pull request has been modified.

@CriesofCarrots CriesofCarrots added the automerge Merge this Pull Request automatically once CI passes label Jul 1, 2020
@mergify mergify bot merged commit d97850f into solana-labs:master Jul 1, 2020
CriesofCarrots added a commit to CriesofCarrots/solana that referenced this pull request Jul 7, 2020
* Fix comment and make less pub

* Add account-decoder crate and use to decode vote and system (nonce) accounts

* Update docs

* Rename RpcAccount struct

* s/Rpc/Display

* Call it jsonParsed and update docs

* Revert "s/Rpc/Display"

This reverts commit 6e7149f.

* s/Rpc/Ui

* Add tests

* Ui more things

* Comments
CriesofCarrots added a commit to CriesofCarrots/solana that referenced this pull request Jul 7, 2020
* Fix comment and make less pub

* Add account-decoder crate and use to decode vote and system (nonce) accounts

* Update docs

* Rename RpcAccount struct

* s/Rpc/Display

* Call it jsonParsed and update docs

* Revert "s/Rpc/Display"

This reverts commit 6e7149f.

* s/Rpc/Ui

* Add tests

* Ui more things

* Comments
CriesofCarrots added a commit that referenced this pull request Jul 7, 2020
* Revert "Rpc: add filter to getProgramAccounts (#10888) (#10932)"

This reverts commit 9311a6e.

* Add jsonParsed option for EncodedTransactions; add memo parser (#10711)

* Add jsonParsed option for EncodedTransactions; add memo parser

* Use kebab case for program names

* Add account-key parsing

* Add parse test

* Update transaction encoding docs (#10833)

* Add account-decoder utilities (#10846)

* Fix comment and make less pub

* Add account-decoder crate and use to decode vote and system (nonce) accounts

* Update docs

* Rename RpcAccount struct

* s/Rpc/Display

* Call it jsonParsed and update docs

* Revert "s/Rpc/Display"

This reverts commit 6e7149f.

* s/Rpc/Ui

* Add tests

* Ui more things

* Comments

* Update struct prefixes to Ui (#10874)

* Update comments

* Use Ui prefix

* Rpc: add filter to getProgramAccounts (#10888)

* Add RpcFilterType, and implement CompareBytes for getProgramAccounts

* Accept bytes in bs58

* Rename to memcmp

* Add Memcmp optional encoding field

* Add dataSize filter

* Update docs

* Clippy

* Simplify tests that don't need to test account contents; add multiple-filter tests
@CriesofCarrots CriesofCarrots deleted the parse-accounts branch July 24, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants