-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Run mempool_accept.py even with wallet disabled #21014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept ACK Can you squash your commits @stackman27? |
e585692
to
ce45bd6
Compare
Yes! Should be fine now :) |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
ce45bd6
to
4501022
Compare
4501022
to
27f078c
Compare
27f078c
to
582d57c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments
582d57c
to
f37a517
Compare
There was a problem hiding this 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
91c2848
to
311a6f7
Compare
311a6f7
to
5ed2bde
Compare
There was a problem hiding this 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's optional
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): |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
🐙 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". |
Are you still working on this? Otherwise someone else could pick this up. |
Picked up in #22509 |
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 inmempool_accept.py
like explicitly statingnSequence
for RBF and sending tx withmax fee = 0