Repository navigation
fix: reduce update_fee target for anchor channels - #9826
Conversation
| self.logger.info(f"({chan.get_id_for_log()}) current pending feerate {chan_fee}. " | ||
| f"new feerate {feerate_per_kw}") | ||
| chan.update_fee(feerate_per_kw, True) | ||
| f"new feerate {current_feerate_per_kw}") |
There was a problem hiding this comment.
I find the current_feerate_per_kw / update_feerate_per_kw split somewhat confusing.
For example, here, we should probably log the value we are actually updating the fee to.
There was a problem hiding this comment.
Yeah missed that log, changed it.
I found it useful to have these two variables as it is hard to do the calculations otherwise, would you suggest different naming or do you see any cleaner approach?
| ratio = chan_feerate / current_feerate_per_kw | ||
| if ratio < 0.5: | ||
| # Note that we trust the Electrum server about fee rates | ||
| # Thus, automated force-closing might not be a good idea | ||
| # Maybe we should display something in the GUI instead | ||
| self.logger.warning( | ||
| f"({chan.get_id_for_log()}) feerate is {chan_feerate} sat/kw, " | ||
| f"current recommended feerate is {feerate_per_kw} sat/kw, consider force closing!") | ||
| f"current recommended feerate is {current_feerate_per_kw} sat/kw, consider force closing!") |
There was a problem hiding this comment.
here also, we probably want update_feerate_per_kw instead.
(what we "recommend" should be what we would want to update the fee to, no? :P)
There was a problem hiding this comment.
Switched to update_feerate_per_kw, i thought it may is better to be "less aggressive" here but it's just a warning, so using update_feerate_per_kw for the ratio and the log seems more consistent yes.
| return | ||
| # add some buffer to anchor chan fees as we always act at the lower end and don't | ||
| # want to get kicked out of the mempool immediately if it grows | ||
| fee_buffer = current_feerate_per_kw * 0.25 if chan.has_anchors() else 0 |
There was a problem hiding this comment.
note: the +25% comes from eclair: https://github.com/ACINQ/eclair/blob/f14b92d7df8727d6362d86251d717a93f37df251/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/fee/OnChainFeeConf.scala#L127
but they have additional logic giving it more buffer
I think we could just use +50%, to be safer, but not have said additional logic.
There was a problem hiding this comment.
on second thought, let's just add a 5 sat/vbyte floor, to reduce the chance of not getting into the mempool after coming back from a long offline period
There was a problem hiding this comment.
have added a floor in current_target_feerate_per_kw() and increased the buffer to 50%
d2b7941 to
c6b376e
Compare
the update_fee logic for lightning channels was not adapted to anchor channels causing us to send update_fee with a eta target of 2 blocks. This causes force closes when there are mempool spikes as the fees we try to update to are a lot higher than e.g. eclair uses. Eclair will force close if our fee is 10x > than their fee.
c6b376e to
61874e9
Compare
| if has_anchors: | ||
| # set a floor of 5 sat/vb to have some safety margin in case the mempool | ||
| # grows quickly | ||
| feerate_per_kvbyte = max(feerate_per_kvbyte, 5000) |
There was a problem hiding this comment.
self-note: we add the +50% buffer on top of this later, so the effective floor is 7.5 s/b
the update_fee logic for lightning channels is not adapted to anchor channels causing us to send update_fee with a eta target of 2 blocks, while for anchor channels it is enough to just get into the mempool as the fee can be bumped later. This causes force closes when there are mempool spikes as the fees we try to update to are a lot higher than e.g. eclair uses. Eclair will send errors if our attempted fee update is 10x > than their fee.
This now uses the 1008 block estimate + 25% buffer as the anchor channel fee target. This is the lowest value available to fetch from electrum servers / bitcoin core estimatesmartfee limit, which also guarantees acceptance into the mempool.
As side effect of adding 1008 blocks to the
FEE_ETA_TARGETSto be fetched, these values are also shown in the gui. So i added 144 (1 day) too and tooltips for them, as they seem useful anyways and introducing logic to not show all eta's in the gui would make things more complex.Potentially an addition to the electrum protocol allowing to explicitly fetch the minimal mempool acceptance fee would be useful for the future.
Example of such a force close: