Skip to content

Allowing the creation of height locked Slates Fixes #564#565

Open
jafalter wants to merge 3 commits into
mimblewimble:masterfrom
jafalter:PR-564
Open

Allowing the creation of height locked Slates Fixes #564#565
jafalter wants to merge 3 commits into
mimblewimble:masterfrom
jafalter:PR-564

Conversation

@jafalter

@jafalter jafalter commented Jan 5, 2021

Copy link
Copy Markdown
Contributor

Created new function blank_with_kernel_features which takes (compared to the regular blank(num_participants: u8, is_invoice: bool)) the additional parameters kernel_feat_param: u8, and lock_height_param: Option<u64> such that one can create a slate with a height locked kernel.

This fixes the issue #564

I have adjusted blank(num_participants: u8, is_invoice: bool) to use this new function to avoid code duplication.

@DavidBurkett DavidBurkett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change looks good to me. @antiochp @quentinlesceller, can one of you merge this?

Comment thread libwallet/src/slate.rs Outdated
false => SlateState::Standard1,
};
let kernel_features = if kernel_feat_param > 3 {
0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

my guess is that kernel_feat_param being > 3 means there's a bug, so is it possible that a panic would be better in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed, fixed

@phyro

phyro commented Mar 19, 2021

Copy link
Copy Markdown
Contributor

@antiochp @quentinlesceller do you guys think this one is good to merge?

Comment thread libwallet/src/slate.rs Outdated
/// Create a new slate with custom kernel_feature and lock height
/// If a lock_height is set kernel_features will have to be either HeightLocked (2) or NoRecentDuplicate (3)
/// otherwise the value passed as lock_height will be ignored and a plain kernel will be created
/// Invalid arguments for kernel_features (>3) will be set to 0 (Plain)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should update this comment as well now that we made it panic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

very true, thanks! Corrected the comment now.

@phyro

phyro commented Mar 29, 2021

Copy link
Copy Markdown
Contributor

alright, @antiochp @quentinlesceller could one of you two also give it a quick look now and merge if it looks good?

@quentinlesceller quentinlesceller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR @jafalter! I have a question regarding safety and possible simplification.

Comment thread libwallet/src/slate.rs
Comment on lines +262 to +267
pub fn blank_with_kernel_features(
num_participants: u8,
is_invoice: bool,
kernel_feat_param: u8,
lock_height_param: Option<u64>,
) -> Slate {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would that makes sense to pass a kernel_features like that?

Suggested change
pub fn blank_with_kernel_features(
num_participants: u8,
is_invoice: bool,
kernel_feat_param: u8,
lock_height_param: Option<u64>,
) -> Slate {
pub fn blank_with_kernel_features(
num_participants: u8,
is_invoice: bool,
kernel_features: KernelFeatures,
) -> Slate {

That would avoid to have the whole parsing and possible panic in here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with this suggestion, doing it in this way also doesn't need code modification if/when we add new kernel features 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jafalter pinging just in case it was forgotten

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will do that. But I just need to doublecheck because I remember one of the types was not publicly visible I think that is why I did it like that.

@jafalter jafalter Apr 24, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@quentinlesceller @phyro the Slate struct requires a Option<KernelFeaturesArgs> see:
image
KernelFeaturesArgs is not a publicly visible struct, therefore can't be passed as the parameter. Using KernelFeatures as you recommended would require bigger refactoring of the Slate struct, this is why I went for this solution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jafalter sorry for the late response. I see, in this case I'm ok if we go this way and we can possibly refactor this later 👍
cc: @quentinlesceller

@quentinlesceller quentinlesceller self-requested a review May 25, 2021 14:44
@cekickafa

Copy link
Copy Markdown

is that forgotten?

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.

6 participants