mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
test: add BIP352 scanning to the functional test framework #36835
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36835
Loading…
Reference in a new issue
No description provided.
Delete branch "sp-recv-functional"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Picked from #35302 as an isolated change that can be evaluated independently. This should make #35302 a bit easier to review. This adds a Python implementation of BIP352 scanning, without labels, so the functional tests can check silent payments outputs independently of
bitcoindsupport. It is tested against the BIP352 receiving test vectors.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.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.
Earlier concerns remain unresolved; see the Run archive linked from the Review report.
🔵 Suggestion · Witness-version skip rule lacks Python coverage
The Python receiving vectors contain no witness-version-2-or-higher prevouts, so removing the transaction-wide skip guard from
scan()would leave the existing assertions unchanged.Location:
test/functional/test_framework/bip352.py:60(head).Review coverage was incomplete.
Reviewed:
cd6d7e240bb2· Review report · Previous reportspermalink
Concept ACK, well scoped change.
I did a brief review, see comments below
nit: could add a small comment here, explaining the function?
too many magic nums here and other places
Isn't this an issue when the output is in a transaction that is confirmed? getrawtransaction will return confirmed tx too when tx index is enabled.
I can include an old payment, and you may think it's a new payment during this scan, so you want to check the utxo set and getmempool entry or gate and only return the output when getmempool entry also returns the tx?
nit: too many nested loops; can u simplify? It would make it easy to follow.
Concept ACK
non-blocking suggestion: I wonder if introducing
is_{p2tr,p2pkh...}_scripthelpers (or aSolverequivalent) inscript_util.pywould make sense to keep the output script matching logic out of this file, kind of surprised that we don't have that already in the functional test frameworkI don't think extracting into a separate function would help much for readability
re https://github.com/bitcoin/bitcoin/pull/36835#discussion_r4551222771
I think this suggestion makes sense, so the magic numbers and such can move to
script_util.pyThis is by design. We check for confirmed payments here as well, whose inputs will inherently not be in the UTXO set. See this commit for the use cases. FWIW, a "real" scanner would use the undo data and block rather than
-txindexandgetrawtransaction.Side note related to thsee calls, either we assume
-txindexis enabled as is done here, or the user has to pass a block hash they expect the payment to be in, which would be cumbersome for writing tests IMO.It did a bit. I added a function that creates an iterator for the receiving test vectors after parsing the json.
Added
fdfd7467cfwith someis_p2*utilities and a witness version function🚧 At least one of the CI tasks failed.
Task
lint: https://github.com/bitcoin/bitcoin/actions/runs/43298469093/job/131462961033LLM reason (✨ experimental): CI failed in Python lint:
bip352.py:35passes aninttois_p2wpkh, which expectsbytes.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Moved to
fdfd7467cfwith a descriptionShouldn't we loop on outputs and see if they match an output for the current (increasing) k instead? Here, there is a very minimal, but non null, chance that there is a k that matches, but is not actually a sp output?
OR, if we keep the loop in that way because it is 'safe enough', then maybe we should at least stop the range at min(K_MAX, len(outputs)) to save on scan time?
This matches the BIP.
k = 0and no found outputs exits the loop.Oh you're right. I read the loop assuming the function would have to scan for potentially multiple scan keys of multiple sp receive addresses of the wallet. Now i understand.
6ad35e8686added themake_sp_addrfunction from #35302 along with tests. Also included a short note on-txindexin thescan_txfunction.ACK https://github.com/bitcoin/bitcoin/pull/36835/commits/6ad35e8686075cdc51ebb8ff3857ea50e13325fb
Modulo some nits.
https://github.com/bitcoin/bitcoin/pull/36835/commits/6ad35e8686075cdc51ebb8ff3857ea50e13325fb:
nit: Can return early if
outputsis empty.https://github.com/bitcoin/bitcoin/pull/36835/commits/6ad35e8686075cdc51ebb8ff3857ea50e13325fb:
When a Coinbase TX is supplied, txid will be
000...00, andgetrawtransactionwill fail withtest_framework.util.JSONRPCException: No such mempool or blockchain transaction. Use gettransaction for wallet transactions. (-5).Not sure what approach is most appropriate here; on the one hand, a user shouldn't try to scan a coinbase tx, and maybe the code should crash and force the user to adjust the test, but I also see this happening when a user tries to scan a block, and an argument could be made that the function should simply skip a coinbase tx the way the production scanning function would.
c4580eae58skips coinbases, per the BIP, and also adds the early return in the case there are no PT2R outputs in the transactionReACK https://github.com/bitcoin/bitcoin/pull/36835/commits/c4580eae5817a22d3630f996ff5455b9f7b23581
scan_txis dead for now; we are not sure it compiles in C.I, and it does not seem like a utility because it needs state and a-txindexrequirement. Probably fits better as a helper in the actual test?Thanks, this reads much better now.
Sure, we can have this module be self tested entirely. I don't think #35302 uses this in multiple files anyway.
🚧 At least one of the CI tasks failed.
Task
lint: https://github.com/bitcoin/bitcoin/actions/runs/44109510291/job/134130936328LLM reason (✨ experimental): CI failed because Python linting found three unused imports in
test/functional/test_framework/bip352.py(ruff F401 errors).Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
ACK
cd6d7e240bI agree that deferring the introduction of
scan_txto another PR (likely #35302) makes sense, given that it it's currently unused/untested.nit: could consider moving this function (and the decoding counterpart) to
address.pyin the futurenit: reference the bip here.
ACK
cd6d7e240bReACK https://github.com/bitcoin/bitcoin/pull/36835/commits/cd6d7e240bb22e5d9515bd8cf8dbc081ff471dc8
ACK
cd6d7e240b