-
Notifications
You must be signed in to change notification settings - Fork 6
OP_CHECKCONTRACTVERIFY #102
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
base: 29.x
Are you sure you want to change the base?
Conversation
Adds a framework for validation checks that persist an individual input's script validation, allowing to persist state across the evaluations of multiple inputs of a transaction. This will be used for the amount logic of OP_CHECKCONTRACTVERIFY, that performs amount checks that are aggregate across multiple inputs. It could also be used for other applications, like batch validation and cross-input Schnorr signature aggregation.
|
This is currently failing the I assume I must be doing something wrong in the activation logic - any advice would be greatly appreciated. |
|
Hey @bigspider , glad to see this show up here! Hopefully I can be a little helpful
I didn't look at this super closely, but taking your word for it, if the Script that is failing is
That means nothing ends up on the stack, which is equivalent to the empty byte vector and thus a Script failure correct? Previously [ I believe you would want to make the
I'm still interested in this subject and will come back later and take a look at this. This is an interesting design space imo |
Yes, the test is just checking the expected Summoning @ajtowns if you kindly have time to check. |
|
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. |
This is a port of the previous PR for OP_CHECKCONTRACTVERIFY in core, matching the specifications in BIP-443.
Implementation with mutex
There are several ways the opcode's cross-input logic could be implemented, some without changing the semantics and some that make functionality tradeoffs to simplify the implementation. In this PR, I chose to use the keep the most direct implementation that uses a mutex for the synchronization of the cross-input logic, like in the linked bitcoin-core PR. The analysis of the various options will certainly deserve more careful consideration for an implementation in bitcoin-core, as cross-input Script evaluation logic is currently a new concept in the Script interpreter (although implicitly introduced in taproot, if Schnorr batch validation is implemented)
Sigops budget (draft)
Apart from rebasing and some minor style changes in the code, this PR adds a simple benchmark to compare with Schnorr signature checks, and a rough sigops budget pricing (which is still left as a TODO in the BIP). This will also need deserve more care in view of the fact that overpricing might cause some reasonable use cases to run out of sigops budget (forcing to stuff the witness just for the sake of gaining some more budget). I am currently not aware of such situations, but I hope that having the opcode available in signet might help with discovery. Underpricing it, of course, would cause the usual DoS concerns.
In this PR, CCV is priced as a signature check in the heaviest case with two tweaks, half if one tweak is skipped, and 0 otherwise.