-
Notifications
You must be signed in to change notification settings - Fork 946
introduce support for alternative addresses for peer connections #7422
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
base: master
Are you sure you want to change the base?
Conversation
Thanks @maxrantil for the proposal. I read through the description, and I'm not sure I understand the rationale for this change. Is this intended as a way to say "hey, if we get disconnected, this is how you can reach me again", or is the intention something else? Just thought I'd ask this before looking at the code itself, wanting to start with the right mental model. |
Hi @cdecker , as you might know, this project is part of Summer of Bitcoin and this is the project description:
I think this answers your question, right? |
Oh, cool, yeah I hadn't made the connection right away. Thanks for sharing the description, it's much clearer now |
f6bacf0
to
24018af
Compare
d212cd9
to
572a616
Compare
821e28d
to
e461ad2
Compare
aae893b
to
e6ff7da
Compare
0360fcf
to
be019d1
Compare
- Aswell as parameters alt-bind-addr and alt-announce-addr Changelog-Added: Introduced the 'alt-addr' config parameter for specifying alternative addresses. Signed-off-by: Max Rantil <rantil@pm.me>
be019d1
to
6be03fc
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.
I apologize that I am only reviewing this now. It needs significant rework to be included, and may not make this release.
I'm aware that this was a Summer of Bitcoin project, so I can make the changes myself.
/* Alternative address for peer connections not publicly announced */ | ||
u8 *alt_addr; | ||
/* Alternative binding address for peer connections not publicly announced */ | ||
u8 *alt_bind_addr; | ||
|
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.
This is a very strange type to use! We have a struct wireaddr, which is far more convenient, and has the bonus we parse it immediately.
char **bind_addrs = tal_strsplit(tmpctx, (char *)ld->alt_bind_addr, | ||
",", STR_NO_EMPTY); | ||
for (size_t i = 0; bind_addrs[i] != NULL; i++) | ||
if (strcmp(arg, bind_addrs[i]) == 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.
This has the problem that equivalent addresses can be different strings.
There are two things here, however: restricted addresses, to which only whitelisted peers can connect to, and the addresses we advertize. This is not clearly documented, and needs to be.
/* We need the addrs in my own db too for later whitelist confirmation */ | ||
u8 *msg = towire_channeld_my_alt_addr(tmpctx, peer->my_alt_addr); | ||
wire_sync_write(MASTER_FD, take(msg)); | ||
} |
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.
This is a very weird thing for channeld to do. It's more gossipy than channel-related. These days, this kind of thing is handled by connectd.
msgtype,peer_alt_addr,209 | ||
msgdata,peer_alt_addr,addr_len,u8, | ||
msgdata,peer_alt_addr,addr,byte,addr_len, |
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.
This is a spec change! This means:
- It needs an associated assignment for a BOLT PR.
- Meanwhile it should use 32768+ as that's the experimental range.
- We should probably mark it experimental in the mean time.
Also, this file is generated from the spec, rather than hand-edited.
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.
regarding the BOLT PR, after discussions with other devs here we came to the conclusion for a blip-0043 instead of a BOLT.
@@ -1021,6 +1021,8 @@ static struct migration dbmigrations[] = { | |||
{SQL("ALTER TABLE channels ADD remote_htlc_minimum_msat BIGINT DEFAULT NULL;"), NULL}, | |||
{SQL("ALTER TABLE channels ADD last_stable_connection BIGINT DEFAULT 0;"), NULL}, | |||
{NULL, migrate_initialize_alias_local}, | |||
{SQL("ALTER TABLE peers ADD COLUMN peer_alt_addr TEXT DEFAULT '';"), NULL}, |
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.
I think this should be an array of wireaddr, not a text field.
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.
sounds good to me
@@ -1021,6 +1021,8 @@ static struct migration dbmigrations[] = { | |||
{SQL("ALTER TABLE channels ADD remote_htlc_minimum_msat BIGINT DEFAULT NULL;"), NULL}, | |||
{SQL("ALTER TABLE channels ADD last_stable_connection BIGINT DEFAULT 0;"), NULL}, | |||
{NULL, migrate_initialize_alias_local}, | |||
{SQL("ALTER TABLE peers ADD COLUMN peer_alt_addr TEXT DEFAULT '';"), NULL}, | |||
{SQL("ALTER TABLE peers ADD COLUMN my_alt_addr TEXT DEFAULT '';"), NULL}, |
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.
I don't understand why this is in the db?
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.
You might give different alt_addrs to different peers, so you want to confirm, when they connect to you, that you have given that peer the alt_addr it is trying to connect to.
And ofcourse the db is read on node restart, that's why its there.
@@ -289,6 +308,11 @@ struct daemon { | |||
/* Our features, as lightningd told us */ | |||
struct feature_set *our_features; | |||
|
|||
/* check whitelist before accepting incoming alt addr */ | |||
struct whitelisted_peer_htable *whitelisted_peer_htable; |
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.
I think this can simply be a set of node ids (i.e a htable of node_ids).
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.
I think the previous answer does explain why we need more then only the node_id
/* This is a dev command: fix the api if you need this! */ | ||
if (more_than_one) | ||
return command_fail(cmd, LIGHTNINGD, "More than one channel"); | ||
|
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.
No it's not a dev command!
Plus, you can totally whitelist ids which are not peers.
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.
If you say so! I just couldn't understand how to whitelist ids which are not peers.
Thanks for looking into it @rustyrussell , I understand that there now needs to be a lot of fixes to merge it and if it doesn't make it to the release it will hopefully make it to the next one. I will try to answer all your questions |
This PR introduces a new configuration parameter,
alt_addr
, which allows specifying an alternative address for peer connections.Key Features
alt_addr
is specified, this address is communicated to the peer.alt_addr
is used to establish the connection.alt-addr
,alt-bind-addr
, andalt-announce-addr
for managing alternative addresses.alt-bind-addr
for specific peers.