-
Notifications
You must be signed in to change notification settings - Fork 404
Wumbo! #1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wumbo! #1425
Changes from all commits
5840374
7bf7b3a
fa59544
e49f738
5cfe19e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,9 +58,12 @@ use ln::chan_utils::CommitmentTransaction; | |
#[test] | ||
fn test_insane_channel_opens() { | ||
// Stand up a network of 2 nodes | ||
use ln::channel::TOTAL_BITCOIN_SUPPLY_SATOSHIS; | ||
let mut cfg = UserConfig::default(); | ||
cfg.peer_channel_config_limits.max_funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It allows us to cover both the cases of |
||
let chanmon_cfgs = create_chanmon_cfgs(2); | ||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); | ||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); | ||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(cfg)]); | ||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs); | ||
|
||
// Instantiate channel parameters where we push the maximum msats given our | ||
|
@@ -92,11 +95,11 @@ fn test_insane_channel_opens() { | |
} else { assert!(false); } | ||
}; | ||
|
||
use ln::channel::MAX_FUNDING_SATOSHIS; | ||
use ln::channelmanager::MAX_LOCAL_BREAKDOWN_TIMEOUT; | ||
|
||
// Test all mutations that would make the channel open message insane | ||
insane_open_helper(format!("Funding must be smaller than {}. It was {}", MAX_FUNDING_SATOSHIS, MAX_FUNDING_SATOSHIS).as_str(), |mut msg| { msg.funding_satoshis = MAX_FUNDING_SATOSHIS; msg }); | ||
insane_open_helper(format!("Per our config, funding must be at most {}. It was {}", TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1, TOTAL_BITCOIN_SUPPLY_SATOSHIS + 2).as_str(), |mut msg| { msg.funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 2; msg }); | ||
insane_open_helper(format!("Funding must be smaller than the total bitcoin supply. It was {}", TOTAL_BITCOIN_SUPPLY_SATOSHIS).as_str(), |mut msg| { msg.funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS; msg }); | ||
|
||
insane_open_helper("Bogus channel_reserve_satoshis", |mut msg| { msg.channel_reserve_satoshis = msg.funding_satoshis + 1; msg }); | ||
|
||
|
@@ -113,6 +116,25 @@ fn test_insane_channel_opens() { | |
insane_open_helper("max_accepted_htlcs was 484. It must not be larger than 483", |mut msg| { msg.max_accepted_htlcs = 484; msg }); | ||
} | ||
|
||
#[test] | ||
fn test_funding_exceeds_no_wumbo_limit() { | ||
// Test that if a peer does not support wumbo channels, we'll refuse to open a wumbo channel to | ||
// them. | ||
use ln::channel::MAX_FUNDING_SATOSHIS_NO_WUMBO; | ||
let chanmon_cfgs = create_chanmon_cfgs(2); | ||
let mut node_cfgs = create_node_cfgs(2, &chanmon_cfgs); | ||
node_cfgs[1].features = InitFeatures::known().clear_wumbo(); | ||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); | ||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs); | ||
|
||
match nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), MAX_FUNDING_SATOSHIS_NO_WUMBO + 1, 0, 42, None) { | ||
valentinewallace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Err(APIError::APIMisuseError { err }) => { | ||
assert_eq!(format!("funding_value must not exceed {}, it was {}", MAX_FUNDING_SATOSHIS_NO_WUMBO, MAX_FUNDING_SATOSHIS_NO_WUMBO + 1), err); | ||
}, | ||
_ => panic!() | ||
} | ||
} | ||
|
||
fn do_test_counterparty_no_reserve(send_from_initiator: bool) { | ||
// A peer providing a channel_reserve_satoshis of 0 (or less than our dust limit) is insecure, | ||
// but only for them. Because some LSPs do it with some level of trust of the clients (for a | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
//! Various user-configurable channel limits and settings which ChannelManager | ||
//! applies for you. | ||
|
||
use ln::channel::MAX_FUNDING_SATOSHIS_NO_WUMBO; | ||
use ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT}; | ||
|
||
/// Configuration we set when applicable. | ||
|
@@ -95,11 +96,16 @@ impl Default for ChannelHandshakeConfig { | |
/// are applied mostly only to incoming channels that's not much of a problem. | ||
#[derive(Copy, Clone, Debug)] | ||
pub struct ChannelHandshakeLimits { | ||
/// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so | ||
/// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so | ||
/// only applies to inbound channels. | ||
/// | ||
/// Default value: 0. | ||
pub min_funding_satoshis: u64, | ||
/// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so | ||
/// only applies to inbound channels. | ||
/// | ||
/// Default value: 2^24 - 1. | ||
pub max_funding_satoshis: u64, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have a config parameter? If we advertise support for wumbo, wouldn't it be surprising to a peer if they couldn't open a channel >= 2^24? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users are likely to implement it anyway via the |
||
/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows | ||
/// you to limit the maximum minimum-size they can require. | ||
/// | ||
|
@@ -151,6 +157,7 @@ impl Default for ChannelHandshakeLimits { | |
fn default() -> Self { | ||
ChannelHandshakeLimits { | ||
min_funding_satoshis: 0, | ||
max_funding_satoshis: MAX_FUNDING_SATOSHIS_NO_WUMBO, | ||
max_htlc_minimum_msat: <u64>::max_value(), | ||
min_max_htlc_value_in_flight_msat: 0, | ||
max_channel_reserve_satoshis: <u64>::max_value(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny nitpick on naming (not blocking): I feel like "total" can be misinterpreted in various ways such as representing the total supply so far and not necessarily year 2140. If the intention is to communicate the maximum number of sats possible in any one channel, then maybe a name like
MAX_SATOSHI_LIMIT
would be more accurate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Total bitcoin supply" is referred to quite a few times in the codebase as 21 million bitcoin, so I like that it's consistent with that