Research/Bitcoin Dev Archive / lightning-dev list
Lack of capacity field in channel_announcement makes life difficult. Why is it not there?
7 messages, Jul 29 to Aug 1, 2018. Started by Артём Литвинович.
Robert Olsson (2), Christian Decker (2), Артём Литвинович, Rusty Russell, Sjors Provoost
Greetings.
What was the rationale for not including channel capacity into the channel_announcement message?
As things stand now, the only way to determine it is to check the blockchain, which is hard for mobile and/or light wallets. Even worse, the data is only there in the form of short_channel_id, which is incompatible with most block explorer APIs.
In other words, having to have access to the blockchain turns a route-finding tool from a simple program into a thing laden with many dependencies in order to fetch and parse the transactions. Not knowing the capacity of the channels drops routing success rates dramatically, especially for larger payments.
Is there a good reason to force us to do so that i'm missing?
-Artem
I agree that having to look in the blockchain should not be a requirement for light wallets.
I think however it would be much better and flexible to append a max to channel_update. We already have htlc_minimum_msat there and could add htlc_maximum_msat to show capacity (minus fees) Like this:
1. type: 258 (channel_update)
2. data:
- [64:signature]
- [32:chain_hash]
- [8:short_channel_id]
- [4:timestamp]
- [2:flags]
- [2:cltv_expiry_delta]
- [8:htlc_minimum_msat]
- [4:fee_base_msat]
- [4:fee_proportional_millionths]
- [8:htlc_maximum_msat]
It shouldn't be an issue for older implementations to handle an added 8 bytes, they simply won't read the last 8 bytes. New implementations can easily read old ones, and setting htlc_maxmimum_msat internally to a default value.
Implementations that do lookup in blockchain can easily check that htlc_maximum_msat doesn't exceed the real capacity, and discard those messages if they see fit.
By simply adding 8 bytes at the end it should be an easy fix that is/should be compatible with current implementations (devs:please verify your parsing code, i haven't).
We also have flexibility to adjust these values just as we adjust the disable flag or fees. That means we could optionally perodically announce this value to reflect the average local balance, and thereby make it much easier for implementations to avoid for instance channels with low or 0 balance.
Even if not periodically gossiped it would help in many cases.
Consider an AMP payment of 100k going thru a channel which only has 50k local balance. The node already responds with an error with an attached type258 message. Let it reflect the current local balance in htlc_maximum_msat, so the AMP implementation can directly try 50k instead. Without that info in the error, the AMP implementation would have to try 90k, 80k, 70k, 60k, 50k before getting through, taking up time and resources.
Other implementations of it would be to set it in order to traffic control without having to signal it as disabled, and thereby passively balance channels, or making sure most funds end up on whatever desired side before closing on-chain. And there are other things you can do once we have this.
I think it would be a simple 8-byte fix with huge advantages and possibilities.
Regarding abuse: Nodes checking blockchain can discard erroneous messages. If the messages slip thru to a wallet that doesn't verify, how much could this possibly hurt and where? Today for instance Eclair assumes all channels are wide enough anyhows.
Regarding bandwidth: Nodes should not broadcast updates after every packet, but do it wisely. And optionally. You could just announce the original capacity.
Regarding privacy concerns: Use cases such as revealing local balances are of course totally optional and does not need to be activated for those node owners that prefer ppl to instead use repeated trial-and-error probing to discover the local balance. I'm currently working on a tool for that, but if this proposal is adopted i'll obviously scrap that project.
Best regards Robert Olsson
On Sun, Jul 29, 2018 at 3:59 PM, Артём Литвинович <theartlav at gmail.com> wrote:
Quoted text (27 lines)
> Greetings. > > What was the rationale for not including channel capacity into the > channel_announcement message? > > As things stand now, the only way to determine it is to check the > blockchain, which is hard for mobile and/or light wallets. > Even worse, the data is only there in the form of short_channel_id, which > is incompatible with most block explorer APIs. > > In other words, having to have access to the blockchain turns a > route-finding tool from a simple program into a thing laden with many > dependencies in order to fetch and parse the transactions. > Not knowing the capacity of the channels drops routing success rates > dramatically, especially for larger payments. > > Is there a good reason to force us to do so that i'm missing? > > > -Artem > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev > >
Robert Olsson <robban at robtex.com> writes:
Quoted text (19 lines)
> I think however it would be much better and flexible to append a max to > channel_update. We already have htlc_minimum_msat there and could add > htlc_maximum_msat to show capacity (minus fees) > Like this: > > > 1. type: 258 (channel_update) > 2. data: > - [64:signature] > - [32:chain_hash] > - [8:short_channel_id] > - [4:timestamp] > - [2:flags] > - [2:cltv_expiry_delta] > - [8:htlc_minimum_msat] > - [4:fee_base_msat] > - [4:fee_proportional_millionths] > > - [8:htlc_maximum_msat]
This isn't about maximum HTLC value, rather Артём is talking about adding the total channel capacity to the channel_announcement. That is a perfectly reasonable idea, as it allows us to safe an on-chain lookup (incidentally that is the main reason we started tracking an internal UTXO set so we can stop asking bitcoind for full blocks just to check a channel's capacity).
The channel's capacity is also fixed for the existence of that channel (splice-in and splice-out will result in new short channel IDs), so the announcement is exactly the right place to put this.
Cheers, Christian
Christian,
Ok, it definitely makes sense to include the exact fixed capacity in channel_announcement for the reason you mentioned, and more.
However, can we do both while we are at it? The ideas are not mutually exclusive, and for successful routing, i think the channel_update-approach is much more of a boost.
Regards, Robert
On Sun, Jul 29, 2018 at 4:59 PM, Christian Decker < decker.christian at gmail.com> wrote:
Quoted text (35 lines)
> Robert Olsson <robban at robtex.com> writes: > > I think however it would be much better and flexible to append a max to > > channel_update. We already have htlc_minimum_msat there and could add > > htlc_maximum_msat to show capacity (minus fees) > > Like this: > > > > > > 1. type: 258 (channel_update) > > 2. data: > > - [64:signature] > > - [32:chain_hash] > > - [8:short_channel_id] > > - [4:timestamp] > > - [2:flags] > > - [2:cltv_expiry_delta] > > - [8:htlc_minimum_msat] > > - [4:fee_base_msat] > > - [4:fee_proportional_millionths] > > > > - [8:htlc_maximum_msat] > > This isn't about maximum HTLC value, rather Артём is talking about > adding the total channel capacity to the channel_announcement. That is a > perfectly reasonable idea, as it allows us to safe an on-chain lookup > (incidentally that is the main reason we started tracking an internal > UTXO set so we can stop asking bitcoind for full blocks just to check a > channel's capacity). > > The channel's capacity is also fixed for the existence of that channel > (splice-in and splice-out will result in new short channel IDs), so the > announcement is exactly the right place to put this. > > Cheers, > Christian >
They are orthogonal, I agree, but we should judge their merits independently, and not batch the discussions out of convenience. In the case of the htlc_maximum_msat I think it will not be controversial, but it should get its own proposal and discussion.
Cheers, Christian On Sun, Jul 29, 2018 at 4:17 PM Robert Olsson <robban at robtex.com> wrote:
Quoted text (53 lines)
> > Christian, > > Ok, it definitely makes sense to include the exact fixed capacity in channel_announcement for the reason you mentioned, and more. > > However, can we do both while we are at it? The ideas are not mutually exclusive, and for successful routing, i think the channel_update-approach is much more of a boost. > > Regards, > Robert > > > On Sun, Jul 29, 2018 at 4:59 PM, Christian Decker <decker.christian at gmail.com> wrote: >> >> Robert Olsson <robban at robtex.com> writes: >> > I think however it would be much better and flexible to append a max to >> > channel_update. We already have htlc_minimum_msat there and could add >> > htlc_maximum_msat to show capacity (minus fees) >> > Like this: >> > >> > >> > 1. type: 258 (channel_update) >> > 2. data: >> > - [64:signature] >> > - [32:chain_hash] >> > - [8:short_channel_id] >> > - [4:timestamp] >> > - [2:flags] >> > - [2:cltv_expiry_delta] >> > - [8:htlc_minimum_msat] >> > - [4:fee_base_msat] >> > - [4:fee_proportional_millionths] >> > >> > - [8:htlc_maximum_msat] >> >> This isn't about maximum HTLC value, rather Артём is talking about >> adding the total channel capacity to the channel_announcement. That is a >> perfectly reasonable idea, as it allows us to safe an on-chain lookup >> (incidentally that is the main reason we started tracking an internal >> UTXO set so we can stop asking bitcoind for full blocks just to check a >> channel's capacity). >> >> The channel's capacity is also fixed for the existence of that channel >> (splice-in and splice-out will result in new short channel IDs), so the >> announcement is exactly the right place to put this. >> >> Cheers, >> Christian > > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
Christian Decker <decker.christian at gmail.com> writes:
Quoted text (4 lines)
> They are orthogonal, I agree, but we should judge their merits > independently, and not batch the discussions out of convenience. > In the case of the htlc_maximum_msat I think it will not be > controversial, but it should get its own proposal and discussion.
BTW, my thinking was that we should add an optional funding tx + merkle proof to channel_announce (or maybe a new channel_announce_with_proof msg). A node would use a feature bit to indicate it wants this. Or we could have a req/response for specific proofs.
We could also tunnel bitcoin block headers through the network, which would also help lite nodes.
Cheers, Rusty.
+1 on this idea, no opinion on data structure
Quoted text (8 lines)
> Op 29 jul. 2018, om 15:43 heeft Robert Olsson <robban at robtex.com> het volgende geschreven: > > > Regarding abuse: > Nodes checking blockchain can discard erroneous messages. If the messages slip thru to a wallet that doesn't verify, how much could this possibly hurt and where? Today for instance Eclair assumes all channels are wide enough anyhows. > > Regarding bandwidth: > Nodes should not broadcast updates after every packet, but do it wisely. And optionally. You could just announce the original capacity.
And Christian Decker wrote:
Quoted text (3 lines)
> (incidentally that is the main reason we started tracking an internal > UTXO set so we can stop asking bitcoind for full blocks just to check a > channel's capacity).
This could be very useful for fresh pruned nodes. When they receive gossip from before their birth, they would simply take notice in order to construct a map of the network, but hold off on fetching historical blocks to verify. Only when they need to make a payment, they would generate a bunch of candidate routes and fetch the relevant blocks to see if those channels were really created (and the UTXO set to make sure it's not closed).
It could still leave a bit of DOS risk if you gossip lies about lots of potentially useful channels in every historical block, forcing the pruned node to fetch these blocks one by one. Perhaps that can mitigated by a strong preference for channels created after wallet birth. There could also be cap on how many historical blocks are fetched before giving up. Anyway, this proposal doesn’t change that risk profile.
Sjors