[WIP] script: prevent OP_NEGATE from generating negative zero. #18236

pull v1048576 wants to merge 1 commits into bitcoin:master from v1048576:master changing 1 files +1 −6
  1. v1048576 commented at 9:53 pm on March 1, 2020: none

    Prevent OP_NEGATE from generating negative zero since negative zero is implementation defined for C/C++.

    Do you agree with negative zero issue? Does this impact CastToBool since mentions negative zero? Looking for feedback as I am unsure how to test these changes?

  2. Avoid negative zero?
    Prevent OP_NEGATE from generating negative zero.
    1ebc0f5c8b
  3. v1048576 renamed this:
    script: prevent OP_NEGATE from generating negative zero.
    [WIP] script: prevent OP_NEGATE from generating negative zero.
    on Mar 1, 2020
  4. sipa commented at 10:00 pm on March 1, 2020: member

    This is a hardfork, and cannot be made unilaterally by one client - the entire network must choose this.

    It’s also misguided. Representation and existance of negative zero is indeed implementation defined for C++ int types, but also not observable and not what this is about. Bitcoin Script’s numeric interpration of byte vectors does have a well-defined and observable negative zero. We cannot get rid of it without enormous effort.

  5. v1048576 commented at 10:06 pm on March 1, 2020: none

    This is a hardfork, and cannot be made unilaterally by one client - the entire network must choose this.

    It’s also misguided. Representation and existance of negative zero is indeed implementation defined for C++ int types, but also not observable and not what this is about. Bitcoin Script’s numeric interpration of byte vectors does have a well-defined and observable negative zero. We cannot get rid of it without enormous effort.

    Thanks for the fast reply, definitely more complex than I realized. Can you recommend where to learn about Script negative zero behavior for byte vectors? Or do you have an example?

  6. DrahtBot added the label Consensus on Mar 1, 2020
  7. v1048576 closed this on Mar 1, 2020

  8. sipa commented at 10:31 pm on March 1, 2020: member
    To be clear: it’s the CastToBool change that’s a hardfork. The script 0x0180 goes from being unspendable to spendable (it pushes a negative zero onto the stack). The change in OP_NEGATE is a no-op, as the arithmetic operations there operate on the converted-to-numbers representation, in which zero and negative zero are equal.
  9. DrahtBot locked this on Feb 15, 2022


v1048576 sipa

Labels
Consensus


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-26 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me