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

listpeerchannels: split conversion into stages #5825

Merged
merged 14 commits into from Jan 13, 2023

Conversation

rustyrussell
Copy link
Contributor

This is #5568 split into simple commits. Hopefully this will not just help with review, but with debugging!

@rustyrussell rustyrussell added this to the v22.11.1 milestone Dec 15, 2022
@rustyrussell rustyrussell marked this pull request as draft December 15, 2022 05:08
@rustyrussell rustyrussell modified the milestones: v22.11.1, v23.02 Dec 15, 2022
@rustyrussell
Copy link
Contributor Author

Moving to draft, since 8f0cdb8 is suspicious.

Is it really the case that bookkeeper won't see the payment if it happens just before the node is shutdown? @niftynei

@rustyrussell rustyrussell force-pushed the guilt/pr-5568 branch 3 times, most recently from f4956d0 to dc560d7 Compare December 15, 2022 06:15
@rustyrussell rustyrussell mentioned this pull request Dec 15, 2022
@vincenzopalazzo vincenzopalazzo changed the title listpeerhtlcs: split conversion into stages listpeerchannels: split conversion into stages Dec 15, 2022
@vincenzopalazzo vincenzopalazzo self-assigned this Dec 15, 2022
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Sorry for the messy history, I should do a better job with it and make life easier for everybody.

I think the last change that this PR needs is

rm contrib/pyln-testing/pyln/testing/node_pb2.py and make -j$(nproc) check DEVELOPER=1

this will regenerate the python code that we had, maybe this works also without removing the file?

@rustyrussell
Copy link
Contributor Author

OK, I've further diagnosed the bookkeeper issue.

What happens (once listpeers is faster due to removal of channels[]):

  1. Two payments (111 msat and 222 msat) are complete.
  2. One payment (4,000,000 msat) is half-complete: l2 sends removal and sig, but stops before l1 reply. So bookkeeper's notification not called.
  3. l1 goes onchain, with that 4M msat HTLC resolved.
  4. bookkeeper records this differently.

Before (all settled before unilateral close):

DEBUG:root:{
  "id": "pytest:bkpr-listaccountevents#23",
  "result": {
    "events": [
      {
        "account": "wallet",
        "type": "channel",
        "tag": "journal_entry",
        "credit_msat": "0msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "timestamp": 1671162611,
        "is_rebalance": false
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "channel_open",
        "credit_msat": "0msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "39d55b0463a19f49e31e5dca98c5af17721b33383c603d9f535c451590a0e712:1",
        "timestamp": 1671162614,
        "blockheight": 103
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "channel",
        "tag": "invoice",
        "credit_msat": "111msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "payment_id": "edaf67a40f8ca36ae02832ca591cff0d6be6fd05dac28addea5b8359a697e855",
        "part_id": 0,
        "timestamp": 1671162624,
        "description": "JPLcIsLkZ4PIl04gljQh",
        "is_rebalance": false
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "channel",
        "tag": "invoice",
        "credit_msat": "222msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "payment_id": "be8ea4c3d7cc291a76ae865d2feda2a85de28d405b0f1877919aeb0b225f112b",
        "part_id": 0,
        "timestamp": 1671162625,
        "description": "xyGn04WTTt8WM33A2xqJ",
        "is_rebalance": false
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "channel",
        "tag": "invoice",
        "credit_msat": "4000000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "payment_id": "43006c98d17c4d72a81a256e0ce7260d940fde3b5757bcba3a209b7559837053",
        "part_id": 0,
        "timestamp": 1671162627,
        "description": "xohM9goEbViIiTRuzzPl",
        "is_rebalance": false
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "channel_close",
        "credit_msat": "0msat",
        "debit_msat": "4000333msat",
        "currency": "bcrt",
        "outpoint": "39d55b0463a19f49e31e5dca98c5af17721b33383c603d9f535c451590a0e712:1",
        "txid": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186",
        "timestamp": 1671162629,
        "blockheight": 104
      },
      {
        "account": "wallet",
        "origin": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "anchor",
        "credit_msat": "330000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186:0",
        "timestamp": 1671162629,
        "blockheight": 104
      },
      {
        "account": "external",
        "origin": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "anchor",
        "credit_msat": "330000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186:1",
        "timestamp": 1671162629,
        "blockheight": 104
      },
      {
        "account": "wallet",
        "origin": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "deposit",
        "credit_msat": "4000000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186:2",
        "timestamp": 1671162629,
        "blockheight": 104
      },
      {
        "account": "external",
        "origin": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "chain",
        "tag": "to_them",
        "credit_msat": "982975000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186:3",
        "timestamp": 1671162629,
        "blockheight": 104
      },
      {
        "account": "12e7a09015455c539f3d603c38331b7217afc598ca5d1ee3499fa163045bd538",
        "type": "onchain_fee",
        "tag": "onchain_fee",
        "credit_msat": "333msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "timestamp": 1671162629,
        "txid": "2a35b9498dfa9881b5b8e6a5844db6af4f520d7c077d872790c7c4dd7bf8e186"
      }
    ]
  }
}

After (one settled by unilateral close):

