-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Glock transaction graph (2) #298
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: main
Are you sure you want to change the base?
Conversation
ed566d2 to
5fe9111
Compare
Rajil1213
left a comment
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.
Amazing work -- especially with generalizing the connectors and creating "one-test-to-rule-them-all". It does come at the cost of a more convoluted test design but I think the tradeoffs are acceptable. I also like the new TaprootWitness type and I'm okay removing the older type once the old tx-graph crate has been replaced.
Most of my review comments are about some non-obvious/new things and some general housekeeping stuff.
| .push_opcode(opcodes::all::OP_SIZE) | ||
| .push_int(0x20) |
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.
Could you add a note in the constructor that the preimage must be a 32-byte value? At the same time, I don't really see the value in enforcing this since the spec does not specify the size of the preimage.
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 looked at the stake chain implementation and it used 32-byte preimages. I think it's good to consistently use 32 bytes.
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.
We don't have the hashlocked (stake) chain anymore so there is nothing to be consistent with. To be clear, I don't mind having this in. However, this should not be abstracted away in the implementation -- it should be documented.
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.
It's documented now in the constructor. Should we update the spec?
Rajil1213
left a comment
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 did a second pass of this PR, specifically the OP_CODESEPARATOR stuff and the test. I think we can make the spending transaction in the test more like what we expect to see in the final transaction graph. For the CPFP connector, it'd be useful to have a separate test that actually demonstrates the CPFP behavior. A test like this already exists in the older CPFP connector module which you might want to borrow.
All connector outputs implement this trait. Most of the taproot internals are automatically implemented. The TaprootWitness struct represents a generic Taproot witness. I realize that this clashes with the TaprootWitness from primitives/scripts/taproot.rs. I feel the latter is ill-named or should be removed, since the "witness" doesn't contain any signature data. I plan to make a follow-up PR that revises the struct and that updates the affected Musig2 signing machinery. Let's discuss this.
This commit moves the connector testing code to test_utils.rs. The code is generic, using the new Signer trait.
Stop using old connectors crate as a dependency.
It turns out that half of the Glock connectors follow the same pattern: - some internal key - a single tap leaf: N/N + some timelock
This commit extends the connector testing functionality to support leaf scripts that contain OP_CODESEPARATOR.
Because this output is only spent in one place of the transaction graph, it is strictly speaking not a connector. However, it is convenient to implement the Connector trait regardless.
5fe9111 to
aeda373
Compare
|
Rebased onto |
Rajil1213
left a comment
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.
Did another pass of this PR after the recent changes.
These methods will be useful to make signartures for testing and for production. Splitting the normal method from the code separator one keeps the code simple. In the following commit, I will refactor the testing infrastructure of connectors.
This struct makes it easy to play transactions on Bitcoin Core. The RPC calls are abstracted away, to reduce code duplication. The coinbase outpoints are an easy way to fund transactions. The wallet automatically signs its inputs. This commit temporarily disables the code separator and cpfp tests. I will refactor these tests in the following commits.
Instead of using assert_connector_is_spendable, we use custom code to test the connector. Separately handling code separators keeps the code simple.
|
I refactored the testing infrastructure. It should be much simpler and more useful now. Connectors have a method to compute the sighash of their transaction input. Code separators are handled separately from the rest of the code. |
This PR implements and tests all (connector) outputs that are used in the Glock transaction graph.
I have used AI for autocompletion.
Type of Change
Notes to Reviewers
The
ConnectorandSignertraits turned out very useful for implementing and testing transaction outputs. WhileConnectoris made for Taproot outputs, I was able to implementCpfpConnectorwhich uses a custom script pubkey. I also implementedContestCounterproofOutput, which is not a connector but just a normal output. We may want to renameConnectorto justOutputor something like that.Checklist
Related Issues
Depends on #296