Skip to content

Add an override optional UserConfig per new outbound channel #517

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

Merged

Conversation

ccdle12
Copy link
Contributor

@ccdle12 ccdle12 commented Feb 26, 2020

fixes #485

This PR adds an optional UserConfig parameter when calling create_channel() in ChannelManager.

The idea is that if this option is None, ChannelManager will revert to the default_configuration found in its own fields or the user can provide their own configuration for a particular channel.

Also to add that in the original issue, there was some discussion about implementing a tracked peer-per channel config as in a "whitelist" of pubkeys. It seems like an interesting idea, but I thought that would deserve its own attempt at a PR - since I think we would still need to switch between a default and an override config per channel.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the PR! I think the testing could possibly be expanded a tad, but overall it's looking very good.


// Node0 initiates a channel to node1 using the override config.
let mut override_config = UserConfig::default();
override_config.own_channel_config.our_to_self_delay = 200;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the existing testing for bad UserConfig values is pretty light -- this test could be a good opportunity to add some more :)

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 1st PR, overall looks good to me, can you squash functional test and fuzzing fixes commit to avoid breaking git bisect ? Also rebase on master to avoid the fixup one.

if channel_value_satoshis < 1000 {
return Err(APIError::APIMisuseError { err: "channel_value must be at least 1000 satoshis" });
}

let channel = Channel::new_outbound(&*self.fee_estimator, &self.keys_manager, their_network_key, channel_value_satoshis, push_msat, user_id, Arc::clone(&self.logger), &self.default_configuration)?;
let channel = match override_config {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

719b5ec

You may try
if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in regards to the git jobs, I've squashed and dropped the fixup. My bad, looking back at the contribution guidelines I missed this:

Further, each commit, individually, should compile and pass tests, in order to ensure git bisect and other automated tools function properly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ariard's suggested change here would probably make this more readable. Also, it looks like you replaced all the indentation here with spaces. Please don't mix indentation types in a file.

Copy link
Contributor Author

@ccdle12 ccdle12 Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks and appreciate the review @TheBlueMatt, I'll start work on the requested changes

@ccdle12
Copy link
Contributor Author

ccdle12 commented Feb 27, 2020

thank for the review @valentinewallace and @ariard, I'll get started on the comments :)

@ccdle12 ccdle12 force-pushed the 2020-02-per-channel-config branch from b4e7ec6 to fe154c8 Compare February 27, 2020 12:07
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs a few nits addressed and the commits squashed.

if channel_value_satoshis < 1000 {
return Err(APIError::APIMisuseError { err: "channel_value must be at least 1000 satoshis" });
}

let channel = Channel::new_outbound(&*self.fee_estimator, &self.keys_manager, their_network_key, channel_value_satoshis, push_msat, user_id, Arc::clone(&self.logger), &self.default_configuration)?;
let channel = match override_config {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ariard's suggested change here would probably make this more readable. Also, it looks like you replaced all the indentation here with spaces. Please don't mix indentation types in a file.


#[test]
fn test_override_channel_config() {
let chanmon_cfgs = create_chanmon_cfgs(2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Same here, please use indentation characters instead of spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed both, perhaps better to work on the requested updates to the tests before squashing? - might be easier for everyone to match the review requested per commit

@TheBlueMatt
Copy link
Collaborator

Looks good. Needs rebase but otherwise probably fine to go. I dont know that this needs more tests for the new functionality, only that our general config infrastructure likely does.

@ccdle12 ccdle12 force-pushed the 2020-02-per-channel-config branch from 0a08644 to 849c514 Compare February 28, 2020 22:30
@ccdle12 ccdle12 force-pushed the 2020-02-per-channel-config branch from 849c514 to 53c894b Compare February 28, 2020 22:58
@ccdle12
Copy link
Contributor Author

ccdle12 commented Feb 28, 2020

Ok sounds good, maybe I could help review a PR or look into further testing on the config infrastructure. Squashed and rebased.

@TheBlueMatt TheBlueMatt merged commit 27426f8 into lightningdevkit:master Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to per-channel config
4 participants