Skip to content

Conversation

@theStack
Copy link
Contributor

@theStack theStack commented Jan 13, 2020

Adds an empty stack failure check for OP_CSV (BIP112) to the functional test feature_csv_activation.py by prepending a valid scriptSig with OP_CHECKSEQUENCEVERIFY.
If BIP112 is inactive, the operator just behaves as a NOP (for both tx versions 1 and 2) and the transaction remains valid -- if it is active, the tx is invalid due to an empty stack (for both tx versions 1 and 2, as well).

@fanquake fanquake added the Tests label Jan 13, 2020
@fanquake fanquake requested a review from instagibbs January 14, 2020 03:51
Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

Your changes look ok I guess, but the magic numbers in mining are throwing me off.

I think in general this test needs some loving, but I think if the magic mining numbers are explained and we check for specific reject reasons this is an improvement

@theStack
Copy link
Contributor Author

@instagibbs: Thanks for reviewing! Before I get into action: should I really put in all those suggested changes (magic numbers elimination/explanation, reject reason checking, adding empty stack test case) in one single PR?
I feel it may make more sense to start off with a new PR that only includes reject reason checking for all places (not just the ones concerning the new test add here) first, and eliminating/explaining magic numbers, and only then continue here with adding the test, so that the "improve the CSV test in general" and "add a new concrete CSV subtest" are two separate parts that are independent and make reviewing easier. Thoughts on this? Is just dividing it up here in two commits enough?

@instagibbs
Copy link
Member

Minimally I want to know that it's being rejected for the right reasons, not "oops the script is wrong in a different way".

Secondary is the magic numbers floating around, but that can be held off for now(though I'd really appreciate it, magic numbers in tests make them very brittle and hard to understand).

@theStack theStack force-pushed the 20200113-test-check-for-empty-stack-op_csv branch from e8f1227 to 3330bce Compare January 14, 2020 16:26
Copy link
Contributor

@jimmysong jimmysong left a comment

Choose a reason for hiding this comment

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

Would like some documentation on some of the magic numbers. Otherwise, looks good.

@theStack
Copy link
Contributor Author

@jimmysong: Thanks for reviewing! Feels funny to have ones code reviewed by the author of a book that I am just reading right now 😂

@jimmysong
Copy link
Contributor

glad you're reading it!

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 18, 2020

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.

@DrahtBot
Copy link
Contributor

Needs rebase

With BIP112 activated, the operation OP_CHECKSEQUENCEVERIFY (former OP_NOP3)
leads to script interpreter termination with an error if one of the following
conditions is true:
    -> stack is empty
    -> top item on stack is negative (< 0)
    -> top item on stack has disable flag unset and at least one of
       four other conditions is true (contains the core CSV logic)

This commits adds the missing empty stack failure test to the functional test
by prepending a valid scriptSig with just OP_CHECKSEQUENCEVERIFY. If BIP112 is
inactive, the operator just behaves as a NOP (for both tx versions 1 and 2) and
the transaction remains valid -- if it is active, the tx is invalid due to an
empty stack (for both tx versions 1 and 2, as well).
@theStack theStack force-pushed the 20200113-test-check-for-empty-stack-op_csv branch from 93f5ee0 to 5ffaf88 Compare February 28, 2020 08:07
@theStack
Copy link
Contributor Author

Rebased.

@maflcko maflcko merged commit e5753fa into bitcoin:master Feb 28, 2020
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Feb 28, 2020
…sv_activation.py

54be4e7 test: check specific reject reasons in feature_csv_activation.py (Sebastian Falbesoner)

Pull request description:

  This is kind of a prequel to bitcoin#17921: increases the general quality of the functional test `feature_csv_activation.py` by checking for the specific reject reasons whenever the sending of a block fails. To get the reason, we have to limit the script threads to 1 via the parameter `-par=1`, like it is also done in `feature_cltv.py`:
  https://github.com/bitcoin/bitcoin/blob/a654626f076a72416a3d354218d7107571d6caaf/test/functional/feature_cltv.py#L57-L61

  The commit also fixes a bug that was uncovered with this checks: for the BIP112 version 1 tx tests, txs from `bip112txs_vary_OP_CSV_v1` have been add twice to the list `failed_txs`:
  https://github.com/bitcoin/bitcoin/blob/a654626f076a72416a3d354218d7107571d6caaf/test/functional/feature_csv_activation.py#L396-L397

  leading also to a block rejection as expected but for the wrong reason. It seems one of those two tx lists was meant to be `bip112txs_vary_OP_CSV_v1` (without the `_9`) and it was a typo.

ACKs for top commit:
  MarcoFalke:
    ACK 54be4e7 📶

Tree-SHA512: 9aac11aee3f53f1ae95ddb346a2f268872038f4d118c8dcf81b8201dee869774c9f3c3f1c326e370b8fd4eaf8e0673371689a96d9b1cb91be4286c88824725c3
@theStack theStack deleted the 20200113-test-check-for-empty-stack-op_csv branch December 1, 2020 09:58
PiRK added a commit to PiRK/bitcoin that referenced this pull request Apr 18, 2021
These changes in the test documentation reflect the changes introduced in bitcoin#17921
maflcko pushed a commit that referenced this pull request Apr 19, 2021
9053b88 update docstring in feature_csv_activation.py (Pierre K)

Pull request description:

  These changes in the test documentation reflect the changes introduced in #17921.

ACKs for top commit:
  MarcoFalke:
    review ACK  9053b88

Tree-SHA512: 17fb954baded8dab1c869dd48b76b516150bae616c792c573e4114d4adfdd40195745c56570aa3050cc0015ee496acd7ec178df8ba14831dd22f9722fda84da2
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 19, 2021
…tion.py

9053b88 update docstring in feature_csv_activation.py (Pierre K)

Pull request description:

  These changes in the test documentation reflect the changes introduced in bitcoin#17921.

ACKs for top commit:
  MarcoFalke:
    review ACK  9053b88

Tree-SHA512: 17fb954baded8dab1c869dd48b76b516150bae616c792c573e4114d4adfdd40195745c56570aa3050cc0015ee496acd7ec178df8ba14831dd22f9722fda84da2
windsok pushed a commit to windsok/bitcoin that referenced this pull request Apr 23, 2021
These changes in the test documentation reflect the changes introduced in bitcoin#17921
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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