DEBUG:root:{
  "id": "pytest:bkpr-listaccountevents#19",
  "result": {
    "events": [
      {
        "account": "wallet",
        "type": "channel",
        "tag": "journal_entry",
        "credit_msat": "0msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "timestamp": 1671162699,
        "is_rebalance": false
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "channel_open",
        "credit_msat": "0msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "500e5492b6ab78e62c7fdd4e29de39cfb829e41e42b341e0ed12188e3b98e043:0",
        "timestamp": 1671162702,
        "blockheight": 103
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "channel",
        "tag": "invoice",
        "credit_msat": "111msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "payment_id": "2b9320b8d31dc5767a0c9d7302983a1c3d86dbf489cd0f1e92a81ce8206c9fac",
        "part_id": 0,
        "timestamp": 1671162712,
        "description": "ILn6TzJJn6OrB8qinufP",
        "is_rebalance": false
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "channel",
        "tag": "invoice",
        "credit_msat": "222msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "payment_id": "7154be1f3d8f5f19d11fffbb832cbdc4a51b094cda189a9023329db84307b206",
        "part_id": 0,
        "timestamp": 1671162713,
        "description": "b1GyiJYLKeu39Fyi8aRX",
        "is_rebalance": false
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "channel_close",
        "credit_msat": "0msat",
        "debit_msat": "333msat",
        "currency": "bcrt",
        "outpoint": "500e5492b6ab78e62c7fdd4e29de39cfb829e41e42b341e0ed12188e3b98e043:0",
        "txid": "478dd6ba6f98c393bb207e5849c86494443c194c0c94993fd49f05fcf93af2b7",
        "timestamp": 1671162716,
        "blockheight": 104
      },
      {
        "account": "wallet",
        "origin": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "anchor",
        "credit_msat": "330000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "478dd6ba6f98c393bb207e5849c86494443c194c0c94993fd49f05fcf93af2b7:0",
        "timestamp": 1671162716,
        "blockheight": 104
      },
      {
        "account": "external",
        "origin": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "anchor",
        "credit_msat": "330000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "478dd6ba6f98c393bb207e5849c86494443c194c0c94993fd49f05fcf93af2b7:1",
        "timestamp": 1671162716,
        "blockheight": 104
      },
      {
        "account": "wallet",
        "origin": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "deposit",
        "credit_msat": "4000000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "478dd6ba6f98c393bb207e5849c86494443c194c0c94993fd49f05fcf93af2b7:2",
        "timestamp": 1671162716,
        "blockheight": 104
      },
      {
        "account": "external",
        "origin": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "chain",
        "tag": "to_them",
        "credit_msat": "982975000msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "outpoint": "478dd6ba6f98c393bb207e5849c86494443c194c0c94993fd49f05fcf93af2b7:3",
        "timestamp": 1671162716,
        "blockheight": 104
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "channel",
        "tag": "penalty_adj",
        "credit_msat": "3999667msat",
        "debit_msat": "0msat",
        "currency": "bcrt",
        "timestamp": 1671162716,
        "is_rebalance": false
      },
      {
        "account": "43e0983b8e1812ede041b3421ee429b8cf39de294edd7f2ce678abb692540e50",
        "type": "channel",
        "tag": "penalty_adj",
        "credit_msat": "0msat",
        "debit_msat": "3999667msat",
        "currency": "bcrt",
        "timestamp": 1671162716,
        "is_rebalance": false
      }
    ]
  }
}

@rustyrussell
Copy link
Contributor Author

I've rebased this onto master; it deprecates the schema and doesn't remove it now. We don't have deprecations for parameter removal, so that still gets removed entirely.

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Looks like the bookkeeper error is hide under the following one

=========================== short test summary info ============================
FAILED tests/test_connection.py::test_wumbo_channels - KeyError: 'channels'
============ 1 failed, 499 passed, 54 skipped in 1863.02s (0:31:03) ============

I think this is one reason to prioritize this PR and not merge it close to the end of the merge windows, this PR will break many (if not all) others PRs

rustyrussell and others added 9 commits January 12, 2023 11:45
We're soon going to call json_add_unsaved_channel and
json_add_uncommitted_channel from a new place, where we want the peer
state directly included.

Based on patch by @vincenzopalazzo.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: new command `listpeerchannels` now contains information on direct channels with our peers.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Instead of returning a peers -> channels heirarchy, return (as callers
want!) a flat array of channels.

This is actually most of the transition work to make them work with
listpeerchannels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…nels().

This way we always have an SCID and a direction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Don't parse the listpeers.channels output ourselves: with two extra fields
we can simply reuse json_to_listpeers_channels().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
vincenzopalazzo and others added 5 commits January 12, 2023 11:54
With the next change (which, as a side-effect, speeds up listpeers),
we seem to hit a race in this test.  The bookkeeper doesn't get to
process the final payment before the node is shutdown.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `listpeers` `channels` array: use `listpeerchannels`

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Some are best copied into the schema, but some are already
out-of-date, so cleanest to remove them and rely on the generated (and
thus, checked!) fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell
Copy link
Contributor Author

These changes always find things that have changed since I did the initial sweep! No big deal, I'm re-testing now, rebased on master.

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK 6b41666

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.

None yet

2 participants