Skip to content

Conversation

stackman27
Copy link
Contributor

@stackman27 stackman27 commented Jan 26, 2021

This is a PR proposed in #20078

This PR enables one more of the non-wallet functional tests (mempool_accept.py) to be run even with the Bitcoin Core wallet disabled by using the new MiniWallet instead.

This PR also includes changes on wallet.py to accommodate some of the features used in mempool_accept.py like explicitly stating nSequence for RBF and sending tx with max fee = 0

@michaelfolkson
Copy link

Concept ACK

Can you squash your commits @stackman27?

@DrahtBot DrahtBot added the Tests label Jan 26, 2021
@stackman27 stackman27 force-pushed the diswallet_mempoolaccept branch from e585692 to ce45bd6 Compare January 26, 2021 21:00
@stackman27
Copy link
Contributor Author

Concept ACK

Can you squash your commits @stackman27?

Yes! Should be fine now :)

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 27, 2021

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.

@stackman27 stackman27 force-pushed the diswallet_mempoolaccept branch from 27f078c to 582d57c Compare February 7, 2021 15:05
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 comments

Copy link
Contributor

@DariusParvin DariusParvin left a comment

Choose a reason for hiding this comment

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

Looks good! The only thing is I think having a separate create_self_transfer method would be more straightforward than having a send_tx flag in send_self_transfer. With the send_tx flag, it also becomes a bit ambiguous whether the new utxo has been appended to the list of spendable utxos when send_tx = False.

@@ -55,25 +55,34 @@ def get_utxo(self, *, txid=''):
index = self._utxos.index(utxo)
return self._utxos.pop(index)

def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None):
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), seq_num = 0xffffffff, from_node, utxo_to_spend=None, send_tx = True, default_fee = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like it might be misleading to have a method whose name is send_self_transfer, but then have a flag to say send = False.

Instead, maybe it would be more straightforward to have a separate method create_self_transfer, that returns the tx hex. This function could be used within send_self_transfer to create the transaction before broadcasting it.

I'm about to submit a PR for another test where I had a go at doing it this way.

Copy link
Contributor Author

@stackman27 stackman27 Feb 19, 2021

Choose a reason for hiding this comment

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

That totally makes sense! or maybe we can simply rename the method to something that mimics it's accurate behavior, something in the lines of sign_or_send_self_transfer. Would love to hear @MarcoFalke's thoughts on this

@stackman27 stackman27 force-pushed the diswallet_mempoolaccept branch from 91c2848 to 311a6f7 Compare February 19, 2021 16:21
@stackman27 stackman27 force-pushed the diswallet_mempoolaccept branch from 311a6f7 to 5ed2bde Compare March 1, 2021 16:14
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

A few comments
Also on style - from PEP8: "Don't use spaces around the = sign when used to indicate a keyword argument, or when used to indicate a default value for an unannotated function parameter"

@@ -55,7 +55,7 @@ def get_utxo(self, *, txid=''):
index = self._utxos.index(utxo)
return self._utxos.pop(index)

def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None):
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), seq_num = 0xffffffff, from_node, utxo_to_spend=None, send_tx = True, nVersion = 1, default_fee = False):
Copy link
Member

Choose a reason for hiding this comment

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

Since it's optional

Suggested change
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), seq_num = 0xffffffff, from_node, utxo_to_spend=None, send_tx = True, nVersion = 1, default_fee = False):
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None, send_tx=True, nVersion=1, seq_num=0xffffffff, default_fee=False):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotchu!

self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value})
from_node.sendrawtransaction(tx_hex)
if send_tx:
if default_fee:
Copy link
Member

Choose a reason for hiding this comment

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

This should be called bypass_maxfeerate. But really, since it's a parameter for sendrawtransaction, why isn't the caller doing a send_tx=False and then submitting it themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this was following Darius's comment. I could only append tx in self.utxos after sending a transaction. If I try to simply send transaction from somewhere else, I wouldn't be able to append it in the internal wallet.py list

tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
tx.nVersion = 2
Copy link
Member

Choose a reason for hiding this comment

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

You're accepting a nVersion param but not using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops my bad 😅

inputs=[{"txid": txid_in_block, "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}], # RBF is used later
outputs=[{node.getnewaddress(): Decimal('0.3') - fee}],
))['hex']
fee = Decimal('0.00000672')
Copy link
Member

Choose a reason for hiding this comment

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

You're changing the fee?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea cause the previous fee of fee = Decimal('0.000007') was too low to pass the mempool test. I manually calculated the fee here fee_rate = Decimal('0.00007672') - fee,, to get the best option


self.log.info('Start with empty mempool, and 200 blocks')
self.mempool_size = 0
miniwallet.generate(10)
node.generate(190)
Copy link
Member

Choose a reason for hiding this comment

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

Assuming this is done to mature the coinbases... is there any reason to do more than 100?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, just wanted to keep 200 blocks to mimic the current code

@DrahtBot
Copy link
Contributor

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

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@maflcko
Copy link
Member

maflcko commented Jul 18, 2021

Are you still working on this? Otherwise someone else could pick this up.

@maflcko
Copy link
Member

maflcko commented Jul 20, 2021

Picked up in #22509

@fanquake fanquake closed this Jul 21, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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.

9 participants