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

Reintroduce support for legacy collaborative revert of LN-DLC channels #1893

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

luckysori
Copy link
Contributor

@luckysori luckysori commented Jan 25, 2024

This can be removed once all LN-DLC channels in production have been closed.


I can't easily add an e2e test for this because some of the code to even establish an LN-DLC channel was already removed. So I ran manual tests instead.

Collab revert with app still on version 1.7.4

  1. Build app and coordinator on version 1.7.4.
  2. Start environment and open channel and position with app.
  3. Shut down coordinator.
  4. Re-start coordinator on this branch.
  5. Trigger collab revert.
curl -X POST localhost:8000/api/admin/channels/legacy-revert -d '{"channel_id":"9d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc797", "txid": "96c7accabe03043e868623765e03c97ef2a5aa4a30a17371cfe95d4695248b9d", "vout": 1, "coordinator_amount": 110000, "fee_rate_sats_vb": 5, "price":"40000"}' -H "Content-Type: application/json"
  1. Verify logs and values.
  • Coordinator logs:

    2024-01-25 03:48:09  INFO legacy_collaborative_revert: coordinator::collaborative_revert: Proposing legacy collaborative revert channel_id="9d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc797" coordinator_address=bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj coordinator_amount=109580 trader_amount=89580
    2024-01-25 03:48:09  INFO legacy_collaborative_revert: coordinator::admin: Proposed legacy collaborative revert channel_id="9d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc797"
    2024-01-25 03:48:09  INFO coordinator::message: Sending trader message trader_id=03baea6c556195d2dcf27a2a228aeaaa1fafd2ee47a740a5bb314aeda2c7675918 CollaborativeRevert { channel_id: [157, 139, 36, 149, 70, 93, 233, 207, 113, 115, 161, 48, 74, 170, 165, 242, 126, 201, 3, 94, 118, 35, 134, 134, 62, 4, 3, 190, 202, 172, 199, 151], coordinator_address: bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj, coordinator_amount: Amount(0.00109580 BTC), trader_amount: Amount(0.00089580 BTC), execution_price: 40000, funding_txo: OutPoint { txid: 96c7accabe03043e868623765e03c97ef2a5aa4a30a17371cfe95d4695248b9d, vout: 1 } }
    2024-01-25 03:48:09  INFO legacy_collaborative_revert_confirm: coordinator::routes: Confirming legacy collaborative revert channel_id="9d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc797"
    2024-01-25 03:48:09  INFO legacy_collaborative_revert_confirm: coordinator::collaborative_revert: Confirming legacy collaborative revert legacy_collaborative_revert_record=LegacyCollaborativeRevert { channel_id: ChannelId([157, 139, 36, 149, 70, 93, 233, 207, 113, 115, 161, 48, 74, 170, 165, 242, 126, 201, 3, 94, 118, 35, 134, 134, 62, 4, 3, 190, 202, 172, 199, 151]), trader_pubkey: PublicKey(185967c7a2ed4a31bba540a747eed2af1faaea8a222a7af2dcd29561556ceaba8b8a61fac19d8103f6a69fcf047bc3c4ea47eeacfcc7563490ddd202a8af90f6), price: 40000.0, coordinator_address: bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj, coordinator_amount_sats: Amount(0.00109580 BTC), trader_amount_sats: Amount(0.00089580 BTC), timestamp: 2024-01-25 3:37:24.095999 +00:00:00, txid: 96c7accabe03043e868623765e03c97ef2a5aa4a30a17371cfe95d4695248b9d, vout: 1 }
    2024-01-25 03:48:09  INFO legacy_collaborative_revert_confirm: coordinator::collaborative_revert: Broadcasting legacy collaborative revert transaction txid="ff0caddb62757a5f83c06a1b89ee711386af062114ba54743589eba130e505e6"
    2024-01-25 03:48:09  INFO legacy_collaborative_revert_confirm: ln_dlc_node::ldk_node_wallet: Broadcasting transaction txid=ff0caddb62757a5f83c06a1b89ee711386af062114ba54743589eba130e505e6 raw_tx=020000000001019d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc7960100000000ffffffff020cac010000000000160014d9c449146b6e77fb25e1a0cb9df8a4f1bfb76b9fec5d0100000000001600140876754f0454f9520eef5907a29046df2f5247c40400473044022001be96903e3b7d2dde75f2b94265bea34776caf39a5b08e1aa97da86ffefff0a022029e03e85d68b30e5da80785b7dbef5a2080ad85f0ddcbbea8664717549b00ab2014730440220796bbe729297653b39606a4a7c54fe1883d9f40c7336133e2d70d658bfb12e29022011f2af5aad09acd956bc398e3c52602f11f08446593019e8c599e4077b536504014752210208ed5c1d4672bb376553c17987c3209dc0f4c9bd414b7d4592b31c7ea54cddb22102b41746840aba0a7c469f59a871ed05d1222b72700e60882a0ff43d4a78ceaa8952ae00000000
    
  • App logs:

    2024-01-25T03:48:09.549488622Z DEBUG native::orderbook: New orderbook message msg=CollaborativeRevert
    2024-01-25T03:48:09.550024945Z DEBUG native::orderbook: Received request to revert channel channel_id=9d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc797
    flutter: [D] TIME: 2024-01-25T03:48:09.553995Z Received a collab revert channel event. Status: TaskStatus.pending
    flutter: [D] TIME: 2024-01-25T03:48:09.561413Z Received a collab revert channel event. Status: TaskStatus.success
    2024-01-25T03:48:09.678716111Z  INFO native::ln_dlc: Received response from confirming reverting a channel response="\"020000000001019d8b2495465de9cf7173a1304aaaa5f27ec9035e762386863e0403becaacc7960100000000ffffffff020cac010000000000160014d9c449146b6e77fb25e1a0cb9df8a4f1bfb76b9fec5d0100000000001600140876754f0454f9520eef5907a29046df2f5247c40400473044022001be96903e3b7d2dde75f2b94265bea34776caf39a5b08e1aa97da86ffefff0a022029e03e85d68b30e5da80785b7dbef5a2080ad85f0ddcbbea8664717549b00ab2014730440220796bbe729297653b39606a4a7c54fe1883d9f40c7336133e2d70d658bfb12e29022011f2af5aad09acd956bc398e3c52602f11f08446593019e8c599e4077b536504014752210208ed5c1d4672bb376553c17987c3209dc0f4c9bd414b7d4592b31c7ea54cddb22102b41746840aba0a7c469f59a871ed05d1222b72700e60882a0ff43d4a78ceaa8952ae00000000\""
    2024-01-25T03:48:09.682792872Z  INFO native::ln_dlc: Channel is reverted before the position got closed successfully.
    
  • Collab revert transaction:

    image

