Skip to content

Conversation

@theStack
Copy link
Contributor

@theStack theStack commented Mar 22, 2022

This PR enables one more of the non-wallet functional tests (mempool_package_onemore.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in #20078. For this purpose helper methods MiniWallet.{create,send}_self_transfer_multi are introduced which serve as a replacement for chain_transaction. With this, it should be also quite straight-forward to change the larger related test mempool_packages.py to use MiniWallet.

@fanquake fanquake added the Tests label Mar 22, 2022
Copy link
Member

@maflcko maflcko 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. Some questions/thoughts.

@theStack theStack force-pushed the 20220322-test-use_MiniWallet_for_mempool_packages_onemore branch from 87f28c1 to 913a09c Compare March 22, 2022 13:44
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Left some more nits 😅

Copy link
Member

Choose a reason for hiding this comment

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

nit: Is this needed? The next line will assert even without this, but I can see the reason for a slightly better error message.

Comment on lines 200 to 228
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe wrap all of this into a create_self_transfer_multi helper for symmetry with the existing helpers?

Copy link
Member

Choose a reason for hiding this comment

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

nit: (Some renames for symmetry)

Suggested change
def chain_tx(self, node, utxos, num_outputs=1, fee_per_output=1000):
def send_self_transfer_multi(self, node_from, utxos, *, num_outputs=1, fee_per_output=1000):

@theStack theStack force-pushed the 20220322-test-use_MiniWallet_for_mempool_packages_onemore branch from 913a09c to 5d0c26a Compare March 22, 2022 14:33
@theStack
Copy link
Contributor Author

theStack commented Mar 22, 2022

Thanks again for the valuable feedback @MarcoFalke! Force-pushed with the following suggested changes:

The PR description was also adapted accordingly.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

(feel free to ignore)

Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
def create_self_transfer_multi(self, from_node, utxos, *, num_outputs=1, fee_per_output=1000):
def create_self_transfer_multi(self, *, from_node, utxos, num_outputs=1, fee_per_output=1000):

Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
def send_self_transfer_multi(self, from_node, utxos, **kwargs):
def send_self_transfer_multi(self, *, from_node, utxos, **kwargs):

Also, "utxos" can be renamed to "inputs" or "utxos_to_spend".

Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe return a dict similar to send_self_transfer?

Suggested change
return [self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))]
return {"new_utxo":[self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))], "tx": tx}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def send_self_transfer_multi(self, from_node, utxos, **kwargs):
def send_self_transfer_multi(self, **kwargs):

or maybe even just

@theStack theStack force-pushed the 20220322-test-use_MiniWallet_for_mempool_packages_onemore branch from 5d0c26a to 2b6dd4e Compare March 22, 2022 17:47
@theStack
Copy link
Contributor Author

theStack commented Mar 22, 2022

Force-pushed again with the following changes:

  • all parameters for the newly introduced methods {create,send}_self_transfer_multi methods must be passed as keyword arguments now (to be consistent with {create,self}_transfer methods)
  • send_self_transfer_multi returns a dictionary with several informations (txid, tx serialized as hex, tx as CTransaction instance, list of new UTXOs)
  • introduced small helper chain_tx in the test in order to avoid repeatedly passing from_node arguments and being able to pass utxos and num_outputs as positional arguments; returns new UTXOs
  • getrawtransaction RPC at the end of the test is not needed anymore, since we can directly access the tx field from the result dictionary

@fanquake fanquake requested a review from glozow March 24, 2022 11:16
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

ACK 2b6dd4e 💾

Show signature

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 2b6dd4e75b3ad2daff553fde018fe4c8f1187878 💾
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUh0jgwAlqAJ870kGVFw8j59DsDnOgazr4Q3gZs3ev7+QPUDwABrwzfJggjUWYy8
G+fBs+4b/buewrlpMpLHMoAza3n1ib4yiR4Ayebbj65vyVhRVERBncLMlbnYDU7c
VQR0Fkuz5FTza9P7BuIegO3JPOXxPnJi5AKg8xSsIY7vZfNvXuwn74zyZqI14hCm
iDG4JtKtyiYpL+Mct9UWD9mKBUlEW1KnESejKVj5eQTG5ww0TijlNCfQ7W+JTE3m
ndwqmbuPI5RM7YqytsKuTpPc584nqr/zM1/AuIGM7aEM8BdwTW5StJCL6AuPL1B+
wD3w7HVltleskkvmj2407xPZkiGanxzOE7L3Q5G0GiWDCJFYU6jqXbRoJ8ml/oPn
b8kILOTtLvEqRNry8bOGiOAxTGZG8VkdsvRtjxBE/HLGtgX/avlN9ELPPvLE6GKD
rY+isoIqlqqGGZfLegweVnCuLJVS0+1o8HJAgwPyhyejVXbcU1EACstphCNdMtd8
s9QdQ3hV
=mjSo
-----END PGP SIGNATURE-----

