ld: add commit-fee-offset option, update config schema

Changelog-Added: Added option --commit-fee-offset to potentially reduce feerate update disagreements
This commit is contained in:
Alex Myers 2023-10-31 14:24:50 -05:00 committed by Rusty Russell
parent 4265699fcd
commit 10bac49dac
6 changed files with 69 additions and 1 deletions

View file

@ -313,6 +313,11 @@ The [`lightning-listconfigs`](ref:lightning-listconfigs) command will output a v
The percentage of _estimatesmartfee 2/CONSERVATIVE_ to use for the commitment The percentage of _estimatesmartfee 2/CONSERVATIVE_ to use for the commitment
transactions: default is 100. transactions: default is 100.
- **commit-feerate-offset**=_INTEGER_
The additional feerate a channel opener adds to their preferred feerate to
lessen the odds of a disconnect due to feerate disagreement (default 5).
- **max-concurrent-htlcs**=_INTEGER_ - **max-concurrent-htlcs**=_INTEGER_
Number of HTLCs one channel can handle concurrently in each direction. Number of HTLCs one channel can handle concurrently in each direction.

View file

@ -281,6 +281,9 @@ On success, an object is returned, containing:
- **commit-fee** (object, optional): - **commit-fee** (object, optional):
- **value\_int** (u64): field from config or cmdline, or default - **value\_int** (u64): field from config or cmdline, or default
- **source** (string): source of configuration setting - **source** (string): source of configuration setting
- **commit-feerate-offset** (object, optional):
- **value\_int** (u32): field from config or cmdline, or default
- **source** (string): source of configuration setting
- **# version** (string, optional): Special field indicating the current version **deprecated, removal in v24.05** - **# version** (string, optional): Special field indicating the current version **deprecated, removal in v24.05**
- **plugins** (array of objects, optional) **deprecated, removal in v24.05**: - **plugins** (array of objects, optional) **deprecated, removal in v24.05**:
- **path** (string): Full path of the plugin - **path** (string): Full path of the plugin
@ -359,6 +362,7 @@ On success, an object is returned, containing:
- **developer** (boolean, optional): Whether developer mode is enabled *(added v23.08)* - **developer** (boolean, optional): Whether developer mode is enabled *(added v23.08)*
- **commit-fee** (u64, optional): The percentage of the 6-block fee estimate to use for commitment transactions **deprecated, removal in v24.05** *(added v23.05)* - **commit-fee** (u64, optional): The percentage of the 6-block fee estimate to use for commitment transactions **deprecated, removal in v24.05** *(added v23.05)*
- **min-emergency-msat** (msat, optional): field from config or cmdline, or default *(added v23.08)* - **min-emergency-msat** (msat, optional): field from config or cmdline, or default *(added v23.08)*
- **commit-feerate-offset** (u32, optional): additional commitment feerate applied by channel owner *(added v23.11)*
[comment]: # (GENERATE-FROM-SCHEMA-END) [comment]: # (GENERATE-FROM-SCHEMA-END)
@ -476,4 +480,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning> Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:cc7b6d10f93b9efb34ad76d0cc2273d29189a8dd7ef4acef2e5227755c279ea8) [comment]: # ( SHA256STAMP:245e056bdda7c8015917c89e243a0fd3bdd1512ca760da5d7f0a284cb3214ef7)

View file

@ -420,6 +420,11 @@ opens a channel before the channel is usable.
The percentage of *estimatesmartfee 2/CONSERVATIVE* to use for the commitment The percentage of *estimatesmartfee 2/CONSERVATIVE* to use for the commitment
transactions: default is 100. transactions: default is 100.
* **commit-feerate-offset**=*INTEGER*
The additional feerate a channel opener adds to their preferred feerate to
lessen the odds of a disconnect due to feerate disagreement (default 5).
* **max-concurrent-htlcs**=*INTEGER* * **max-concurrent-htlcs**=*INTEGER*
Number of HTLCs one channel can handle concurrently in each direction. Number of HTLCs one channel can handle concurrently in each direction.

View file

@ -1351,6 +1351,24 @@
"description": "source of configuration setting" "description": "source of configuration setting"
} }
} }
},
"commit-feerate-offset": {
"type": "object",
"additionalProperties": false,
"required": [
"value_int",
"source"
],
"properties": {
"value_int": {
"type": "u32",
"description": "field from config or cmdline, or default"
},
"source": {
"type": "string",
"description": "source of configuration setting"
}
}
} }
} }
}, },
@ -1770,6 +1788,11 @@
"type": "msat", "type": "msat",
"added": "v23.08", "added": "v23.08",
"description": "field from config or cmdline, or default" "description": "field from config or cmdline, or default"
},
"commit-feerate-offset": {
"type": "u32",
"added": "v23.11",
"description": "additional commitment feerate applied by channel owner"
} }
} }
} }

View file

@ -1578,6 +1578,10 @@ static void register_opts(struct lightningd *ld)
clnopt_witharg("--commit-fee", OPT_SHOWINT, clnopt_witharg("--commit-fee", OPT_SHOWINT,
opt_set_u64, opt_show_u64, &ld->config.commit_fee_percent, opt_set_u64, opt_show_u64, &ld->config.commit_fee_percent,
"Percentage of fee to request for their commitment"); "Percentage of fee to request for their commitment");
clnopt_witharg("--commit-feerate-offset", OPT_SHOWINT,
opt_set_u32, opt_show_u32, &ld->config.feerate_offset,
"Additional feerate per kw to apply to feerate updates "
"as the channel opener");
clnopt_witharg("--min-emergency-msat", OPT_SHOWMSATS, clnopt_witharg("--min-emergency-msat", OPT_SHOWMSATS,
opt_set_sat_nondust, opt_show_sat, &ld->emergency_sat, opt_set_sat_nondust, opt_show_sat, &ld->emergency_sat,
"Amount to leave in wallet for spending anchor closes"); "Amount to leave in wallet for spending anchor closes");

View file

@ -3831,3 +3831,30 @@ def test_even_sendcustommsg(node_factory):
l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg)) l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
l1.daemon.wait_for_log('Invalid unknown even msg') l1.daemon.wait_for_log('Invalid unknown even msg')
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == []) wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [])
def test_set_feerate_offset(node_factory, bitcoind):
opts = [{'commit-feerate-offset': 100}, {}]
l1, l2 = node_factory.get_nodes(2, opts=opts)
assert l1.daemon.is_in_log('Server started with public key')
configs = l1.rpc.listconfigs()['configs']
assert configs['commit-feerate-offset'] == {'source': 'cmdline',
'value_int': 100}
scid12 = l1.fundchannel(l2)[0]
# chanid = l1.get_channel_scid(l2)
# node 1 sets fees.
l1.set_feerates((14000, 11000, 7500, 3750))
l1.pay(l2, 200000000)
# First payment causes fee update, which should reflect the feerate offset.
l1.daemon.wait_for_log('lightningd: update_feerates: feerate = 11100, '
'min=1875, max=150000, penalty=7500')
l2.daemon.wait_for_log('peer updated fee to 11100')
l2.pay(l1, 100000000)
# Now shutdown cleanly.
l1.rpc.close(scid12)
l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE')
l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE')