Re-work sighash type conversion methods#796
Conversation
|
This is also good, I also wouldn't mind nuking the inner method. Your preference. |
sanket1729
left a comment
There was a problem hiding this comment.
utACK 5efa0067344cbc9b03cc6c5f70729254e82a04c5
|
Let's nuke it :) |
sanket1729
left a comment
There was a problem hiding this comment.
ACK bec898e055d3b4024aa5221396dd5153b426557c
Kixunil
left a comment
There was a problem hiding this comment.
I think this deserves at least a comment but wouldn't block it.
apoelstra
left a comment
There was a problem hiding this comment.
ACK f627f67626f3640af01c368094043a83e7d95c5c
|
@apoelstra please re-ack, if you agree, PR now uses |
Kixunil
left a comment
There was a problem hiding this comment.
ACK bb17582862146bdb83611e54c917e845f7a4241c
apoelstra
left a comment
There was a problem hiding this comment.
ACK bb17582862146bdb83611e54c917e845f7a4241c
I think the new name is a good idea, given our current crappy handling of non-standard flags.
|
ouch, I was on the wrong branch and rebased on master. Sorry fellas, no changes made. Please re-ack and give me a virtual slap. |
Kixunil
left a comment
There was a problem hiding this comment.
ACK 9de614e6d9914194020861765c3739ce8e1cfcbc
apoelstra
left a comment
There was a problem hiding this comment.
ACK 9de614e6d9914194020861765c3739ce8e1cfcbc
|
I believe this one should go in before we do the taproot release, friendly bump :) |
|
Thanks for the bump, I have been exclusively looking at taproot release PRs. Feel free to tag me for review. I will look at your amazing PRs soon :) , but so far I was only tunnel visioning on 0.28 milestone. I missed the RC fix label. Edit: Phone autocorrect "amazing PRs" to |
This is not true. It is possible to have non-standard values if they are explicitly constructed from serialize::Deserialize with non-standard u32. I would rather it be called The purpose of |
|
Ok, given @sanket1729's comments I rescind my ACK |
This sounds massively broken. Either we should enforce it's standard in all constructors or in neither. I believe we agreed standard is better? |
ff811c5 to
9b1ee35
Compare
|
Changes in force push:
While checking over the diff before force pushing I noticed that this PR adds a |
|
This PR had a bunch of unrelated changes to the |
sanket1729
left a comment
There was a problem hiding this comment.
ACK 51ac67356d6b581a99f4775546962a964c18b77b. In the interest of moving things forward, I think we should merge this after it meets the requirements(2 ACKs and no Nacks/comments for other reviewers).
We can address @Kixunil new comments in follow-up PR after the next RC or if required in the next breaking release.
|
ACK 51ac67356d6b581a99f4775546962a964c18b77b Not merging yet to give @apoelstra and @Kixunil another day to comment. |
|
ouh, this now requires rebase :( :( :( |
|
I think we should focus on getting this in before any other merge now :) |
We have conversion functions that include suffixes `_consensus` and `_standard` to make it explicit what guarantees are provided by the returned `u32` value. The `From` implementation reduces the clarity of the API.
Rust naming conventions stipulate that conversion methods from owned -> owned for `Copy` types use the naming convention `to_`. This change makes the function name objectively better, however it makes no claims of being the 'best' name. We have had much discussion on using `to_standard` vs `to_u32` but are unable to reach consensus.
`EcdsaSigHashType::from_u32` was deprecated in v0.26, since we are working on the v0.28 release we can drop this method.
The functions `from_u32_standard` and `from_u32_consensus` smell a bit like hungarian notation. We can look at the method definition to see that the methods accept `u32` arguments without mentioning that in the method names. Remove `_u32_` from the method names. This brings the `from_*` methods in line with the `to_standard` method also.
Improve the `PsbtSigHashType` conversion methods by doing: - Re-name `inner` -> `to_u32` as per Rust convention - Add `from_u32` method Note, we explicitly do _not_ use suffix 'consensus' because these conversion methods make no guarantees about the validity of the underlying `u32`.
It is possible, although not immediately obvious, that it is possible to create a `PsbtSigHashType` with a non-standard value. Add a unit test to show this and also catch any regressions if we accidental change this logic.
|
Force push is rebase only, no other changes. |
|
@Kixunil where have you gone man, are you ok with this one? Its not perfect but is it acceptable? |
|
Merging now: if there will be major comments from other reviewers will do a follow-up PR. We waited for more than a week for the comments already. |
|
BOOM! |
c3d30d5 Remove deprecated method use for sighash conversion (Dr. Maxim Orlovsky) Pull request description: Post-merge #796 follow-up. Feel free to add other changes/nits which hadn't get into #796. ACKs for top commit: tcharding: ACK c3d30d5 sanket1729: ACK c3d30d5 apoelstra: ACK c3d30d5 Tree-SHA512: 7418f90bad9ce43b5504a3e45f06fecd636f62f2f7bd75bfc27e29faa181202595ed9b5175866e0fce01a301ea34c2b07afb16e658757215823965e7e1440c2e
This PR has evolved into a full blown clean up of the conversion methods for all three sighash types based on the discussion below.
Everything is split up into very small patches to aid review (and bikeshedding, this PR is almost totally just naming things).
EDIT: I'm not convinced this should be an RC-fix, the changes are too wide spread now. It started as just a single method rename. Leaving label as is for others to consider.