Collab revert with app updated from 1.7.4 to this branch

  1. Build app and coordinator on version 1.7.4.
  2. Start environment and open channel and position with app.
  3. Shut down coordinator and app.
  4. Re-start coordinator and app on this branch.
  5. Trigger collab revert.
curl -X POST localhost:8000/api/admin/channels/legacy-revert -d '{"channel_id":"49557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a", "txid": "6a893dd64653068350974182146bdb64d65d0c1a6a80aec9dbf9f8c299785549", "vout": 0, "coordinator_amount": 110000, "fee_rate_sats_vb": 5, "price":"40000"}' -H "Content-Type: application/json"
  1. Verify logs and values.
  • Coordinator logs:

    2024-01-25 04:20:48  INFO legacy_collaborative_revert: coordinator::collaborative_revert: Proposing legacy collaborative revert channel_id="49557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a" coordinator_address=bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj coordinator_amount=109580 trader_amount=89580
    2024-01-25 04:20:48  INFO legacy_collaborative_revert: coordinator::admin: Proposed legacy collaborative revert channel_id="49557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a"
    2024-01-25 04:20:48  INFO coordinator::message: Sending trader message trader_id=024f2c0f703ecc90144d20123d1609d5a5fd0dd1c537543e0319b75095b92d09d9 LegacyCollaborativeRevert { channel_id: [73, 85, 120, 153, 194, 248, 249, 219, 201, 174, 128, 106, 26, 12, 93, 214, 100, 219, 107, 20, 130, 65, 151, 80, 131, 6, 83, 70, 214, 61, 137, 106], coordinator_address: bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj, coordinator_amount: Amount(0.00109580 BTC), trader_amount: Amount(0.00089580 BTC), execution_price: 40000, funding_txo: OutPoint { txid: 6a893dd64653068350974182146bdb64d65d0c1a6a80aec9dbf9f8c299785549, vout: 0 } }
    2024-01-25 04:20:48  INFO legacy_collaborative_revert_confirm: coordinator::routes: Confirming legacy collaborative revert channel_id="49557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a"
    2024-01-25 04:20:48  INFO legacy_collaborative_revert_confirm: coordinator::collaborative_revert: Confirming legacy collaborative revert legacy_collaborative_revert_record=LegacyCollaborativeRevert { channel_id: ChannelId([73, 85, 120, 153, 194, 248, 249, 219, 201, 174, 128, 106, 26, 12, 93, 214, 100, 219, 107, 20, 130, 65, 151, 80, 131, 6, 83, 70, 214, 61, 137, 106]), trader_pubkey: PublicKey(d9092db99550b719033e5437c5d10dfda5d509163d12204d1490cc3e700f2c4f78e6dd18c1716b7b4b4ee766f3ca3ac55e01be8d15098f93b02a281814cda0a5), price: 40000.0, coordinator_address: bcrt1qm8zyj9rtdemlkf0p5r9em79y7xlmw6uldzqttj, coordinator_amount_sats: Amount(0.00109580 BTC), trader_amount_sats: Amount(0.00089580 BTC), timestamp: 2024-01-25 4:20:48.545728 +00:00:00, txid: 6a893dd64653068350974182146bdb64d65d0c1a6a80aec9dbf9f8c299785549, vout: 0 }
    2024-01-25 04:20:48  INFO legacy_collaborative_revert_confirm: coordinator::collaborative_revert: Broadcasting legacy collaborative revert transaction txid="ef28f7a5fecfd8b49c90af22759d555738fc8bba2c537a7695a87bd47a717dd6"
    2024-01-25 04:20:48  INFO legacy_collaborative_revert_confirm: ln_dlc_node::ldk_node_wallet: Broadcasting transaction txid=ef28f7a5fecfd8b49c90af22759d555738fc8bba2c537a7695a87bd47a717dd6 raw_tx=0200000000010149557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a0000000000ffffffff020cac010000000000160014d9c449146b6e77fb25e1a0cb9df8a4f1bfb76b9fec5d01000000000016001407e02fbfb4c106c3df6051d7ec4a6fa324a338380400473044022036d0862eb9305fcfec80643f4b27cae21882c140ad5a578b08622567c304c00c02203c3389fc75d503295a97055846fa13c3b6ea8d87187d23c4a970e8a2a01835340147304402203ac72e02dd07b70b5c77d8ae09c3e4bb30cc615637cb348b892d4b1a9519bf5a0220453295c597ec056bce8b4e4d3682b666439762759502cdfd01d3171ecccec5cc014752210236ccda588363ea4b2d914da380de7c481cd46e590e6fc6e635908b12fb408aa22102664d85cedc9d432cde8adfe404a019638025bccc684c40b2a74d10594fd934f552ae00000000
    
  • App logs:

    2024-01-25T04:20:48.552280914Z DEBUG native::orderbook: New orderbook message msg=CollaborativeRevert
    2024-01-25T04:20:48.552443732Z DEBUG native::orderbook: Received request for legacy collaborative revert of LN-DLC channel channel_id=49557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a
    flutter: [DEBUG] TIME: 2024-01-25T04:20:48.554173Z Received a collab revert channel event. Status: TaskStatus.pending
    flutter: [DEBUG] TIME: 2024-01-25T04:20:48.563019Z Received a collab revert channel event. Status: TaskStatus.success
    2024-01-25T04:20:48.640378143Z  INFO native::ln_dlc: Received response from confirming reverting a channel response="\"0200000000010149557899c2f8f9dbc9ae806a1a0c5dd664db6b148241975083065346d63d896a0000000000ffffffff020cac010000000000160014d9c449146b6e77fb25e1a0cb9df8a4f1bfb76b9fec5d01000000000016001407e02fbfb4c106c3df6051d7ec4a6fa324a338380400473044022036d0862eb9305fcfec80643f4b27cae21882c140ad5a578b08622567c304c00c02203c3389fc75d503295a97055846fa13c3b6ea8d87187d23c4a970e8a2a01835340147304402203ac72e02dd07b70b5c77d8ae09c3e4bb30cc615637cb348b892d4b1a9519bf5a0220453295c597ec056bce8b4e4d3682b666439762759502cdfd01d3171ecccec5cc014752210236ccda588363ea4b2d914da380de7c481cd46e590e6fc6e635908b12fb408aa22102664d85cedc9d432cde8adfe404a019638025bccc684c40b2a74d10594fd934f552ae00000000\""
    2024-01-25T04:20:48.640602571Z  INFO native::ln_dlc: Channel is legacy-reverted before the position got closed successfully.
    
  • Collab revert transaction:

    image

This can be removed once all LN-DLC channels in production have been
closed.
@luckysori luckysori requested review from bonomat and holzeis January 25, 2024 04:03
@luckysori luckysori self-assigned this Jan 25, 2024
Copy link
Contributor

@holzeis holzeis left a comment

Choose a reason for hiding this comment

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

Nice,

Did you also test the scenario where the collab revert has been triggered with 1.7.4, but will only get accepted with the app and the coordinator upgraded to this branch?

@luckysori
Copy link
Contributor Author

Did you also test the scenario where the collab revert has been triggered with 1.7.4, but will only get accepted with the app and the coordinator upgraded to this branch?

Yep, both scenarios involve the coordinator upgrading to this branch, because that's a key part of what we want to achieve: that an app on version 1.7.4 or 1.8.0 can be collab-reverted with a coordinator on version 1.8.0.

The scenario you are referring to is the 2nd one in the PR description.

@luckysori luckysori added this pull request to the merge queue Jan 25, 2024
Merged via the queue into main with commit fab2d8b Jan 25, 2024
9 checks passed
@luckysori luckysori deleted the feat/legacy-collab-revert branch January 25, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants