Skip to content

Conversation

darosior
Copy link
Member

@darosior darosior commented Sep 23, 2021

Some cleanups that i noticed would be desirable while working on #23074 and #22539, which are intentionally not based on it. Mainly simplifications and a slight speedup.

  • Use a single tx to create the 2**9 coins instead of creating 2**8 2-outputs transactions
  • Use a single P2SH script
  • Avoid the use of non-standard transactions
  • Misc style nits (happy to take more)

@laanwj laanwj added the Tests label Sep 23, 2021
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 23, 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:

  • #13990 (Allow fee estimation to work with lower fees by ajtowns)

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.

@theStack
Copy link
Contributor

theStack commented Oct 4, 2021

Concept ACK

After #22539 is merged, I'd suggest to also replace bare asserts with assert_equal()/assert_greater_than() helpers in the newly introduced subtest sanity_check_rbf_estimates (plus other fixups proposed in #22539).

@darosior
Copy link
Member Author

Rebased and addressed @theStack 's feedback from both here and #22539. But i forgot #22539 (comment), will address but i think it can start to be reviewed in the meantime.

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.

Concept ACK

@darosior
Copy link
Member Author

Rebased. Gave a look to replacing the use of the P2SH anyonecanspend by Miniwallet and it's actually a pretty invasive refactoring of the test.

@DariusParvin
Copy link
Contributor

Concept ACK. In a future PR, I think the initial_split function could be moved to the MiniWallet since other tests could benefit from it too.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
@darosior darosior force-pushed the fee_est_test_cleanup branch from 4eb027e to 0db0907 Compare December 9, 2021 12:27
@darosior
Copy link
Member Author

darosior commented Dec 9, 2021

Rebased.

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.

overall looks good, nice cleanup. I think there's a commit diff reorg needed - feature_fee_estimation.py doesn't pass in 9d6a88e because it doesn't fully remove instances of SCRIPT_SIG

@glozow
Copy link
Member

glozow commented Dec 9, 2021

Also seems like you tried to co-author @theStack in 7ccd775, but it needs to be on the 1st line maybe?

@fanquake
Copy link
Member

fanquake commented Dec 9, 2021

Also seems like you tried to co-author

The issue is that Co-Atuhored-By: is spelt wrong.

Using 2 different scripts is unnecessary complication

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This simplifies the code, and slightly speeds up the test.

Running `./test/functional/test_runner.py -j15 $(printf 'feature_fee_estimation %.0s' {1..15})`
on master 3 times gives:

- Before:
    ALL                       | ✓ Passed  | 788 s (accumulated)
    ALL                       | ✓ Passed  | 818 s (accumulated)
    ALL                       | ✓ Passed  | 873 s (accumulated)

- After:
    ALL                       | ✓ Passed  | 763 s (accumulated)
    ALL                       | ✓ Passed  | 798 s (accumulated)
    ALL                       | ✓ Passed  | 731 s (accumulated)

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
We don't need dust outputs anymore.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
darosior and others added 2 commits December 9, 2021 15:11
Followups to bitcoin#22539

Co-Authored-By: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
@darosior darosior force-pushed the fee_est_test_cleanup branch from 0db0907 to 60ae116 Compare December 9, 2021 14:31
@darosior
Copy link
Member Author

darosior commented Dec 9, 2021

Thanks you both! Done.

Copy link

@pg156 pg156 left a comment

Choose a reason for hiding this comment

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

Thank you for the pr. As a newcomer, I find it very educational to review.

I ACK all commits up to 60ae116 (except 1fc0315, where I have a question more for my own learning than actually questioning the PR). I built and ran the test successfully. I agree after the changes, the behavior is kept the same and the code is shorter and easier to reason.

self.confutxo = [
{"txid": txid, "vout": i, "amount": splitted_amount}
for i in range(utxo_count)
]
while len(node.getrawmempool()) > 0:
self.generate(node, 1, sync_fun=self.no_op)
Copy link

Choose a reason for hiding this comment

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

Is the node "state" here expected to exactly the same before and after changes in 1fc0315? If so, how to test?

E.g. this is what I tried to compare:

  • before

node.getbalance() returns Decimal('1200.00000000')
len(node.listunspent()) returns 24

  • after

node.getbalance() returns Decimal('1150.00000000')
len(node.listunspent()) returns 23

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the node "state" here expected to exactly the same before and after changes in 1fc0315?

It's not. At least, it was not my intention.


# vbytes == bytes as we are using legacy transactions
fee = tx.get_vsize() * feerate
tx.vout[0].nValue -= fee

Copy link

Choose a reason for hiding this comment

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

@darosior said "since we use legacy txs in this test it's indeed much cleaner" in #22539 (comment). Does this mean for non-legacy txs, we can no longer use the same logic fee = tx.get_vsize() * feerate to calculate fee?

Copy link
Member Author

Choose a reason for hiding this comment

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

#22539 (comment) was refering to using the length of the serialized transaction. This works only for legacy transactions as there is no witness data discount (hence 1 byte == 1 vbyte).

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.

utACK 60ae116

Light code re-review, commits all pass now. Thanks for addressing comments, sorry for the delay!

# Force fSendTrickle to true (via whitelist.noban)
self.extra_args = [
["-acceptnonstdtxn", "-whitelist=noban@127.0.0.1"],
["-acceptnonstdtxn", "-whitelist=noban@127.0.0.1", "-blockmaxweight=68000"],
["-acceptnonstdtxn", "-whitelist=noban@127.0.0.1", "-blockmaxweight=32000"],
Copy link
Member

Choose a reason for hiding this comment

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

yus 🚀 big fan of removing -acceptnonstdtxn

@maflcko maflcko changed the title refactoring: Fee estimation functional test cleanups test: Fee estimation functional test cleanups Jan 6, 2022
@maflcko maflcko merged commit 799fd7a into bitcoin:master Jan 6, 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.

LGTM

P2SH_2 = script_to_p2sh_script(REDEEM_SCRIPT_2)
SCRIPT = CScript([OP_1, OP_DROP])
P2SH = script_to_p2sh_script(SCRIPT)
REDEEM_SCRIPT = CScript([OP_TRUE, SCRIPT])
Copy link
Member

Choose a reason for hiding this comment

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

I think the previous wording was correct. Redeem script refers to the thing that is hashed (serialized), see also BIP 16:

serialized script - also referred to as the redeemScript

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 6, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Jan 6, 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.

9 participants