-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BIP draft: 64-bit arithmetic opcodes #1538
base: master
Are you sure you want to change the base?
Conversation
Why not push the overflow amount and the result back on the stack? Rather than This would simply doing 256-bit math from 64-bit stack elements and I don't see any downsides for 64-bit operations. |
Sorry I don't understand this. Could you maybe give a more concrete example, perhaps on delvingbitcoin? We have a thread going here: https://delvingbitcoin.org/t/64-bit-arithmetic-soft-fork/397/25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a light first pass. I noticed that this document may be missing a Rationale Section that describes design decisions, alternate approaches, and related work, and a Backwards Compatibility section.
You may want to add the "Post-History" header to the preamble to link to discussions of this proposal on the mailing list or forums.
Title: 64 bit arithmetic operations | ||
Author: Chris Stewart <[email protected]> | ||
Comments-Summary: No comments yet. | ||
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0364 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refrain from issuing your own BIP numbers.
<pre> | ||
BIP: TBD | ||
Layer: Consensus (soft fork) | ||
Title: 64 bit arithmetic operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
Title: 64 bit arithmetic operations | |
Title: 64-bit arithmetic operations |
Hey @Christewart, are you still working on this? |
Yep i'm going to give it another go. I'll update soon. |
… existing airthmetic opcodes
|
||
This BIP re-enables two opcodes: OP_MUL and OP_DIV. | ||
|
||
This BIP also expands supported precision for valid operands from `-2^31 +1` to `2^31 -1` to `-2^63 +1...2^63 -1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make sure I understand, this isn't proposing new opcodes that handle 64-bit arithmetic is it redefining the existing opcodes. Is that correct? It's probably on your TODO list, but what is the mechanism you are using to make this a softfork? Script versioning?
In the future we may wish to increase the supported precision again. What about adding a precision commitment to make soft-forking precision upgrades easier? For instance OP_PUSH x, OP_PRECIS
, if x >64 then P_PUSH x OP_PRECIS
is an OP_SUCCESSx. Then if we soft precision to 128 bits, OP_PUSH x, OP_PRECIS
becomes a NOP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ethan thanks for your continued interest in this topic.
I want to make sure I understand, this isn't proposing new opcodes that handle 64-bit arithmetic is it redefining the existing opcodes. Is that correct?
👍
It's probably on your TODO list, but what is the mechanism you are using to make this a softfork? Script versioning?
My latest thinking for the upgrade mechanism is allocating a new tap leaf version to indicate the precision of arithmetic operations for Script. This was suggested by @sipa here. You can read about how this works on delving bitcoin and see my implementation of it here inside the bitcoin c++ code base.
I personally think this makes Scripts easier to reason about as the leaf version indicates the precision of all numeric operations during this Script's execution. If we want to increase precision again in the future, we can allocate a new leaf version and extend the underlying precision of CScriptNum and expose that functionality as I've done here
In the future we may wish to increase the supported precision again. What about adding a precision commitment to make soft-forking precision upgrades easier?
Committing to arbitrary precision seems hard, but i think this BIP lays the groundwork for extending precision in the future by making the precision of arithmetic operations linked with new tapleaf versions.
I pushed to this branch staged changes in a haphazard state, apologies. I'm working on a BIP currently to disallow 64 byte transactions in the bitcoin blockchain as I think that is more likely to be widely accepted by the community, and then will be coming back to this work.
Hi @Christewart, it’s my understanding that this document is currently not ready for BIP Editor review, so I have labeled the pull request as Draft. Please let us know when you would like us to take a look by returning it to "Ready for Review" when it has been updated. |
semantics and detailed rationale for those semantics. | ||
|
||
<source lang="cpp"> | ||
class CScriptNum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big thumbs down at the idea of just pasting a blob of C++ code vs actually specifying the semantics of the new op codes.
This BIP describes a soft fork to add 64-bit arithmetic op codes to bitcoin
Implementation: bitcoin/bitcoin#29221