Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Jun 10, 2021

This comes with nice benefits:

  • Less code and complexity
  • Test can be run without wallet compiled in

Also add some additional checks for getmempoolentry (#22209) and other cleanups 🎨

@fanquake fanquake added the Tests label Jun 10, 2021
@maflcko maflcko force-pushed the 2106-testMiniWallet branch 2 times, most recently from fa621d8 to fa59d50 Compare June 10, 2021 11:19
@theStack
Copy link
Contributor

Concept ACK

Not strictly related to this PR, but: the parameter locktime is currently unused in send_self_transfer, i.e. it is not passed on to create_self_transfer. Now that this part is touched in this PR, this could also be addressed (e.g. in the first commit).

@maflcko maflcko force-pushed the 2106-testMiniWallet branch from fa59d50 to fa7d71f Compare June 10, 2021 11:39
self.nodes[0].generate(1)
self.sync_blocks()
wallet = MiniWallet(self.nodes[0])
wallet.scan_blocks(start=76, num=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does the hardcoded 76 come from? It seems to me you just need a mature utxo here? If that's the case and I'm not missing anything, could you do something like: start=blockheight - COINBASE_MATURITY?

Copy link
Member Author

Choose a reason for hiding this comment

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

The constant is derived from

# Create a 199-block-long chain; each of the 3 first nodes
# gets 25 mature blocks and 25 immature.
# The 4th address gets 25 mature and only 24 immature blocks so that the very last
# block in the cache does not age too much (have an old tip age).
# This is needed so that we are out of IBD when the test starts,
# see the tip age check in IsInitialBlockDownload().
gen_addresses = [k.address for k in TestNode.PRIV_KEYS][:3] + [ADDRESS_BCRT1_P2WSH_OP_TRUE]
assert_equal(len(gen_addresses), 4)
for i in range(8):
cache_node.generatetoaddress(
nblocks=25 if i != 7 else 24,
address=gen_addresses[i % len(gen_addresses)],
)

# Summary section.
# The original transaction (`optout_child_tx`) doesn't signal RBF but its parent (`optin_parent_txid`) does.
# The original transaction (`optout_child_tx`) doesn't signal RBF but its parent (`optin_parent_tx`) does.
# The replacement transaction (`replacement_child_tx`) should be able to replace the original transaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is my understanding here correct?

a) testmempoolaccept returns that replacement_child_tx is allowed even though it is rejected w/ 'txn-mempool-conflict'
b) getmempoolentry returns that optout_child_tx is 'bip125-replaceable' - as you descbribe in #22209 even though it is not

So does anything need to be done to fix a and b?

Another question I have (which maybe I should just try out). But, I wonder what would happen if you tried something like https://github.com/bitcoin/bitcoin/pull/22210/files#diff-260c479178e3e99a16798aeed39f400676894392864784eda6c207716704398dR584-R589 after optout_child_tx was already sent

Copy link
Member Author

Choose a reason for hiding this comment

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

a) No, it is also rejected by testmempoolaccept, see mempool_valid=False for replacement_child_tx above.
b) correct

So does anything need to be done to fix a and b?

Maybe. But a fix should be done outside a test-only change.

@practicalswift
Copy link
Contributor

Concept ACK: MiniWallet good

@mjdietzx
Copy link
Contributor

Tested ACK fa7d71f thanks for the explanations, nicely done

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 16, 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.

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK fa7d71f 🍷

Follow-up idea based on discussion #22210 (comment): This will probably not the last test that needs the block number of the first output to ADDRESS_BCRT1_P2WSH_OP_TRUE (i.e. suitable for MiniWallet in its default mode of MiniWalletMode.ADDRESS_OP_TRUE). In the future it may makes sense to put the magic number 76 into a constant.

@maflcko maflcko merged commit e172ea8 into bitcoin:master Jun 19, 2021
@maflcko maflcko deleted the 2106-testMiniWallet branch June 19, 2021 06:51
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 20, 2021
maflcko pushed a commit that referenced this pull request Jul 30, 2021
… feature_rbf.py

aa02c64 test: use MiniWallet for simple doublespend test in feature_rbf.py (Sebastian Falbesoner)
a3f6397 test: feature_rbf.py: make MiniWallet instance available for all sub-tests (Sebastian Falbesoner)
84c8747 test: remove unneeded initialization code in feature_rbf.py (Sebastian Falbesoner)

Pull request description:

  This PR's goal is to prepare the functional test `feature_rbf.py` for more MiniWallet usage. It first gets rid of unused initialization code (I guess that was needed at times when the nodes were still in IBD at the start of tests?), then makes the MiniWallet instance introduced in #22210 available for all sub-tests, and finally, uses that instance in the first sub-test `test_simple_doublespend`.

  Note that the same idea of replacing the `make_utxo` calls with MiniWallet can be also applied to other sub-tests too; this just serves as a first proof-of-concept.

ACKs for top commit:
  MarcoFalke:
    re-ACK aa02c64 🌯

Tree-SHA512: 2902dd15d493d83b0790028c92d14fbd99ca05ace704c7011fb38261ce6517aeb810ef9f360fcb701d95887975b6a2911cfe538858d38fceb2c1c2a40afdbe6b
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
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.

6 participants