Skip to content

Completely remove disabled opcodes; modify script tests accordingly - #1869

Closed
maaku wants to merge 3 commits into
bitcoin:masterfrom
maaku:remove_disabled_opcodes
Closed

maaku wants to merge 3 commits into
bitcoin:masterfrom
maaku:remove_disabled_opcodes

Conversation

@maaku

@maaku maaku commented Sep 26, 2012

Copy link
Copy Markdown
Contributor

This patch removes the disabled opcodes and the one dependent utility function that is orphaned.

Interestingly there appears to be a slight difference in behavior between explicitly disabled opcodes and reserved/unused opcodes. Previously VerifyScript() would fail any script containing a disabled opcode as soon as it is encountered, whereas reserved/unused opcodes would fail when they are executed. This is a subtle difference, but detectable. Take the following script from the invalid-script unit tests:

0 IF INVERT ELSE 1 ENDIF

This previously failed even though the INVERT is never executed. But now that the disabled opcodes are removed entirely, INVERT becomes 0x83 and is treated like any other unused opcode, meaning that script now passes validation. To fail, the IF-branch of the conditional would have to be taken:

1 IF 0x83 ELSE 1 ENDIF

The last commit of this pull request simply switches the branch taken in this and other unit tests such that the opcode is executed and fails.

However the construction of the unit test clearly indicates that failure even if the opcode is not executed was the desired result. A decision still needs to be made as to whether this behavior should be extended to all reserved/unused opcodes.

Mark Friedenbach added 3 commits September 25, 2012 16:40
…nd OP_XOR.

Due to a bug in the implementation of MakeSameSize(), using OP_AND, OP_OR, or OP_XOR with signed values of unequal size will result in the sign-value becoming part of the smaller integer, with nonsensical results. This patch documents the unexpected behavior and provides the basis of a solution should decision be made to fix the bug in the future.
…meSize(), which was only used by the disabled opcodes).
…aken and the previously disabled, now unused opcodes are executed.
@gavinandresen

Copy link
Copy Markdown
Contributor

NACK. Changing the behavior of VerifyScript in any detectable way is unacceptable, because of the risk of a blockchain fork.

@maaku

maaku commented Sep 26, 2012

Copy link
Copy Markdown
Contributor Author

This can't lead to a blockchain fork. These opcodes aren't on mainnet, and wouldn't be accepted on mainnet anyway by any existing client. They would be illegal before the change, and they would be illegal after the change. It only changes the behavior of a hypothetical client that relaxes IsStandard() script restrictions.

@jgarzik

jgarzik commented Sep 26, 2012

Copy link
Copy Markdown
Contributor

IsStandard() is not relevant to this discussion. Transactions may appear in the blockchain, even if they fail IsStandard().

The set of acceptable behaviors is much larger than the set of relay-able IsStandard() behaviors.

@maaku

maaku commented Sep 26, 2012

Copy link
Copy Markdown
Contributor Author

Ok understood.

@maaku maaku closed this Sep 26, 2012
KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Dec 5, 2020
7723a0a CI: Check scripted diffs in Travis (Fuzzbawls)
b401d55 Fix outliers not covered by the scripted diff (Fuzzbawls)
92c8273 scripted-diff: Use UniValue.pushKV instead of push_back(Pair()) (Fuzzbawls)
3d9f028 Squashed 'src/univalue/' changes from dac5296759..98261b1e7b (Fuzzbawls)

Pull request description:

  The pervious usage of `push_back(Pair())` was needed for compatibility with the old json spirit library, which we transitioned away from quite a while ago in favor of Univalue.

  Univalue provides a more convenient method for pushing key/value pairs into a JSON object or array in the form of `pushKV()`, which is easier to read and leads to shorter code segments.

  This PR first updates our univalue subtree with upstream, which has removed the now-unneeded declaration methods for `push_back(Pair())`, as well as patch a bug with `pushKV()` being supplied with a boolean instead of an integer argument.

  92c8273 handles the majority of the work to replace usages of `push_back(Pair())` with `pushKV()` with a reproducible shell command.

  b401d55 takes care of 3 instances that were not picked up in the previous commit due to multiline code

  7723a0a finally, this commit adds the scripted-diff verification linter to TravisCI for future use.

  Note: Depending on merge order, existing open PRs may "leak" new or conflicting introductions of `push_back(Pair())`

ACKs for top commit:
  random-zebra:
    rebase ut-ACK 7723a0a
  furszy:
    utACK 7723a0a

Tree-SHA512: c8e738ced0f561fc9d79f22179553e19fd9a5271e22d3d4885032098b90e08053f7030146f40fdd9a6477106561ba728093b986b09a7cd0b7aceabf305ed7ec4
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants