Skip to content

Make NodeInfo API public - #910

Merged
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
sanket1729:nodeinfo_pub
Mar 28, 2022
Merged

apoelstra merged 1 commit into
rust-bitcoin:masterfrom
sanket1729:nodeinfo_pub

Conversation

@sanket1729

Copy link
Copy Markdown
Member

Reported by @shesek. Users might find it convenient to manually construct the tree using NodeInfo API

let leaf1 = NodeInfo::from_leaf_with_ver();
let leaf2 = NodeInfo::from_leaf_with_ver();

let root = NodeInfo::combine(leaf1, leaf2);
let spend_info = TaprootSpendInfo::from_node_info(&secp, internal_key, root);

@sanket1729 sanket1729 added the trivial Obvious, easy and quick to review (few lines or doc-only...) label Mar 27, 2022
@sanket1729

Copy link
Copy Markdown
Member Author

It is a fairly small change, but don't want to add anything else to the already pending rust-bitcoin release.

@dr-orlovsky

Copy link
Copy Markdown
Collaborator

I think this is needed for this release

dr-orlovsky
dr-orlovsky previously approved these changes Mar 27, 2022

@dr-orlovsky dr-orlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK d840614b1e71a8ad5f1c1702738003694eda610b

Regarding my nits, here and everywhere: I think the main challenge is to get ACKs, so all nits should be better addressed as a follow-up PR(s), if the author agrees with them - and not as a force-pushes discarding existing ACKs and taking reviewers time on non-important stuff once again.

Comment thread src/util/taproot.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
/// using [`TaprootBuilder`]
/// using [`TaprootBuilder`].

Comment thread src/util/taproot.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
/// Create a new [`NodeInfo`] with omitted/hidden info
/// Creates a new [`NodeInfo`] with omitted/hidden info

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.

nit: nit:

Suggested change
/// Create a new [`NodeInfo`] with omitted/hidden info
/// Creates a new [`NodeInfo`] with omitted/hidden info.

Comment thread src/util/taproot.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
/// Create a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`]
/// Creates a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`]

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.

nit: nit:

Suggested change
/// Create a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`]
/// Create a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`].

Phew, docs are hard to do meticulously :)

Comment thread src/util/taproot.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
/// Combine two [`NodeInfo`] to create a new parent
/// Combines two [`NodeInfo`] to create a new parent

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.

As above.

@JeremyRubin

Copy link
Copy Markdown
Contributor

ACK

@sanket1729

sanket1729 commented Mar 27, 2022 •

Copy link
Copy Markdown
Member Author

This is good to have, but not mandatory! This can be emulated using the TaprootBuilder API. Don't necessarily want to make it release-blocking if it does have to be. I really want to get this release out before bitcoin 2022 at Miami.

@dr-orlovsky

Copy link
Copy Markdown
Collaborator

Well, it's quite trivial and requires just a single ACK more...

@dr-orlovsky dr-orlovsky added the one ack PRs that have one ACK, so one more can progress them label Mar 27, 2022
@tcharding

Copy link
Copy Markdown
Member

Regarding my nits, here and everywhere: I think the main challenge is to get ACKs, so all nits should be better addressed as a follow-up PR(s), if the author agrees with them - and not as a force-pushes discarding existing ACKs and taking reviewers time on non-important stuff once again.

I agree with you that all this re-acking is adding seemingly unnecessary work for reviewers.

Idea: what if we pushed the burden onto the merger instead of the dev or reviewer? By that I mean, merger could decide that changes since ACK where trivial (e.g., docs, non-logic-changing refactor) and therefore the ACK is still valid? That way if reviewer gets to the PR and wants to re-ack, fine, if merger gets to the PR and sees nit-only fixes, then fine too.

@sanket1729

Copy link
Copy Markdown
Member Author

Idea: what if we pushed the burden onto the merger instead of the dev or reviewer? By that I mean, merger could decide that changes since ACK where trivial (e.g., docs, non-logic-changing refactor) and therefore the ACK is still valid? That way if reviewer gets to the PR and wants to re-ack, fine, if merger gets to the PR and sees nit-only fixes, then fine too.

This is possible, but I think we should keep this to a bare minimum, comment fixes, variable renames etc. I don't think code move refactors fall here because that has a big diff. I would be okay in doing this if the diff is fairly small(< 10-15 lines) and no code changes.

@tcharding tcharding 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.

The NodeInfo struct is now public but the fields are private and there are no getters/setters, are users able to use this struct as expected? I noticed that non of the util::taproot types are re-exported out of util, is that what we want? I am about to try and do the 'add taproot example' issue, perhaps I'll add a bunch of rustdoc examples to the taproot module to test the public API?

