-
Notifications
You must be signed in to change notification settings - Fork 95
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
custom channels: add more itest coverage, fix pending channel bug #797
Conversation
20d8091
to
36513aa
Compare
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.
LGTM
This PR bumps the version of tapd to fix the bug of panicking when an HTLC that pays the full balance to the recipient of a channel is being created. We assert this no longer is a problem and we also assert that the final balance when co-op closing in that state (where the initiator has zero balance) is correct.
It turns out the custom message override that should've allowed tapd to send custom p2p wire messages never worked, because we set the value after calling into lnd.ValidateConfig() which actually injects the value into the lnwire package. We now move the code and also create an itest for it (we should be able to try funding multiple times after each other, as each attempt should be cleaned up by the receiver when they receive the error message).
36513aa
to
fb6949d
Compare
Updated |
@@ -916,10 +917,19 @@ func waitForSendEvent(t *testing.T, | |||
} | |||
} | |||
|
|||
// coOpCloseBalanceCheck is a function type that can be passed into | |||
// closeAssetChannelAndAsset to asset the final balance of the closing |
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.
asset
-> assert
type coOpCloseBalanceCheck func(t *testing.T, local, remote *HarnessNode, | ||
closeTx *wire.MsgTx, closeUpdate *lnrpc.ChannelCloseUpdate, | ||
assetID, groupKey []byte, universeTap *tapClient) |
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 might be a good idea to put all of these arguments in a single struct. Or the option pattern. There are already many arguments so a struct could help organise them. And it would minimise the diff if adding another argument in the future.
t.Fatalf("close output (targetPkScript=%x) not found in close "+ | ||
"transaction", targetPkScript) | ||
|
||
return &wire.TxOut{}, 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.
return nil, 0
?
@@ -1160,6 +1161,36 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness, | |||
syncUniverses(t.t, charlieTap, dave) | |||
t.Logf("Universes synced between all nodes, distributing assets...") | |||
|
|||
// Before we actually create the asset channel, we want to make sure | |||
// that failed attempts of creating a channel (e.g. due to insufficient |
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.
of
-> at
I just tested fb6949d and I ran into the missing proof issue again. I tried twice. I'm not sure why this is still happening. I tested lightninglabs/taproot-assets#1033 yesterday and this issue went away. This log line confirms the nodes are running the latest commit here (
Here's the CLI Output Expand to view contentitd@alice:/$ tapcli assets mint --name PBUX --type normal --supply 1000
{
"pending_batch": {
"batch_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"batch_txid": "",
"state": "BATCH_STATE_PENDING",
"assets": [
{
"asset_version": "ASSET_VERSION_V0",
"asset_type": "NORMAL",
"name": "PBUX",
"asset_meta": null,
"amount": "1000",
"new_grouped_asset": false,
"group_key": "",
"group_anchor": "",
"group_internal_key": null,
"group_tapscript_root": "",
"script_key": {
"pub_key": "b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"key_desc": {
"raw_key_bytes": "0379b16e2ad2fbd65f8b6f5a1346c665eaece6036a828a191de5c10d363e6887c7",
"key_loc": {
"key_family": 212,
"key_index": 0
}
},
"tap_tweak": ""
}
}
],
"created_at": "1721398472",
"height_hint": 107,
"batch_psbt": ""
}
}
litd@alice:/$ tapcli assets mint finalize
{
"batch": {
"batch_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"batch_txid": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9",
"state": "BATCH_STATE_BROADCAST",
"assets": [
{
"asset_version": "ASSET_VERSION_V0",
"asset_type": "NORMAL",
"name": "PBUX",
"asset_meta": null,
"amount": "1000",
"new_grouped_asset": false,
"group_key": "",
"group_anchor": "",
"group_internal_key": null,
"group_tapscript_root": "",
"script_key": {
"pub_key": "b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"key_desc": {
"raw_key_bytes": "0379b16e2ad2fbd65f8b6f5a1346c665eaece6036a828a191de5c10d363e6887c7",
"key_loc": {
"key_family": 212,
"key_index": 0
}
},
"tap_tweak": ""
}
}
],
"created_at": "1721398472",
"height_hint": 107,
"batch_psbt": "70736274ff0100890200000001552b430531274a82b64e88e326ada8217ef2a2543975f79b7ec4d1422ab2c5de00000000000000000002e8030000000000002251202e0f65e61116aceae794041a5228ad4e8d064db6bf790a29b6636f63795a51093b9f000000000000225120b1ddb2f35fee646446483efbea28b1516a415ab7bcc77a8c469d59f6d25da31200000000000100de02000000000101cc4980f7d04b0a829aca4fd8996cfbcf4bc61e921fc6afe8f76e6e198e862c2e0000000000fdffffff0250c3000000000000160014e13343e88e7044b75652f44be5f84dcbe417320eac23052a010000001600148f830a4caa235c5de18474ce4f9b97823e3dc9cd0247304402200d056f8798e126c54d26bc6300f8ca199f2209ed3e03b8126f4ac20871bd3d6d02207662360a06e90b413215eba68d84a7376beacc1aa4e9f09ad7c835f8725cd671012102881d682f36d2aca02ab4244ba11899495b477c656d180983f5f9fc2be85a9ee66500000001011f50c3000000000000160014e13343e88e7044b75652f44be5f84dcbe417320e01086c02483045022100a679dc9726c65647cc018bddc5aa7d729720044ed96750438670801da1877b130220016adcf366d203f7a2e266cbba9abd2a94982b6b8e791b7acd4d022b257f8b4d01210211befc177cb98cbd73a025dfc25a151f9ff78e54633ee22799344e71eee3325d0000220203cb0d5cf0d6370a49ddd84b533dc5e86a9a836e3d26cd298d3f6476794892cd0818000000005600008000000080000000800100000000000000010520cb0d5cf0d6370a49ddd84b533dc5e86a9a836e3d26cd298d3f6476794892cd082107cb0d5cf0d6370a49ddd84b533dc5e86a9a836e3d26cd298d3f6476794892cd08190000000000560000800000008000000080010000000000000000"
}
}
litd@alice:/$ tapcli assets list
{
"assets": [
{
"version": "ASSET_VERSION_V0",
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"amount": "1000",
"lock_time": 0,
"relative_lock_time": 0,
"script_version": 0,
"script_key": "02b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"script_key_is_local": true,
"asset_group": null,
"chain_anchor": {
"anchor_tx": "02000000000101552b430531274a82b64e88e326ada8217ef2a2543975f79b7ec4d1422ab2c5de00000000000000000002e8030000000000002251202e0f65e61116aceae794041a5228ad4e8d064db6bf790a29b6636f63795a51093b9f000000000000225120b1ddb2f35fee646446483efbea28b1516a415ab7bcc77a8c469d59f6d25da31202483045022100a679dc9726c65647cc018bddc5aa7d729720044ed96750438670801da1877b130220016adcf366d203f7a2e266cbba9abd2a94982b6b8e791b7acd4d022b257f8b4d01210211befc177cb98cbd73a025dfc25a151f9ff78e54633ee22799344e71eee3325d00000000",
"anchor_block_hash": "28b4591c8e516729c92463f36abfb69c211b091fbaef5373e84ac093327481a9",
"anchor_outpoint": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"tapscript_sibling": "",
"block_height": 108
},
"prev_witnesses": [],
"is_spent": false,
"lease_owner": "",
"lease_expiry": "0",
"is_burn": false,
"script_key_declared_known": false,
"script_key_has_script_path": false,
"decimal_display": {
"decimal_display": 0
}
}
],
"unconfirmed_transfers": "0",
"unconfirmed_mints": "0"
}
litd@alice:/$ tapcli assets balance
{
"asset_balances": {
"f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac": {
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"balance": "1000"
}
},
"asset_group_balances": {}
}
litd@alice:/$ tapcli assets utxos
{
"managed_utxos": {
"c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0": {
"out_point": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"amt_sat": "1000",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"taproot_asset_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"assets": [
{
"version": "ASSET_VERSION_V0",
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"amount": "1000",
"lock_time": 0,
"relative_lock_time": 0,
"script_version": 0,
"script_key": "02b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"script_key_is_local": true,
"asset_group": null,
"chain_anchor": {
"anchor_tx": "02000000000101552b430531274a82b64e88e326ada8217ef2a2543975f79b7ec4d1422ab2c5de00000000000000000002e8030000000000002251202e0f65e61116aceae794041a5228ad4e8d064db6bf790a29b6636f63795a51093b9f000000000000225120b1ddb2f35fee646446483efbea28b1516a415ab7bcc77a8c469d59f6d25da31202483045022100a679dc9726c65647cc018bddc5aa7d729720044ed96750438670801da1877b130220016adcf366d203f7a2e266cbba9abd2a94982b6b8e791b7acd4d022b257f8b4d01210211befc177cb98cbd73a025dfc25a151f9ff78e54633ee22799344e71eee3325d00000000",
"anchor_block_hash": "28b4591c8e516729c92463f36abfb69c211b091fbaef5373e84ac093327481a9",
"anchor_outpoint": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"tapscript_sibling": "",
"block_height": 108
},
"prev_witnesses": [],
"is_spent": false,
"lease_owner": "",
"lease_expiry": "0",
"is_burn": false,
"script_key_declared_known": false,
"script_key_has_script_path": false,
"decimal_display": {
"decimal_display": 0
}
}
]
}
}
}
litd@alice:/$ litcli --macaroonpath ~/.lnd/data/chain/bitcoin/regtest/admin.macaroon ln fundchannel --asset_id f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac --node_key 035c68a5d88959150bb79c8904cc246a21d77a48f2b024a24996374e08ef04851f --sat_per_vbyte 10 --asset_amount 400
[litcli] error funding channel: rpc error: code = Unknown desc = error funding channel: didn't receive funding ack after 30s
litd@alice:/$ tapcli assets list
{
"assets": [
{
"version": "ASSET_VERSION_V0",
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"amount": "1000",
"lock_time": 0,
"relative_lock_time": 0,
"script_version": 0,
"script_key": "02b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"script_key_is_local": true,
"asset_group": null,
"chain_anchor": {
"anchor_tx": "02000000000101552b430531274a82b64e88e326ada8217ef2a2543975f79b7ec4d1422ab2c5de00000000000000000002e8030000000000002251202e0f65e61116aceae794041a5228ad4e8d064db6bf790a29b6636f63795a51093b9f000000000000225120b1ddb2f35fee646446483efbea28b1516a415ab7bcc77a8c469d59f6d25da31202483045022100a679dc9726c65647cc018bddc5aa7d729720044ed96750438670801da1877b130220016adcf366d203f7a2e266cbba9abd2a94982b6b8e791b7acd4d022b257f8b4d01210211befc177cb98cbd73a025dfc25a151f9ff78e54633ee22799344e71eee3325d00000000",
"anchor_block_hash": "28b4591c8e516729c92463f36abfb69c211b091fbaef5373e84ac093327481a9",
"anchor_outpoint": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"tapscript_sibling": "",
"block_height": 108
},
"prev_witnesses": [],
"is_spent": false,
"lease_owner": "",
"lease_expiry": "0",
"is_burn": false,
"script_key_declared_known": false,
"script_key_has_script_path": false,
"decimal_display": {
"decimal_display": 0
}
}
],
"unconfirmed_transfers": "0",
"unconfirmed_mints": "0"
}
litd@alice:/$ tapcli assets balance
{
"asset_balances": {
"f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac": {
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"balance": "1000"
}
},
"asset_group_balances": {}
}
litd@alice:/$ tapcli assets utxos
{
"managed_utxos": {
"c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0": {
"out_point": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"amt_sat": "1000",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"taproot_asset_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"assets": [
{
"version": "ASSET_VERSION_V0",
"asset_genesis": {
"genesis_point": "dec5b22a42d1c47e9bf7753954a2f27e21a8ad26e3884eb6824a273105432b55:0",
"name": "PBUX",
"meta_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"asset_id": "f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac",
"asset_type": "NORMAL",
"output_index": 0
},
"amount": "1000",
"lock_time": 0,
"relative_lock_time": 0,
"script_version": 0,
"script_key": "02b7504a305f4dc91b88e612c1f051d79ef85332c277185c47af7b5d516fc209c6",
"script_key_is_local": true,
"asset_group": null,
"chain_anchor": {
"anchor_tx": "02000000000101552b430531274a82b64e88e326ada8217ef2a2543975f79b7ec4d1422ab2c5de00000000000000000002e8030000000000002251202e0f65e61116aceae794041a5228ad4e8d064db6bf790a29b6636f63795a51093b9f000000000000225120b1ddb2f35fee646446483efbea28b1516a415ab7bcc77a8c469d59f6d25da31202483045022100a679dc9726c65647cc018bddc5aa7d729720044ed96750438670801da1877b130220016adcf366d203f7a2e266cbba9abd2a94982b6b8e791b7acd4d022b257f8b4d01210211befc177cb98cbd73a025dfc25a151f9ff78e54633ee22799344e71eee3325d00000000",
"anchor_block_hash": "28b4591c8e516729c92463f36abfb69c211b091fbaef5373e84ac093327481a9",
"anchor_outpoint": "c2a6e92c618d708acbcfea9ca91cb8d0410c876952c2a9fc83ef2ff14f05cdc9:0",
"internal_key": "0262650b2257c17f0b579764dfb848e1262dcee618d0944038e7fa7bf584c1657e",
"merkle_root": "a5b4d0fbd3bd19747a9ae46a36e33d39328f46e84f72aaa923a6bb69b880620a",
"tapscript_sibling": "",
"block_height": 108
},
"prev_witnesses": [],
"is_spent": false,
"lease_owner": "",
"lease_expiry": "0",
"is_burn": false,
"script_key_declared_known": false,
"script_key_has_script_path": false,
"decimal_display": {
"decimal_display": 0
}
}
]
}
}
}
litd@alice:/$ litcli --macaroonpath ~/.lnd/data/chain/bitcoin/regtest/admin.macaroon ln fundchannel --asset_id f424abdc608173114b59e8a1b3b5f10d9cbf5b70066e9f96e75fd99e8def5dac --node_key 035c68a5d88959150bb79c8904cc246a21d77a48f2b024a24996374e08ef04851f --sat_per_vbyte 10 --asset_amount 400
[litcli] error funding channel: rpc error: code = Unknown desc = error funding channel: didn't receive funding ack after 30s And here are the logs and datadirs for both nodes. |
Ah.. I see what I screwed up yesterday. I didn't actually test lightninglabs/taproot-assets#1033. Building the docker image used the cache which resulted in me running the |
After chatting with @Roasbeef and @guggero offline, I have retested the pending channels scenario using this PR and ensuring the asset is synced to the receiving node prior to funding the channel. The flow now works as expected without having any lingering pending channels or locked assets after the first failed attempt. This is the flow I tested:
Thanks for all of the assists guys 💪 |
Adds another test case where we co-op close an asset channel when the full balance is on the non-initiator/recipient's side of a channel and assert the final balances are distributed correctly.
This also fixes lightninglabs/taproot-assets#1019, by addressing the last of the 3 reported issues (pending channel staying forever).