Skip to content
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

multi: support non-interactive collectible sends #176

Merged
merged 8 commits into from
Nov 9, 2022
Merged

Conversation

jharveyb
Copy link
Collaborator

@jharveyb jharveyb commented Oct 20, 2022

Depends on #159, addresses #99 and #121.

Adds support for non-interactive sends of collectibles by allowing splits bearing collectibles, iff they have an unspendable root and exactly one non-root locator.

Fixes #99
Fixes #121

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set of changes looks pretty minimal which is great, will attempt to dig into the test failure when an asset w/ emission enabled is used to send. Might be some edge case in key family handling in the db, or just the coin selection portion itself.

t, genesisCollectible,
familyKeyCollectible,
)
root := &SplitLocator{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -151,6 +150,18 @@ func NewSplitCommitment(input *asset.Asset, outPoint wire.OutPoint,
return nil, ErrInvalidSplitLocator
}

// To transfer a collectible with a split, the split root must be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

case vm.newAsset.Type != asset.Normal ||
vm.splitAsset.Type != asset.Normal:

case vm.newAsset.Type != vm.splitAsset.Type:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how compact all these changes are, gotta love when a plan nicely falls into place 🤓*

* hidden bugs may apply

// need a split at all. In this case, we fully consume an input asset,
// so the asset created is the same asset w/ the new script key in
// place.
case SendStatePreparedComplete:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the enum value definition above as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like SendStatePreparedComplete still exists in parcel.go.

itest/collectible_split_test.go Show resolved Hide resolved
err error
)

for i := 0; i < numSends; i++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can somewhat easily (factoring in the optional key family param) abstract this section into a sort of pingPongAsset helper func.

@Roasbeef
Copy link
Member

Confirmed, that the test works when using a collectible that doesn't support emission.

Running the normal test I run into:


panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1023cd454]

goroutine 1339 [running]:
github.com/lightninglabs/taro/mssmt.(*BranchNode).NodeHash(0x0?)
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/mssmt/node.go:210 +0x24
github.com/lightninglabs/taro/commitment.(*TaroCommitment).TapLeaf(0x140011f1228)
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/commitment/taro.go:156 +0x30
github.com/lightninglabs/taro/commitment.(*TaroCommitment).TapscriptRoot(0x7f17870c4797d810?, 0x0)
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/commitment/taro.go:181 +0x2c
github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).stateStep(0x140005bbf80, {0x9, {{0xdb, 0x3}, 0x14000634000}, {0x14000048780, 0x104012a80}, {{{0xa7, 0x74, 0x1, ...}, ...}, ...}, ...})
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/tarofreighter/chain_porter.go:884 +0x1914
github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).advanceStateUntil(0x140005bbf80, 0x140010f3ec8, 0xa)
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/tarofreighter/chain_porter.go:493 +0x12c
github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).taroPorter(0x140005bbf80)
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/tarofreighter/chain_porter.go:226 +0x278
created by github.com/lightninglabs/taro/tarofreighter.(*ChainPorter).Start.func1
	/Users/roasbeef/gocode/src/github.com/lightninglabs/taro/tarofreighter/chain_porter.go:131 +0x284

@jharveyb jharveyb marked this pull request as ready for review November 4, 2022 21:37
@lightninglabs-deploy
Copy link

@Roasbeef: review reminder

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💈

Final comment is that I think we can safely drop forcing the family key to be even/odd given that we'll now always serialize the full version.

asset/asset.go Outdated
return tweakedPrivKey.PubKey(), sig, nil
// Since we'll never query lnd for a tweaked key, it doesn't matter if
// we lose the parity information here.
tweakedPubKey, _ := schnorr.ParsePubKey(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this anymore after #187 ?

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💈

Final comment is that I think we can safely drop forcing the family key to be even/odd given that we'll now always serialize the full version.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💈

Final comment is that I think we can safely drop forcing the family key to be even/odd given that we'll now always serialize the full version.

Since all spends now use splits, input validation should check for
full-value sends, to determine if the split must use a zero-value root.
Simplify the conditions for using an unspendable script key to match the
updates to input validation.
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice and clean, LGTM 🎉

@@ -362,6 +362,56 @@ func splitFullValueStateTransition(t *testing.T, validRootLocator,
}
}

func splitCollectibleStateTransition(t *testing.T,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the outer t isn't needed. But I see that it's there in the other test generator functions too, so non blocking.

// need a split at all. In this case, we fully consume an input asset,
// so the asset created is the same asset w/ the new script key in
// place.
case SendStatePreparedComplete:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like SendStatePreparedComplete still exists in parcel.go.

@@ -600,6 +600,16 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
// to complete the send w/o merging inputs.
assetInput := elgigibleCommitments[0]

// If the key found for the input UTXO is not from the Taro
// keyfamily, something has gone wrong with the DB.
if assetInput.InternalKey.Family != tarogarden.TaroKeyFamily {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we run into this somewhere? Or what's the reason for this specific check? Mostly just curious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think was added during the debugging phase as a sort of sanity check to help track down the bug.

@Roasbeef Roasbeef merged commit 77b6919 into main Nov 9, 2022
@guggero guggero deleted the splits-collectibles branch November 9, 2022 19:30
@jharveyb jharveyb mentioned this pull request Nov 30, 2022
7 tasks
@guggero guggero mentioned this pull request Aug 11, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
4 participants