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

zcash_client_sqlite: Align handling of transparent UTXOs with that of shielded notes. #1402

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented May 31, 2024

This PR is best reviewed hiding whitespace changes.

Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 85.57692% with 30 lines in your changes missing coverage. Please review.

Project coverage is 63.20%. Comparing base (26c6b82) to head (9716617).

Files Patch % Lines
zcash_client_sqlite/src/wallet/transparent.rs 86.62% 21 Missing ⚠️
...sqlite/src/wallet/init/migrations/utxos_to_txos.rs 60.00% 4 Missing ⚠️
zcash_client_sqlite/src/wallet.rs 81.25% 3 Missing ⚠️
zcash_client_backend/src/data_api.rs 0.00% 1 Missing ⚠️
zcash_client_sqlite/src/lib.rs 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
+ Coverage   63.13%   63.20%   +0.06%     
==========================================
  Files         127      128       +1     
  Lines       14864    14869       +5     
==========================================
+ Hits         9385     9398      +13     
+ Misses       5479     5471       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nuttycom nuttycom force-pushed the transparent_txos_migration branch 4 times, most recently from 77fe74d to baa2ad3 Compare June 11, 2024 19:59
@nuttycom nuttycom marked this pull request as draft June 11, 2024 19:59
@nuttycom nuttycom force-pushed the transparent_txos_migration branch 5 times, most recently from acedca8 to bf86c08 Compare June 12, 2024 17:22
@nuttycom nuttycom marked this pull request as ready for review June 14, 2024 16:45
@@ -525,7 +523,12 @@ impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters> WalletRead for W
account: AccountId,
max_height: BlockHeight,
) -> Result<HashMap<TransparentAddress, NonNegativeAmount>, Self::Error> {
wallet::get_transparent_balances(self.conn.borrow(), &self.params, account, max_height)
wallet::transparent::get_transparent_address_balances(
Copy link
Contributor

@daira daira Jun 24, 2024

Choose a reason for hiding this comment

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

Why is this renaming the function in wallet::transparent so that it doesn't match the trait method? I think that for all of the other functions there that correspond to trait methods, the names do match.

(Currently I'm renaming it back in #1257, because I hadn't previously noticed that the change was made here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When moving the methods, I got confused about the meaning of get_transparent_balances vs get_transparent_account_balance and I wanted to clarify. I didn't want to change the top-level trait method, but since this is crate-private I thought that it was a good start.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want me to undo renaming it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel strongly about it.

Comment on lines 231 to +234
/// Originally this table only stored the current UTXO set (as of latest refresh), and the
/// table was cleared prior to loading in the latest UTXO set. We now upsert instead of
/// insert into the database, meaning that spent outputs are left in the database. This
/// makes it similar to the `*_received_notes` tables in that it can store history, but
/// has several downsides:
/// - The table has incomplete contents for recovered-from-seed wallets.
/// - The table can have inconsistent contents for seeds loaded into multiple wallets
/// makes it similar to the `*_received_notes` tables in that it can store history.
Copy link
Contributor

@daira daira Jun 24, 2024

Choose a reason for hiding this comment

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

"Originally this table, when it was called utxos, ..." (Non-blocking.)

daira
daira previously approved these changes Jun 24, 2024
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK

str4d
str4d previously approved these changes Jun 24, 2024
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK 10258b8 with nit about tracing spans. I did not review the codebase outside of what is already changed in this PR to look for other places in e.g. the SQL queries that might need to be altered.

zcash_client_sqlite/src/wallet/transparent.rs Outdated Show resolved Hide resolved
Comment on lines +375 to +379
WHERE (
t.mined_height < :mempool_height -- tx is mined
OR t.expiry_height = 0 -- tx will not expire
OR t.expiry_height >= :mempool_height
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Observation: The other minconf-0 instances of this pattern use t.mined_height <= SOME_HEIGHT OR t.expiry_height >= SOME_HEIGHT. I think it's okay to use < :mempool_height here however, solely because we never actually encounter the off-by-one here (because we encode mempool heights in the database as NULL).

zcash_client_sqlite/src/wallet/transparent.rs Outdated Show resolved Hide resolved
@nuttycom nuttycom dismissed stale reviews from str4d and daira via 5c8f585 June 24, 2024 17:40
str4d
str4d previously approved these changes Jun 24, 2024
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Re-utACK 5c8f585

ro.account_id AS to_account_id,
sent_notes.to_address AS to_address,
sent_notes.value AS value,
0 AS is_change,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just occurs to me, will this be correct behavior after ZIP 320 integration?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why not, but we should test it. Note that put_transparent_output is called from store_sent_tx for ephemeral outputs.

Co-authored-by: Jack Grigg <[email protected]>
Co-authored-by: Daira-Emma Hopwood <[email protected]>
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK 9716617

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.

3 participants