Skip to content

test: use address_to_scriptpubkey instead of RPC call - #27349

Merged
fanquake merged 2 commits into
bitcoin:masterfrom
ismaelsadeeq:use-address_to_scriptpubkey
Mar 29, 2023
Merged

fanquake merged 2 commits into
bitcoin:masterfrom
ismaelsadeeq:use-address_to_scriptpubkey

Conversation

@ismaelsadeeq

Copy link
Copy Markdown
Member

PR #27269 enables the function address_to_scriptpubkey() to decode all address types and return their corresponding scriptpubkeys. As a result, there is no longer any need to call getaddressinfo or validateaddress RPCs in order to retrieve an address scriptpubkey, as explained in the comments on this pull request (see #27269 (review) and #27269 (comment)).

Instead of using RPC calls, this update replaces the process of obtaining an address scriptPubkey with the address_to_scriptpubkey method, resulting in improved performance for functional tests.

@DrahtBot

DrahtBot commented Mar 27, 2023 •

Copy link
Copy Markdown
Contributor

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK josibake, theStack

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@ismaelsadeeq

Copy link
Copy Markdown
Member Author

@josibake @theStack @willcl-ark this is PR #27269 follow up, I will appreciate your reviews.
Thank you

@ismaelsadeeq ismaelsadeeq changed the title refactor: use address_to_scriptpubkey instead of RPC call test: use address_to_scriptpubkey instead of RPC call Mar 27, 2023
@ismaelsadeeq
ismaelsadeeq force-pushed the use-address_to_scriptpubkey branch from 613d333 to b4a7a7f Compare March 27, 2023 23:23
@ismaelsadeeq
ismaelsadeeq marked this pull request as draft March 27, 2023 23:51
@ismaelsadeeq
ismaelsadeeq force-pushed the use-address_to_scriptpubkey branch from b4a7a7f to c73a065 Compare March 28, 2023 00:13
@ismaelsadeeq
ismaelsadeeq marked this pull request as ready for review March 28, 2023 00:45
@ismaelsadeeq
ismaelsadeeq marked this pull request as draft March 28, 2023 00:51

@josibake josibake left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK c73a065

Nice to see a standard function for getting the scriptPubKey instead of a mix of RPC calls. Removing the RPC call should make the tests run faster, but considering it wasn't used in many places, I doubt it makes a material difference. Left two non-blocking nits.

I also noticed the CI was failing, but when I rebased on master and ran the failing functional test locally, everything passed.

Comment thread test/functional/feature_nulldummy.py Resolved
@josibake

Copy link
Copy Markdown
Member

@ismaelsadeeq seems ready for review to me

@ismaelsadeeq
ismaelsadeeq marked this pull request as ready for review March 28, 2023 07:48
@ismaelsadeeq
ismaelsadeeq force-pushed the use-address_to_scriptpubkey branch 2 times, most recently from 64d7f54 to 01e0a16 Compare March 28, 2023 10:52
@ismaelsadeeq

ismaelsadeeq commented Mar 28, 2023 •

Copy link
Copy Markdown
Member Author

@ismaelsadeeq seems ready for review to me

Ready for review now.

@ismaelsadeeq

Copy link
Copy Markdown
Member Author

ACK c73a065

Nice to see a standard function for getting the scriptPubKey instead of a mix of RPC calls. Removing the RPC call should make the tests run faster, but considering it wasn't used in many places, I doubt it makes a material difference. Left two non-blocking nits.

I also noticed the CI was failing, but when I rebased on master and ran the failing functional test locally, everything passed.

Thank you for the review Josi
I rebased to master recently but it failed again.

@josibake

Copy link
Copy Markdown
Member

ACK 01e0a16

thanks for taking the suggestions! CI failure seems unrelated from what I can tell 🤷

Comment thread test/functional/feature_nulldummy.py Resolved
@ismaelsadeeq
ismaelsadeeq force-pushed the use-address_to_scriptpubkey branch from 01e0a16 to 02ee904 Compare March 28, 2023 13:52

@theStack theStack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK, thanks for following up!
LGTM, left just one small suggestion below.

The COINBASE_MATURITY constant in blocktools.py is imported in wallet.py.
However, importing address_to_scriptpubkey to blocktools.py will
generate a circular import error. Since the method is related to
addresses, it is best to move it to address.py, which will also
fix the circular import error.

Update imports of address_to_scriptpubkey accordingly.
This commit updates the code by replacing the RPC call used to
decode an address and retrieve its corresponding scriptpubkey
with the address_to_scriptpubkey function. address_to_scriptpubkey
function can now decode all addresses formats, which makes
it more efficient to use.
@ismaelsadeeq
ismaelsadeeq force-pushed the use-address_to_scriptpubkey branch from 02ee904 to e47ce42 Compare March 28, 2023 15:58
@josibake

Copy link
Copy Markdown
Member

re-ACK e47ce42

@theStack theStack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK e47ce42 🌱

@fanquake
fanquake merged commit c0311b1 into bitcoin:master Mar 29, 2023
@fanquake

Copy link
Copy Markdown
Member

resulting in improved performance for functional tests.

Generally good to provide some sort of benchmark/indication of the speedup when talking about performance.

@bitcoin bitcoin locked and limited conversation to collaborators Jun 9, 2024
@ismaelsadeeq
ismaelsadeeq deleted the use-address_to_scriptpubkey branch June 27, 2024 11:12
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.

5 participants