Skip to content

WitnessVersion type#617

Merged
apoelstra merged 2 commits intorust-bitcoin:masterfrom
BP-WG:feat/witness-version
Sep 8, 2021
Merged

WitnessVersion type#617
apoelstra merged 2 commits intorust-bitcoin:masterfrom
BP-WG:feat/witness-version

Conversation

@dr-orlovsky
Copy link
Copy Markdown
Collaborator

Reopening as a new PR to #562 (github does not allow to re-open force-pushed branches) since there might be changes during the review at this level unrelated to #563 (which will be in draft mode until this is merged - and rebased after the merge)

@dr-orlovsky dr-orlovsky added the API break This PR requires a version bump for the next release label Jun 13, 2021
@dr-orlovsky dr-orlovsky added this to the 0.27.0 milestone Jun 13, 2021
This was referenced Jun 13, 2021
sgeisler
sgeisler previously approved these changes Jun 13, 2021
Copy link
Copy Markdown
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

utACK 3645c6353757a1771799a7ec35bd1a29d34538c3

Looks pretty good. I really like the function documentation describing all error cases applicable to the function (especially when it's only a subset of the error enum).

Copy link
Copy Markdown
Contributor

@jrawsthorne jrawsthorne left a comment

Choose a reason for hiding this comment

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

You mentioned here about using WitnessVersion in the is_* methods on Script. Don't know if you want to do that here.

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

@jrawsthorne well, tried that and it looks like it adds a lot more code instead of simplifying functions. So just made it for only is_witness_program and not the rest of is_* methods (which will require error testing instead of simple opcode equivalence test used now)

Copy link
Copy Markdown
Member

@clarkmoody clarkmoody left a comment

Choose a reason for hiding this comment

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

I prefer this approach, since it "makes impossible states impossible." I've just got a couple preference nits.

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: use num instead of no for a number variable? Also, this function would probably be better named from_u8

Copy link
Copy Markdown
Collaborator Author

@dr-orlovsky dr-orlovsky Jun 14, 2021

Choose a reason for hiding this comment

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

It was originally named from_u8, but later I decided it is a bad name, since there are two different u8-based representations for witness version: by script byte (0, 0x51-0x60) and as version number (incremental from 0 to 16). So while I'm fine with using from_num instead of from_no, it will be confusing to use from_u8.

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.

Possibly raw_num or raw_u8?

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.

+1 for num instead of no

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: I would prefer into_u8

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Commented above: the same reason for the naming here

Kixunil
Kixunil previously approved these changes Jun 14, 2021
Copy link
Copy Markdown
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

Just a few doc suggestions.

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.

Did you mean to say "if a plain u8 type was used instead it would mean that version may be > 16, which is incorrect"?

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.

I believe s.parse::<u8>() is considered idiomatic.

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.

Not a native speaker but the original seemed correct. The rules check if the address is standard.

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.

Agreed.

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

Addressed all suggestions with a separate commit

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: "was be"

sanket1729
sanket1729 previously approved these changes Jun 16, 2021
Copy link
Copy Markdown
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ack 4ecfd689d1fa8da4aed9d9a265f73c1ef3f1160f

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

Needed rebase, merged master into this branch so the review will not require to go through all commits again. Also fixed @Kixunil nit in docs.

Ned re-ACK from @sanket1729 and review from @apoelstra before the merge since this is intrusive and important change

@dr-orlovsky dr-orlovsky requested a review from sanket1729 June 27, 2021 12:43
sgeisler
sgeisler previously approved these changes Jun 27, 2021
Copy link
Copy Markdown
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

utACK 409cb919c5586b5fb39bd72dba3b73e433c379ad

sgeisler
sgeisler previously approved these changes Jun 27, 2021
Copy link
Copy Markdown
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

utACK 8a99a3fddce43001223774fe0d58dfc1457394bb

@apoelstra
Copy link
Copy Markdown
Member

Can you clean up the history by removing the merge commit and rebasing on top of master?

@apoelstra
Copy link
Copy Markdown
Member

ack 8a99a3fddce43001223774fe0d58dfc1457394bb aside from history

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

@apoelstra done

sanket1729
sanket1729 previously approved these changes Aug 1, 2021
Copy link
Copy Markdown
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK a8571f24cb3d50289acc86a6fe72f4ecc615cee8

@dr-orlovsky
Copy link
Copy Markdown
Collaborator Author

@sanket1729 @sgeisler had to force-push due to conflicts with recent merges. Re-ACK will be highly appreciated

Copy link
Copy Markdown
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

re-ACK ecc4008

Just looked at the diff-diff using git range-diff 8a99a3f...ecc400826c5eebf4c8bf3f28219af348a1ba0191

@apoelstra
Copy link
Copy Markdown
Member

re-utACK ecc4008

Copy link
Copy Markdown
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK ecc4008

@apoelstra apoelstra merged commit 2a655f4 into rust-bitcoin:master Sep 8, 2021
@dr-orlovsky dr-orlovsky mentioned this pull request Sep 29, 2021
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API break This PR requires a version bump for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants