Skip to content

Conversation

@pstratem
Copy link
Contributor

@pstratem pstratem commented Jun 9, 2020

Every caller looks up the block hash from a block height immediately before
calling.

@fanquake fanquake added the Wallet label Jun 9, 2020
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 9, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason you didn't remove the start_block variable?

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 didn't want to change the function called but i guess i should

Copy link
Contributor

@promag promag Jun 11, 2020

Choose a reason for hiding this comment

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

I think this can be removed now that block hash is gone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK dropping one of the start args. I have a preference to keep start_block hash instead.

@pstratem pstratem force-pushed the 2020-06-07-wallet-scanforwallettransactions branch from 5586ef7 to 8d8e4d3 Compare June 11, 2020 05:15
@pstratem
Copy link
Contributor Author

@promag im using the block height because everything that calls it is using the block height

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK 8d8e4d36c3d3cbe8b495869865aa0b8ff83fdbca.

@pstratem the interface uses heights but internally block hash is unambiguous - a block at a certain height can change after a reorg - but not a strong opinion.

Copy link
Contributor

@promag promag Jun 11, 2020

Choose a reason for hiding this comment

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

I think this can be removed now that block hash is gone.

Every caller looks up the block hash from a block height immediately before
calling.
@pstratem pstratem force-pushed the 2020-06-07-wallet-scanforwallettransactions branch from 8d8e4d3 to dbd8498 Compare June 11, 2020 22:34
@pstratem
Copy link
Contributor Author

pstratem commented Jun 11, 2020

@promag the rescan is pretty ambiguous to start with, it's scanning whatever the current active chain is

edit: the entire concept in theory should do nothing so it's a much "fuzzier" thing than other wallet ops that handle reorgs cleanly

@promag
Copy link
Contributor

promag commented Jun 11, 2020

Code review ACK dbd8498, dropped unnecessary statement since last review

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@ryanofsky
Copy link
Contributor

This isn't a good change, I think. It doesn't simplify the code very much, and makes the scanning code less correct and more fragile. The problem is the new getBlockHash call added here:

https://github.com/pstratem/bitcoin/blob/dbd8498b8134cb4cefa351eb21bef2769a7bdf18/src/wallet/wallet.cpp#L1672

getBlockHash is a synchronous method that will assert and the crash the process if it is called with an invalid height. Since #16426, the wallet can no longer lock the node, so reorgs can happen any time, and getBlockHash isn't safe to call after startup. The last remaining uses of getBlockHash are removed in #15719.

Calling getBlockHash here can also lead to less correct behavior even if it doesn't fully crash the process. RescanFromTime and CreateWalletFromFile both locate starting blocks based on time, but after this change they only pass the starting block height, not the starting block hash to ScanForWalletTransactions, meaning if there is a reorg, blocks that should be scanned might not be and no errors will be returned.

In general, the only correct way for wallet code to reference blocks is by hash and not by height, and this PR moves in the less correct direction.

Also, while ScanForWalletTransactions code is very messy, I think effort would be better spent deleting it and trying to move rescans outside the wallet with ariard's changes #11756 (comment), than trying to clean it up

@promag
Copy link
Contributor

promag commented Jul 1, 2020

Concept ACK dropping one of the start args. I have a preference to keep start_block hash instead.

@pstratem the interface uses heights but internally block hash is unambiguous - a block at a certain height can change after a reorg - but not a strong opinion.

I've mentioned this before, but considering @ryanofsky comment #19216 (comment) and @ariard work I agree that this is not worth it.

@ryanofsky
Copy link
Contributor

Another option could be to drop the start_height argument and keep the start_block argument

@fanquake
Copy link
Member

Closing for now.

@fanquake fanquake closed this Aug 18, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants