Prepare moving script types to primitives#3194
Prepare moving script types to primitives#3194apoelstra merged 6 commits intorust-bitcoin:masterfrom
primitives#3194Conversation
15d7d50 to
1044774
Compare
|
🚨 API BREAKING CHANGE DETECTED |
1044774 to
bf40359
Compare
|
🚨 API BREAKING CHANGE DETECTED |
bf40359 to
4d5121d
Compare
|
🚨 API BREAKING CHANGE DETECTED |
4d5121d to
0c828ce
Compare
|
🚨 API BREAKING CHANGE DETECTED |
0c828ce to
f1729f2
Compare
|
🚨 API BREAKING CHANGE DETECTED |
729cea4 to
126cfcf
Compare
|
🚨 API BREAKING CHANGE DETECTED |
1 similar comment
|
🚨 API BREAKING CHANGE DETECTED |
In preparation for moving the `Script` type to `primitives` stop accessing the inner field before doing slice operations, use `as_bytes` to first get at the slice.
In preparation for moving the `ScriptBuf` type to `primitives` stop accessing the inner field when encoding/decoding, use `as_script` and `from_bytes` instead.
The `Builder` is staying in `bitcoin` while the `ScriptBuf` is moving to `primitives`, so we cannot access the inner field of `ScriptBuf`. Use the new `as_byte_vec` hack to mutate the inner `ScriptBuf` field.
The optional dependencies are ordered and separated by whitspace in a manner that may not be obvious (or even have a reason). Some of this is because since use of `?` deps changed name. Put all the optional deps together in alphabetic order.
f73dd77 to
e234ab6
Compare
|
I'm not exactly sure how you guys are supposed to review this without just trusting that I did indeed cutn'pasta the script impl blocks. I guess you could copy the impl blocks from master locally and check you git index is dirty/clean as expected. |
|
🚨 API BREAKING CHANGE DETECTED To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section. |
primitivesprimitives
Here's a secret trick for you and anyone else who wants to review such things:
Speaking of tricks, this is my entire git configuration
[merge]
conflictstyle = diff3
[diff]
colorMoved = zebra
[rerere]
enabled = true
[merge "rust-merge"]
name = Rust merge
driver = rust-merge %O %A %B %A
|
|
@Kixunil there is an additional option I learned recently. In and this will even do the move-coloring when the indentation has changed (which would eliminate the need for the silly "dummy module" commits in these PRs). I don't know when this option was added. I don't think it existed a few years ago. |
apoelstra
left a comment
There was a problem hiding this comment.
ACK e234ab6f5d2f5369d1811d539ef595b1df8181de successfully ran local tests
|
I can't come up with the quite the expression right now, but those config options are a total game changer. I haven't worked out exactly what all the colors mean yet but this is massive. The machine is now doing most of the review instead of us having to do it. Massive. |
Kixunil
left a comment
There was a problem hiding this comment.
NACK putting anything deprecated into primitives (&co) at all.
@tcharding suggestion for making the process more efficient: once you see this, immediately drop the top commit and force push the branch without changing hashes, rename the PR to "Prepare moving script types to primitives. Then I'll immediately ACK 8f2f4cb without any review because all those commits are fine. You can then in parallel address the requested changes and make a new PR that only moves (non-deprecated) stuff.
primitives/src/script/mod.rs
Outdated
There was a problem hiding this comment.
Nope, these two functions should no longer exists in primitives. They are a relic from the time when Script was Sized. Everything these do can and should be achieved using Display.
primitives/src/script/borrowed.rs
Outdated
There was a problem hiding this comment.
I think/hope pub(crate) won't be needed long term...
There was a problem hiding this comment.
In this case pub(super) would have been sufficient.
But even that isn't necessary because the two places that script.0 are called can be replaced with script.as_bytes.
There was a problem hiding this comment.
Oh, yeah, Box casting uses unsafe anyway.
|
Also this doesn't compile with |
I think we should just activate
|
|
There's another reason to activate Oh, crap, I had But now I see deprecation warnings. |
e234ab6 to
8f2f4cb
Compare
primitivesprimitives
|
Removed final patch as suggested, thanks for putting thought into how we can speed up the process @Kixunil |
d649c06 Move script types to primitives (Tobin C. Harding) ec46359 Inline bytes_to_asm_fmt into Script::Display impl (Tobin C. Harding) Pull request description: First patch removes `bytes_to_asm_fmt` as requested by Kix here: #3194 (comment) Second patch does the move. The move is minimal but there is quite a bit of code moved in `script/mod.rs` - I believe it is as minimal as required as well. ACKs for top commit: apoelstra: ACK d649c06 successfully ran local tests Tree-SHA512: 329a23948ac5617402a724b734d81cde8ab1f57ddd4860f858880618e260ea8b5cc89315de1fd93ae32787d5e8508fd604a41f003b1f5772a773b5b1648d382c
primitivesprimitives
Move the
ScriptandScriptBuftypes toprimitives. There were still a few preparations required, things we had missed while creating the extension traits.Note also please, in the last patch, we enable
hexfrom theserderfeature. This is not the final state we want but like we did forallocit is a step to reduce the size of the diff.