forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 7
TAPSCRIPT_V2 (Great Script Restoration) #104
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
Open
jmoik
wants to merge
68
commits into
bitcoin-inquisition:29.x
Choose a base branch
from
jmoik:inquisitionGsr
base: 29.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+12,010
−216
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not a generic 64-bit access wrapper, but a very bitcoin-specific
one.
TODO: This was developed in pieces, and I should deconstruct it into separate
commits, with tests, for easy review.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…nally tracks element size counts for efficient calculation of total stack size and maximum element size. This avoids the need to iterate through all elements during script execution.
…ine endian fixers, adjust varop costs
…rt, extend enum class SigVersion by TAPSCRIPT_V2 and move it from interpreter.h to script.h
…t() and add tapscript_v2 witness script execution
…teWitnessScript()
…le restored opcodes in tapscript_v2
…stack() pushVal64() and stackPushCosted() helper functions
… this overload is used with SigVersion::TAPSCRIPT_V2 (to verify that the function bodies are identical run ./test/lint/verify-evalscript-copy.sh <commit_hash>)
…pscript_v2 EvalScript to make it compatible with the following GSR changes
…ad, since it always uses tapscript_v2
… const qualifiers to stacktop() values, since ValtypeStack does not support getters for mutable references
…criptNum (non-arithmetic opcodes). The following non-arithmetic opcodes interpret numbers on the stack as CScriptNum: 1. OP_CHECKLOCKTIMEVERIFY. 2. OP_CHECKSEQUENCEVERIFY. 3. OP_VERIFY. 4. OP_ROLL. 5. OP_CHECKSIGADD. In the first two cases, all numbers > 2^32-1 are equivalent, and we can easily represent them as CScriptNum (which is an int64_t internally). OP_VERIFY uses CastToBool which unfortunately treats "negative zero" as false. OP_ROLL is invalid if the value is greater or equal to the stack depth, so we can cap value conversion at that. OP_CHECKSIGADD doesn't really care about the number, it just adds 1 and puts it back.
…TSTACK, OP_FROMALTSTACK, OP_DUP, OP_2DUP, OP_3DUP, OP_2OVER, OP_OVER, OP_TUCK, OP_IFDUP
…riptNum for OP_DEPTH and OP_SIZE
…DD, OP_1SUB, OP_NOT, OP_0NOTEQUAL; OP_NEGATE and OP_ABS are OP_SUCCESS in tapscript v2
…D, OP_SUB, OP_BOOLAND, OP_NUMNOTEQUAL, OP_LESSTHAN, OP_GREATERTHAN, OP_LESSTHANOREQUAL, OP_GREATERTHANOREQUAL, OP_MIN, OP_MAX
New bench_bitcoin tests: - evalscript: similar to bench_varops - micro: low-level memcmp/memset/memcpy benchmark variants - val64: Val64 class benchmarks to try to tweak out worst case.
…d gsr_tests to execute the test vectors, add valtype_stack_tests
…anipulation opcode tests
* OP_CAT * OP_SUBSTR * OP_LEFT * OP_RIGHT * OP_INVERT * OP_2MUL * OP_2DIV * OP_AND * OP_OR * OP_XOR * OP_MUL * OP_DIV * OP_MOD * OP_LSHIFT * OP_RSHIFT
…Script() to EvalGsrScript()
Collaborator
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements the following two BIPs:
Varops Budget
Great Script Restoration
Summary of Changes:
Added new SigVersion::TAPSCRIPT_V2 with leaf version 0xc2
Restored 15 disabled opcodes: OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT, OP_INVERT, OP_2MUL, OP_2DIV, OP_AND, OP_OR, OP_XOR, OP_MUL, OP_DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT
Generalized the sigops budget by introducing the varops budget system for tracking computational costs
OP_NEGATE, OP_ABS, and OP_1NEGATE became OP_SUCCESS in tapscript v2
Added variabel size unsigned integer class Val64 for arithmetic operations
Added ValtypeStack class for efficient stack size tracking without iteration
Numbers are interpreted as varnums instead of CScriptNum in tapscript v2
Final on-stack value is interpreted as unsigned in tapscript v2
Tests & Benchmarks: