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

feat(rpc): implement the get_address_tx_ids RPC method query #4119

Merged
merged 11 commits into from
Apr 21, 2022

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Apr 14, 2022

Motivation

This PR adds a state query function and RPC method for the get_address_tx_ids RPC in ticket #3147.

Specifications

RPC:

But only the arguments and fields in ticket #3147.

Designs

There are a few tricky parts of this PR:

  • filtering the tx IDs by height range efficiently
  • making sure the tx IDs from the finalized state are consistent with each other
  • combining the finalized and non-finalized tx IDs

We could try to hold a database read snapshot, but that could cause locking issues. Instead, I just retry a few times if the tx IDs might have changed. (If the query fails for this reason, Zebra is still syncing, and the results would probably be wrong anyway.)

But this is easier than the previous PR, because we can just combine the tx IDs, as long as there is chain overlap, or as long as we are querying a single address.

Solution

  • Add the get_address_tx_ids RPC method

    • Add a query function for address tx IDs
    • Add a query method for finalized tx IDs
    • Combine tx IDs in a way that makes sure they are consistent
    • Add a state request that calls the query function
  • Filter the tx IDs by the query height range

    • Optimise database queries, so we don't look up filtered transaction IDs from the disk
    • Test all block range combinations for mainnet
  • Retry interrupted finalized tx ID queries

Closes #3147.

Review

Anyone can review this PR, it's not urgent.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Do a bunch of RPC testing:

@teor2345 teor2345 added C-enhancement Category: This is an improvement P-Medium ⚡ A-rpc Area: Remote Procedure Call interfaces A-state Area: State / database changes lightwalletd any work associated with lightwalletd labels Apr 14, 2022
@teor2345 teor2345 self-assigned this Apr 14, 2022
@teor2345 teor2345 changed the base branch from main to addr-utxo-query April 14, 2022 03:50
@teor2345
Copy link
Contributor Author

Base automatically changed from addr-utxo-query to main April 19, 2022 13:34
@teor2345 teor2345 changed the title 10. feat(rpc): implement the get_address_tx_ids RPC method feat(rpc): implement the get_address_tx_ids RPC method Apr 19, 2022
@teor2345 teor2345 marked this pull request as ready for review April 20, 2022 07:39
@teor2345 teor2345 requested a review from a team as a code owner April 20, 2022 07:39
@teor2345 teor2345 requested review from upbqdn and removed request for a team April 20, 2022 07:39
@teor2345 teor2345 changed the title feat(rpc): implement the get_address_tx_ids RPC method feat(rpc): implement the get_address_tx_ids RPC method query Apr 20, 2022
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and it seems to work with the tests we have, additional tests will be added as part of other tickets. I think is ok to merge.

mergify bot added a commit that referenced this pull request Apr 21, 2022
@mergify mergify bot merged commit c2430c6 into main Apr 21, 2022
@mergify mergify bot deleted the addr-txids-rpc branch April 21, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Area: Remote Procedure Call interfaces A-state Area: State / database changes C-enhancement Category: This is an improvement lightwalletd any work associated with lightwalletd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getaddresstxids JSON-RPC method
2 participants