Skip to content

Conversation

@jonatack
Copy link
Member

@jonatack jonatack commented Jul 3, 2020

Seen while reviewing/testing #13084 and #17204 that both needed a regression test.

This PR adds a regression test based on #13084 (comment) to ensure OP_1NEGATE satisfies the BIP62 minimal push standardness rule. This test fails at the commit immediately before each of these PRs (#13084 and #17204) and passes with their fixes. It also passes on current master.

@jonatack jonatack force-pushed the test-OP_1NEGATE-and-use-OP_RIGHT branch 2 times, most recently from f1b4654 to 0b26e1e Compare July 3, 2020 11:42
@jonatack
Copy link
Member Author

jonatack commented Jul 3, 2020

Minimised the changeset.

@practicalswift
Copy link
Contributor

Concept ACK

Thanks for filling this testing gap!

@meshcollider
Copy link
Contributor

I don't think it makes sense to replace 0x81 with OP_RIGHT, 0x81 is not an op code, it has nothing to do with OP_RIGHT, it just represents the number -1

I'm just looking into how this was fixed in master, I don't immediately see where the change is that fixed it 🤔

@jonatack
Copy link
Member Author

I vaguely recall it was fixed shortly after #13084 in another commit; I should have specified it.

@jonatack
Copy link
Member Author

I don't think it makes sense to replace 0x81 with OP_RIGHT, 0x81 is not an op code, it has nothing to do with OP_RIGHT, it just represents the number -1

Oh right, in BIP62 it says "Pushing the byte 0x81 must use OP_1NEGATE." I'll remove that commit.

with a regression test for PR 13084 and PR 17204.
@jonatack jonatack changed the title consensus, test: use OP_RIGHT, ensure OP_1NEGATE satisfies BIP62 test: ensure OP_1NEGATE satisfies BIP62 Jul 11, 2020
@jonatack jonatack force-pushed the test-OP_1NEGATE-and-use-OP_RIGHT branch from 0b26e1e to 3913278 Compare July 11, 2020 09:19
@meshcollider
Copy link
Contributor

Somehow I think this is avoiding the issue, the test is good but PushAll will still push 0x81 as a byte instead of using the OP_1NEGATE opcode if #17204 doesn't go in as well. I think it would still be good to include it for future safety, even if this practical instance of the bug is fixed.

@jonatack
Copy link
Member Author

Ok, removed "Closes #17204" from this PR description.

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

Code review ACK 3913278

@maflcko maflcko removed the Consensus label Jul 11, 2020
@maflcko
Copy link
Member

maflcko commented Jul 11, 2020

The test fails at the commit immediately before each of these PRs

Can you explain which prs you are referring to?

@jonatack
Copy link
Member Author

The test fails at the commit immediately before each of these PRs

Can you explain which prs you are referring to?

The PRs in the first sentence -- updated to make it more clear.

@maflcko
Copy link
Member

maflcko commented Jul 11, 2020

How can the test pass on master but fail before those pull requests? That sounds like a merge conflict

@jonatack
Copy link
Member Author

Maybe it was fixed since those PRs in other work that touched the code.

  • The test fails at a0079d4, and passes at 5af7625 and at 45af54f. I just re-ran these.

  • The test passed on master when I opened the PR and passes on master at 160800a now.

@jonatack
Copy link
Member Author

Just built at 476cb35 and it fails as well.

@meshcollider
Copy link
Contributor

How can the test pass on master but fail before those pull requests? That sounds like a merge conflict

As I said above, the behavior in master avoids the previous issue, those PRs fixed the issue in a different way which would still be good to include. The symptom is gone but the original cause is still present in master so it isn't a conflict.

@maflcko
Copy link
Member

maflcko commented Jul 12, 2020

It just seemed a bit weird to call this a regression test for a patch that is not yet merged. It should mention that the regression test can only be tested on the patch when rebased on commits prior to ed94c8b

Otherwise, if the patch gets rebased on current master, the test will pass both before and after. Something that seems odd for a regression test.

@jonatack
Copy link
Member Author

It just seemed a bit weird to call this a regression test for a patch that is not yet merged. It should mention that the regression test can only be tested on the patch when rebased on commits prior to ed94c8b

Otherwise, if the patch gets rebased on current master, the test will pass both before and after. Something that seems odd for a regression test.

I think the PR description is fine. The test is to protect against regression to the state before the mentioned PRs. I thought it might be helpful, but I'd rather not spend time bikeshedding.

@jonatack jonatack closed this Jul 12, 2020
@maflcko
Copy link
Member

maflcko commented Jul 12, 2020

Sorry, I didn't want to imply to close this. The test is fine and useful. I think the description can be improved to mention the interaction with commit ed94c8b, but that has nothing to do with the test code itself.

@meshcollider
Copy link
Contributor

I'll cherry-pick this into #17204 if that's ok with you @jonatack

@jonatack
Copy link
Member Author

@MarcoFalke thanks, @meshcollider ACK

@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.

5 participants