lightningd: loosen feerate minimum.

We're getting spurious closures, even on mainnet.  Using --ignore-fee-limits
is dangerous; it's slightly less so to lower the minimum (which is the
usual cause of problems).

So let's halve it, but beware the floor.

This is a workaround, until we get independent feerates in the spec.

Fixes: #613
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-04-27 11:46:03 +09:30 committed by Christian Decker
parent 5db73c6e27
commit c6af2a8cb2
6 changed files with 21 additions and 16 deletions

View File

@ -253,7 +253,7 @@ static void next_updatefee_timer(struct chain_topology *topo);
* This formula is satisfied by a feerate of 4030 (hand-search).
*/
#define FEERATE_FLOOR 253
static u32 feerate_floor(void)
u32 feerate_floor(void)
{
/* Assert that bitcoind will see this as above minRelayTxFee */
BUILD_ASSERT(FEERATE_BITCOIND_SEES(FEERATE_FLOOR, MINIMUM_TX_WEIGHT)

View File

@ -136,6 +136,9 @@ u32 get_block_height(const struct chain_topology *topo);
/* Get fee rate in satoshi per kiloweight. */
u32 get_feerate(const struct chain_topology *topo, enum feerate feerate);
/* Get the minimum possible fee to allow relaying by bitcoind */
u32 feerate_floor(void);
/* Broadcast a single tx, and rebroadcast as reqd (copies tx).
* If failed is non-NULL, call that and don't rebroadcast. */
void broadcast_tx(struct chain_topology *topo,

View File

@ -744,15 +744,8 @@ u8 *peer_accept_channel(const tal_t *ctx,
subd_send_msg(uc->openingd, take(msg));
/* BOLT #2:
*
* Given the variance in fees, and the fact that the transaction may
* be spent in the future, it's a good idea for the fee payer to keep
* a good margin, say 5x the expected fee requirement */
msg = towire_opening_fundee(uc, uc->minimum_depth,
get_feerate(ld->topology, FEERATE_SLOW),
get_feerate(ld->topology, FEERATE_IMMEDIATE)
* 5,
feerate_min(ld), feerate_max(ld),
open_msg);
subd_req(uc, uc->openingd, take(msg), -1, 2,

View File

@ -162,12 +162,18 @@ u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx)
u32 feerate_min(struct lightningd *ld)
{
if (ld->config.ignore_fee_limits)
return 1;
u32 min;
/* Set this to average of slow and normal.*/
return (get_feerate(ld->topology, FEERATE_SLOW)
+ get_feerate(ld->topology, FEERATE_NORMAL)) / 2;
/* We can't allow less than feerate_floor, since that won't relay */
if (ld->config.ignore_fee_limits)
min = 1;
else
/* Set this to half of slow rate.*/
min = get_feerate(ld->topology, FEERATE_SLOW) / 2;
if (min < feerate_floor())
return feerate_floor();
return min;
}
/* BOLT #2:

View File

@ -4135,7 +4135,7 @@ class LightningDTests(BaseLightningDTests):
# L1 asks for stupid low fees
l1.rpc.dev_setfees(15)
l1.daemon.wait_for_log('Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: received ERROR channel .*: update_fee 15 outside range 4250-75000')
l1.daemon.wait_for_log('Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: received ERROR channel .*: update_fee 15 outside range 500-75000')
# Make sure the resolution of this one doesn't interfere with the next!
# Note: may succeed, may fail with insufficient fee, depending on how
# bitcoind feels!
@ -4277,7 +4277,7 @@ class LightningDTests(BaseLightningDTests):
# Make l2 upset by asking for crazy fee.
l1.rpc.dev_setfees('150000')
# Wait for l1 notice
l1.daemon.wait_for_log(r'Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: received ERROR channel .*: update_fee 150000 outside range 4250-75000')
l1.daemon.wait_for_log(r'Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: received ERROR channel .*: update_fee 150000 outside range 500-75000')
# Can't pay while its offline.
self.assertRaises(ValueError, l1.rpc.sendpay, to_json(route), rhash)

View File

@ -71,6 +71,9 @@ bool extract_channel_id(const u8 *in_pkt UNNEEDED, struct channel_id *channel_id
/* Generated stub for features_supported */
bool features_supported(const u8 *gfeatures UNNEEDED, const u8 *lfeatures UNNEEDED)
{ fprintf(stderr, "features_supported called!\n"); abort(); }
/* Generated stub for feerate_floor */
u32 feerate_floor(void)
{ fprintf(stderr, "feerate_floor called!\n"); abort(); }
/* Generated stub for fromwire_gossipctl_peer_disconnect_reply */
bool fromwire_gossipctl_peer_disconnect_reply(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_gossipctl_peer_disconnect_reply called!\n"); abort(); }