-
Notifications
You must be signed in to change notification settings - Fork 132
[group key addrs 5/6]: Add Pedersen unique script key type #1621
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
5687720
to
46d9159
Compare
Pull Request Test Coverage Report for Build 16075189182Details
💛 - Coveralls |
46d9159
to
e5fdf7e
Compare
Going to look into the test failures (I think the mock just needs some mutexes). |
555c711
to
6a85168
Compare
// to avoid proof collisions in the universe, where the script keys | ||
// should be spendable by a hardware wallet that only supports | ||
// miniscript policies for signing P2TR outputs. | ||
ScriptKeyDerivationUniquePedersen ScriptKeyDerivationMethod = 0 |
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.
why not use OP_RETURN
method here rather than pedersen? Are we leaving the door open for hardware wallets, is that the idea here still?
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.
Yes, mainly for the slightly easier hardware wallet support of the Pedersen construction.
authmailbox/multi_subscription.go
Outdated
// Subscribe adds a new subscription for the specified client URL and receiver | ||
// key. It starts a new mailbox client if one does not already exist for the | ||
// given URL. The subscription will receive messages that match the provided | ||
// filter and will send them to the shared message queue. | ||
func (m *MultiSubscription) Subscribe(serverURL url.URL, | ||
receiverKey keychain.KeyDescriptor, filter MessageFilter) error { |
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 this should be thread safe? I'm not sure how this might be used. But if it's going to be called from an RPC endpoint then it probably needs to be thread safe.
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.
Currently we only access this from a single Goroutine in the asset custodian. But doesn't hurt to make it thread safe, so I did that.
proof/send.go
Outdated
const ( | ||
// SendFragmentV0 is the first version of the send fragment. | ||
SendFragmentV0 SendFragmentVersion = 0 | ||
) |
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.
Might be useful to reserve 0
for "unspecified version". Useful for returning errors on version parsing.
Might also be useful to have a "latest version" var here.
|
||
# First, we replace the `$X/*SLICE:<field_name>*/` placeholders with | ||
# the actual placeholder that sqlc will use: `/*SLICE:<field_name>*/?`. | ||
sed -i.bak -E 's/\$([0-9]+)\/\*SLICE:([a-zA-Z_][a-zA-Z0-9_]*)\*\//\/\*SLICE:\2\*\/\?/g' "$file" |
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.
😵
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.
Yeah, regular expressions (combined with the required escaping needed for the shell script and sed
syntax) aren't easy to read. But I guess we can always ask Gemini to explain it to us 😝 I did provide before and after examples to hopefully make them a bit easier to understand.
asset/asset.go
Outdated
// depending on the `filterChannelRelated` parameter. Unless the user specifies | ||
// a specific script key type, in which case the returned slice will only | ||
// contain that specific script key type. | ||
func ScriptKeyTypeForDatabaseQuery(filterChannelRelated bool, |
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.
Perhaps this should instead live in the DB? As it's only used there for now, and makes some assumptions w.r.t how the types are stored in the db.
Eg: IIUC, if someone re-orders the script key types in the definition above (eg: by accident when adding a new type), queries will break.
This is generally why I lean towards making these db enum types into their own table, as then we lean on the database engine to help us enforce referential integrity.
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 moved this specifically here to be close to the different script key types. The idea is that we don't forget to add new script keys to the two lists (AllScriptKeyTypes
and ScriptKeyTypesNoChannel
).
I also felt it was weird having this business logic in the database itself.
assumptions w.r.t how the types are stored in the db
No, we don't make any assumptions, the type is a simple numeric type. Sure, the database doesn't know what possible types there are, but other than that there are no assumptions that I can think of.
IIUC, if someone re-orders the script key types in the definition above (eg: by accident when adding a new type), queries will break.
That luckily isn't the case. Because we use WHERE script_key_type IN (?, ?, ?, ...)
, the order of the enum-like values doesn't matter.
Perhaps you have the event status in mind where we still do this status >= @status_from AND status <= @status_to
in
https://github.com/lightninglabs/taproot-assets/blob/main/tapdb/sqlc/queries/addrs.sql#L170
We can turn that into a WHERE status IN (?, ?, ?, ...)
query now too to make the query order-independent.
proof/records.go
Outdated
@@ -54,6 +54,12 @@ const ( | |||
MetaRevealUniverseCommitments tlv.Type = 7 | |||
MetaRevealCanonicalUniversesType tlv.Type = 9 | |||
MetaRevealDelegationKeyType tlv.Type = 11 | |||
|
|||
SendFragmentVersionType tlv.Type = 0 |
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.
Arguably could live in the address
package, as IIUC we're not placing this information into proofs yet.
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.
Ah yes, makes sense.
6a85168
to
3e10e34
Compare
Because we'll use the address' script key as the bare/raw public key that will be tweaked for each individual output of an address v2 send, we'll need to be able to find addresses by that script key. We'll also make the script key unique for v2 addresses to avoid multiple records being returned here.
3e10e34
to
d050a45
Compare
This introduces a workaround that gets us WHERE xxx IN (...) queries working with a little trick. See the comment in scripts/gen_sqlc_docker.sh for more information on how this works and why the workaround is needed.
This MultiSubscription helper struct allows us to subscribe to receive messages for multiple keys held by a receiving wallet but all consolidated into a single message channel.
We need to place these types in the proof package because the proof courier will need access to them. And because we already use the proof package from the address package, we can't place the new types there, as that would create a circular package dependency.
d050a45
to
770baa6
Compare
I addressed all comments, should be ready for another round of review. |
More commits extracted from #1587 that contain the last (mostly) non-functional changes that can be merged independently before we're starting to change the address behavior.