Comment thread src/util/taproot.rs Outdated

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.

nit: nit:

Suggested change
/// Create a new [`NodeInfo`] with omitted/hidden info
/// Creates a new [`NodeInfo`] with omitted/hidden info.

Comment thread src/util/taproot.rs Outdated

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.

nit: nit:

Suggested change
/// Create a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`]
/// Create a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`].

Phew, docs are hard to do meticulously :)

Comment thread src/util/taproot.rs Outdated

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.

As above.

@tcharding

Copy link
Copy Markdown
Member

I really want to get this release out before bitcoin 2022 at Miami

This! @apoelstra do you think we can do this, would be very cool but also even more pressure not to get egg on our face :) I think we can handle it, what do you rekon?

shesek added a commit to shesek/minsc that referenced this pull request Mar 27, 2022
For example:

    H_POINT+[
      pk(A),
      [
        `1 OP_ADD 2 OP_EQUAL`,
        0x51
      ]
    ]

Depends on rust-bitcoin/rust-bitcoin#910
@shesek

shesek commented Mar 28, 2022

Copy link
Copy Markdown
Contributor

Thanks! That's exactly what I wanted.

I wasn't able to test directly with this PR branch because I'm also using rust-miniscript which isn't compatible with rust-bitcoin's master (Prevouts "expected 1 generic argument"), but I was able to cherry-pick the changes on top of 0.28.0-rc1 and use the new public api in minsc.

With this in place, minsc now allows to construct custom taproot trees like in the first example (previously only huffman trees were supported, like in the second).

@tcharding

Copy link
Copy Markdown
Member

Legend @shesek, thank you.

This allows users to create TaprootSpendInfo using NodeInfo. This
offers an alternative to TaprootBuilder.
@sanket1729

sanket1729 commented Mar 28, 2022 •

Copy link
Copy Markdown
Member Author

The NodeInfo struct is now public but the fields are private and there are no getters/setters, are users able to use this struct as expected?

I have only made the minimal things pub so that the above example in the PR description works. Thankfully, Shesek is able to confirm that this works.

I noticed that non of the util::taproot types are re-exported out of util, is that what we want?

I don't have super strong opinions about this. But I have a preference that these should be re-exported from util. If we have an established convention, I would be happy to adhere to it. So far, I see some things are re-exported out of util and some are not (eg sighash module). I also support pub use util::* in lib.rs.

I am about to try and do the 'add taproot example' issue, perhaps I'll add a bunch of rustdoc examples to the taproot module to test the public API?

Yes, please. I will also make a point to add rustdoc examples for future APIs. They are really handy.

@sanket1729

Copy link
Copy Markdown
Member Author

Force pushed again addressing all the doc-comment nits.

@tcharding

Copy link
Copy Markdown
Member

ACK all the docs stuff, I have more docs fixes for the taproot module queued up. From my perspective we can put this one in and I"ll rebase on top of it. FTR I hadn't done that PR this morning when I requested changes on this one :) Thanks.

@dr-orlovsky dr-orlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 208eb65

@dr-orlovsky

Copy link
Copy Markdown
Collaborator

@shesek I did a PR rust-bitcoin/rust-miniscript#324 that brings miniscript on the version of rust-bitcoin having all RC fixes merged, such that downstream can test and fix all APIs. Even if non-merged RC-fix PRs here will be modified, it will be a very tiny changes.

So, you can add this section to all of your projects:

[patch.crates-io]
bitcoin = { git = "https://github.com/LNP-BP/rust-bitcoin", branch = "canary" }
miniscript = { git = "https://github.com/LNP-BP/rust-miniscript", branch = "canary" }

@apoelstra apoelstra 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.

ACK 208eb65

Yeah, we can get a release out before Miami. I think today?

@apoelstra
apoelstra merged commit 10949b7 into rust-bitcoin:master Mar 28, 2022
shesek added a commit to shesek/minsc that referenced this pull request Apr 5, 2022
For example:

    H_POINT+[
      pk(A),
      [
        `1 OP_ADD 2 OP_EQUAL`,
        0x51
      ]
    ]

Depends on rust-bitcoin/rust-bitcoin#910
loop-ghost5rty added a commit to loop-ghost5rty/minsc that referenced this pull request Sep 28, 2025
For example:

    H_POINT+[
      pk(A),
      [
        `1 OP_ADD 2 OP_EQUAL`,
        0x51
      ]
    ]

Depends on rust-bitcoin/rust-bitcoin#910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

one ack PRs that have one ACK, so one more can progress them trivial Obvious, easy and quick to review (few lines or doc-only...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants