{"action":"created","issue":{"url":"https://api.github.com/repos/ElementsProject/lightning/issues/1888","repository_url":"https://api.github.com/repos/ElementsProject/lightning","labels_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1888/labels{/name}","comments_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1888/comments","events_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1888/events","html_url":"https://github.com/ElementsProject/lightning/pull/1888","id":354338800,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExMTI0NTMx","number":1888,"title":"first version of lib-autopilot.py","user":{"login":"renepickhardt","id":1926816,"node_id":"MDQ6VXNlcjE5MjY4MTY=","avatar_url":"https://avatars2.githubusercontent.com/u/1926816?v=4","gravatar_id":"","url":"https://api.github.com/users/renepickhardt","html_url":"https://github.com/renepickhardt","followers_url":"https://api.github.com/users/renepickhardt/followers","following_url":"https://api.github.com/users/renepickhardt/following{/other_user}","gists_url":"https://api.github.com/users/renepickhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/renepickhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renepickhardt/subscriptions","organizations_url":"https://api.github.com/users/renepickhardt/orgs","repos_url":"https://api.github.com/users/renepickhardt/repos","events_url":"https://api.github.com/users/renepickhardt/events{/privacy}","received_events_url":"https://api.github.com/users/renepickhardt/received_events","type":"User","site_admin":false},"labels":[{"id":669479200,"node_id":"MDU6TGFiZWw2Njk0NzkyMDA=","url":"https://api.github.com/repos/ElementsProject/lightning/labels/Work%20in%20Progress","name":"Work in Progress","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-08-27T14:18:54Z","updated_at":"2018-09-08T07:52:14Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/ElementsProject/lightning/pulls/1888","html_url":"https://github.com/ElementsProject/lightning/pull/1888","diff_url":"https://github.com/ElementsProject/lightning/pull/1888.diff","patch_url":"https://github.com/ElementsProject/lightning/pull/1888.patch"},"body":"As mentioned in the c-lightning list: https://lists.ozlabs.org/pipermail/c-lightning/2018-August/000065.html you wellcome plugins which are not written in c.\r\n\r\n So I took the liberty to provide a first sketch for an autopilot for c-lightning written an python. In the beginning of the year I have stated on lnd's autopilot that the Barabasi Albert model was probably not the best choice (c.f.: https://github.com/lightningnetwork/lnd/issues/677 ) This is why my lib can currently generate candidates for an autopilot to open channels with according to four strategies (and it combines those currently):\r\n\r\n* Random: following the Erdoes Renyi model nodes are drawn from a uniform distribution\r\n* Central: nodes are sampled from a uniform distribution of the top most central nodes (betweenness)\r\n* Network_Improovement: nodes are sampled from a uniform distribution of the nodes which are badly connected\r\n* richness: nodes with high liquidity are taken and it is sampled from a uniform distribution of those\r\n\r\nthis library is work in progress. there is no logic yet implemented on how many funds to allocate to which channel and actually opening the channels (though I think that this should be the easy part) Also due to the randomness the lib might sometimes find less channels than the user asked for. Also many conner cases will let the code break.\r\n\r\nTherefor the PR is more for code review and suggestions.\r\n\r\nRunning the code produces this output:  (edit: the version in the pull request only prints the nodes without the statistics about balance and channels)\r\n```\r\n2018-08-27 16:06:19,285 - lib-autopilot - INFO - Try to load graph from file system at: data/networkx_graph\r\n2018-08-27 16:06:19,306 - lib-autopilot - INFO - Successfully restored the lightning network graph from data/networkx_graph\r\n2018-08-27 16:06:19,306 - lib-autopilot - INFO - running the autopilot on a graph with 1528 nodes and 7997 edges.\r\n2018-08-27 16:06:19,306 - lib-autopilot - INFO - GENERATE CANDIDATES: Try to generate up to {} nodes with 4 strategies: (random, central, network Improvement, liquidity)\r\n2018-08-27 16:06:19,306 - lib-autopilot - INFO - RANDOM_NODES: try to generate a set of 6 nodes sampled with uniform distribution\r\n2018-08-27 16:06:19,306 - lib-autopilot - INFO - CENTRAL_NODES: Try to seek 6 nodes which are currently central\r\n2018-08-27 16:06:32,083 - lib-autopilot - INFO - CENTRAL_NODES: Generated top 24 central nodes (according to betweeness centrality)\r\n2018-08-27 16:06:32,083 - lib-autopilot - INFO - CENTRAL_NODES: Sample 6 items from the candidates as was requested\r\n2018-08-27 16:06:32,083 - lib-autopilot - INFO - RICH_NODES: Try to generate 6 candidates from the 0.5-percentile\r\n2018-08-27 16:06:32,092 - lib-autopilot - INFO - RICH_NODES: Found 34 candidates in the 0.5-percentile\r\n2018-08-27 16:06:32,092 - lib-autopilot - INFO - RICH_NODES: Sample 6 items from the candidates as was requested\r\n2018-08-27 16:06:32,092 - lib-autopilot - INFO - IMPROOVE_NETWORK: Try to seek 6 nodes which are currently bad connected\r\n2018-08-27 16:06:37,253 - lib-autopilot - INFO - IMPROOVE_NETWORK: Found 16 candidates which are currently bad connected\r\n2018-08-27 16:06:37,253 - lib-autopilot - INFO - IMPROOVE_NETWORK: Sample 6 items from the candidates as was requested\r\n2018-08-27 16:06:37,253 - lib-autopilot - INFO - GENERATE CANDIDATES: Found 21 nodes with which channel creation is suggested\r\n\r\npercentage   smoothed percentage    capacity    numchannels     alias\r\n----------------------------------------------------------------------\r\n        0.43           1.73           60000          1      andromeda\r\n        1.45           2.44         2000000         10      stealthmode\r\n        6.12           5.71       404547196        478      tady je slushovo\r\n        6.64           6.08       119389472        130      node1.lnroute.com (LND)\r\n        4.83           4.81        67439741        101      skyrus.net\r\n        0.68           1.90         4403776         47      ⚡⚡⚡GERMAN⚡⚡⚡\r\n       14.67          11.70       176501181         87      CoinGate\r\n        7.24           6.50       414456777        414      🚀🌑 TrueVision.club\r\n        3.04           3.55          420000          1      MEDUSA\r\n        0.47           1.76           65000          1      🚀🌑cl.TrueVision.club\r\n       13.36          10.78       363941981        197      Bitrefill.com\r\n        6.64           6.08        86301722         94      ScripterRon\r\n        7.48           6.67        13449158         13      jfbnode\r\n        0.47           1.76           65000          1      🚀⚡CoNNeX⚡🚀\r\n        0.36           1.68           50000          1      02b80cabdf82638aac86\r\n        0.07           1.48           10000          1      yusasufhin\r\n        8.51           7.38       152889341        130      ACINQ\r\n        0.65           1.88           90000          1      margens\r\n        5.15           5.03         3557093          5      ABank02\r\n       11.59           9.54       245288253        153      mainnet.yalls.org\r\n        0.14           1.53           20000          1      SLEEPYARK-PILOT\r\n```\r\nto explain the output. I asked to lib-autopilot to generate 21 candidates. you can see  in the table the nodes (by their alias for better readability) which are suggested to connect to. \r\n\r\nThe first two columns list the percentage of our funds that the lib-autopilot thinks should be used for this channel. In the first column this is given by looking at the average channel balances of the partners and look at the relative frequency (with respect to alle the other average channel balances for the suggested channels). the second column smoothes the results with a weighted uniform distribution (currently the weight is 70% for the first column and 30% for the uniform distribution)\r\n\r\nthe third colum lists how much balance all the channels of the suggested partner has. the fourth column is the number of active channels and the last one is the alias.\r\n\r\nI would be happy about any thoughts regarding my statistics. I think smoothing is usefull. "},"comment":{"url":"https://api.github.com/repos/ElementsProject/lightning/issues/comments/419621319","html_url":"https://github.com/ElementsProject/lightning/pull/1888#issuecomment-419621319","issue_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1888","id":419621319,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTYyMTMxOQ==","user":{"login":"renepickhardt","id":1926816,"node_id":"MDQ6VXNlcjE5MjY4MTY=","avatar_url":"https://avatars2.githubusercontent.com/u/1926816?v=4","gravatar_id":"","url":"https://api.github.com/users/renepickhardt","html_url":"https://github.com/renepickhardt","followers_url":"https://api.github.com/users/renepickhardt/followers","following_url":"https://api.github.com/users/renepickhardt/following{/other_user}","gists_url":"https://api.github.com/users/renepickhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/renepickhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renepickhardt/subscriptions","organizations_url":"https://api.github.com/users/renepickhardt/orgs","repos_url":"https://api.github.com/users/renepickhardt/repos","events_url":"https://api.github.com/users/renepickhardt/events{/privacy}","received_events_url":"https://api.github.com/users/renepickhardt/received_events","type":"User","site_admin":false},"created_at":"2018-09-08T07:52:14Z","updated_at":"2018-09-08T07:52:14Z","author_association":"COLLABORATOR","body":"@leishman thanks for your review. I separated the lib_autopilot from the C-lightning rpc interface on purpose. So the lib_autopilot could also easily be integrated to lnd or eclair. In particular it could be used by researchers to run simulations and find better strategies. A long term goal will be that the autopilots commuicate to each other and exchange some information about channel balances (which might conflict with privacy) and are able to request channels from others. In particular the autopilot currently ignores the channels you already have. There will be still much more work to do for this feature. "}}
{"actor":{"display_login":"renepickhardt"}}