Comment on lines +227 to +228
for i in range(num_outputs):
tx.vout[i].nValue = outputs_value_total // num_outputs
Copy link
Member

Choose a reason for hiding this comment

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

nit: Haven't tried, but this might be possible to write shorter

Suggested change
for i in range(num_outputs):
tx.vout[i].nValue = outputs_value_total // num_outputs
for o in tx.vout:
o.nValue = outputs_value_total // num_outputs

Copy link
Member

Choose a reason for hiding this comment

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

Done in #24623

@maflcko maflcko merged commit 864fb89 into bitcoin:master Mar 24, 2022
@theStack theStack deleted the 20220322-test-use_MiniWallet_for_mempool_packages_onemore branch March 25, 2022 11:12
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 2, 2022
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Apr 11, 2022
494455f test: use MiniWallet for feature_fee_estimation.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (feature_fee_estimation.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in bitcoin#20078. It takes use of the recently introduced methods `{create,send}_self_transfer_multi` (bitcoin#24637) which allows to specify multiple UTXOs to be spent rather than only one. Very likely the test can still be simplified (e.g. coin selection in `small_txpuzzle_randfee`), but this is a first step.

ACKs for top commit:
  ayush933:
    tACK 494455f . The test runs successfully with the wallet disabled.
  vincenzopalazzo:
    tACK bitcoin@494455f

Tree-SHA512: 89789fc34a4374c79c4b90acd926ac69153aad655dab50450ed796f03c770bd675ad872e906f516f90e8d4cb40b83b55f3c78a94b13bfb8fe8f5e27624937748
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 11, 2022
494455f test: use MiniWallet for feature_fee_estimation.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (feature_fee_estimation.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in bitcoin#20078. It takes use of the recently introduced methods `{create,send}_self_transfer_multi` (bitcoin#24637) which allows to specify multiple UTXOs to be spent rather than only one. Very likely the test can still be simplified (e.g. coin selection in `small_txpuzzle_randfee`), but this is a first step.

ACKs for top commit:
  ayush933:
    tACK 494455f . The test runs successfully with the wallet disabled.
  vincenzopalazzo:
    tACK bitcoin@494455f

Tree-SHA512: 89789fc34a4374c79c4b90acd926ac69153aad655dab50450ed796f03c770bd675ad872e906f516f90e8d4cb40b83b55f3c78a94b13bfb8fe8f5e27624937748
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
maflcko pushed a commit that referenced this pull request Dec 5, 2022
0b78110 test: Move tx creation to create_self_transfer_multi (kouloumos)

Pull request description:

  Two birds with one stone: replacement of #26278 with simplification of the MiniWallet's transaction creation logic.

  Currently the MiniWallet creates simple txns (1 input, 1 output) with `create_self_transfer`.  #24637 introduced `create_self_transfer_multi` **which uses** `create_self_transfer` to create a "transaction template" which then adjusts (copy and mutate inputs and outputs) in order to create more complex multi-input multi-output transactions.
  This can more easily lead to issues such as #26278 and is more of a maintenance burden.

  This PR simplifies the logic by going the other way around. Now `create_self_transfer` **uses** `create_self_transfer_multi`.
  The transaction creation logic has been moved to `create_self_transfer_multi` which is being called by `create_self_transfer` to construct the simple case of 1 input 1 output transaction.

ACKs for top commit:
  MarcoFalke:
    ACK 0b78110 👒

Tree-SHA512: 147e577ed5444bee57865bd375b37c9b49d6539e9875c30c2667e70fcba27fe80bcb4552a4e6efb42760d34b40d5dad826883b778eaeefe29425ec081787b4bd
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 5, 2022
…ulti

0b78110 test: Move tx creation to create_self_transfer_multi (kouloumos)

Pull request description:

  Two birds with one stone: replacement of bitcoin#26278 with simplification of the MiniWallet's transaction creation logic.

  Currently the MiniWallet creates simple txns (1 input, 1 output) with `create_self_transfer`.  bitcoin#24637 introduced `create_self_transfer_multi` **which uses** `create_self_transfer` to create a "transaction template" which then adjusts (copy and mutate inputs and outputs) in order to create more complex multi-input multi-output transactions.
  This can more easily lead to issues such as bitcoin#26278 and is more of a maintenance burden.

  This PR simplifies the logic by going the other way around. Now `create_self_transfer` **uses** `create_self_transfer_multi`.
  The transaction creation logic has been moved to `create_self_transfer_multi` which is being called by `create_self_transfer` to construct the simple case of 1 input 1 output transaction.

ACKs for top commit:
  MarcoFalke:
    ACK 0b78110 👒

Tree-SHA512: 147e577ed5444bee57865bd375b37c9b49d6539e9875c30c2667e70fcba27fe80bcb4552a4e6efb42760d34b40d5dad826883b778eaeefe29425ec081787b4bd
@bitcoin bitcoin locked and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants