Research/Bitcoin Dev Archive / lightning-dev list
Why do we need fee estimation in the protocol?
3 messages, May 12 to 15, 2018. Started by CJP.
CJP, Rusty Russell, ZmnSCPxj
Hi,
Maybe this is a stupid question, and it is late so maybe I'm overlooking something, but I don't want to lose a potentially good idea, so here it goes:
Right now, BOLT#3 imposes a certain algorithm for fee estimation. This algorithm is likely to be sub-optimal: fee estimation is a difficult subject, and may involve subjective situation-specific considerations of participants. I guess it's only there to achieve some kind of consensus between the peers.
But why do we need consensus at all? There are two versions of each commitment transaction: one to be used for unilateral close by one peer (A), and one to be used by the other (B). Peer A has an interest in "commit transaction A", so I'd consider it fair to let peer A pay the transaction fee for that commit tx (subtracted from its part of the channel funds), and also to let peer A determine the amount of that fee. If A wants a different fee for whatever reason, it should simply be able to ask B for a signature on an updated "commit transaction A". B shouldn't care about that fee, as long as its own funds, HTLCs etc. are OK.
I guess, when only changing the fee, you don't even need to use a new revocation secret. Your peer may have different versions which only differ in how much fees your peer pays, and you 'll never care which of them will be used by your peer. Not using a new revocation secret may or may not be a premature optimization though.
If a peer doesn't have enough funds to pay a reasonably effective tx fee, normally that shouldn't be a problem, because then it doesn't have a significant financial interest in having a usable commit tx either. The only exception is if there are significant HTLCs. Is this where the idea breaks down? As far as I can see, this is an exceptional (but important) case, but during normal operation, peers should be free to choose the fee for their own commit tx.
You'd have to deal with any follow-up transactions as well: changing a fee changes the txID, so you need to update follow-up transactions.
regards, CJP
CJP <cjp at ultimatestunts.nl> writes:
Quoted text (22 lines)
> Hi, > > Maybe this is a stupid question, and it is late so maybe I'm > overlooking something, but I don't want to lose a potentially good > idea, so here it goes: > > Right now, BOLT#3 imposes a certain algorithm for fee estimation. This > algorithm is likely to be sub-optimal: fee estimation is a difficult > subject, and may involve subjective situation-specific considerations > of participants. I guess it's only there to achieve some kind of > consensus between the peers. > > But why do we need consensus at all? There are two versions of each > commitment transaction: one to be used for unilateral close by one peer > (A), and one to be used by the other (B). Peer A has an interest in > "commit transaction A", so I'd consider it fair to let peer A pay the > transaction fee for that commit tx (subtracted from its part of the > channel funds), and also to let peer A determine the amount of that > fee. If A wants a different fee for whatever reason, it should simply > be able to ask B for a signature on an updated "commit transaction A". > B shouldn't care about that fee, as long as its own funds, HTLCs etc. > are OK.
It was an attempt at simplficiation: since A always pays the fee, it always sets the level. This means, of course, that B needs to approve it, particularly since HTLCs pay their own fees (oops!), so actually B does care about fee levels!
And that got us into this mess.
We *can* make them independent (with some twists for the initial case where A holds all the funds and must of necessity pay for B's fee too), but the asynchronous nature of updates means it's actually quite a dance. I was bracing myself to write propose that in the spec but:
Even fixing this is insufficient: neither side may end up being happy with the fees when it comes to use the commitment tx. Thus Laolu proposal of always having an "OP_TRUE" output and minimal fees, to basically require you to use CPFP to push the tx. That costs some onchain bloat for unilateral closes, but greatly simplfied the fee problems.
Note that Eltoo works around this by always being a single input/output pair with SIGHASH_SINGLE|SIGHASH_ANYONECANPAY (and relying on SIGHASH_NOINPUT) so you can attach fees later without this bloat issue.
Cheers, Rusty.
Good morning CJP, Rusty, and list,
Quoted text (19 lines)
> > But why do we need consensus at all? There are two versions of each > > > > commitment transaction: one to be used for unilateral close by one peer > > > > (A), and one to be used by the other (B). Peer A has an interest in > > > > "commit transaction A", so I'd consider it fair to let peer A pay the > > > > transaction fee for that commit tx (subtracted from its part of the > > > > channel funds), and also to let peer A determine the amount of that > > > > fee. If A wants a different fee for whatever reason, it should simply > > > > be able to ask B for a signature on an updated "commit transaction A". > > > > B shouldn't care about that fee, as long as its own funds, HTLCs etc. > > > > are OK.
I was thinking this myself.
Quoted text (3 lines)
> We can make them independent (with some twists for the initial case > > where A holds all the funds and must of necessity pay for B's fee too),
Perhaps the twisting could be made relatively minimal: at initial funding, assuming `push_msat=0`, then B does not in fact require a commitment transaction: it could just completely forget the channel ever existed, as it has no stake in the channel.
And in the case `push_msat!=0`, then B *does* have funds in the channel with which to pay the onchain fee.
Quoted text (3 lines)
> Even fixing this is insufficient: neither side may end up being happy > > with the fees when it comes to use the commitment tx.
Yes, this is indeed an issue...
Quoted text (7 lines)
> > Note that Eltoo works around this by always being a single input/output > > pair with SIGHASH_SINGLE|SIGHASH_ANYONECANPAY (and relying on > > SIGHASH_NOINPUT) so you can attach fees later without this bloat issue. >
This works for Decker-Russell-Osuntokun trigger and update transactions, but not for settlement transactions. But then settlement transactions do not have their outputs encumbered with a CSV (it is the settlement transaction itself which is so encumbered), hence allowing direct CPFP.
The same technique cannot be used in Poon-Dryja even with `SIGHASH_NOINPUT`, since commitment transactions often have multiple outputs.
Regards, ZmnSCPxj