Support weight prediction in const context#1710
Merged
apoelstra merged 2 commits intorust-bitcoin:masterfrom Mar 19, 2023
Merged
Support weight prediction in const context#1710apoelstra merged 2 commits intorust-bitcoin:masterfrom
const context#1710apoelstra merged 2 commits intorust-bitcoin:masterfrom
Conversation
1402707 to
3790d13
Compare
Collaborator
Author
|
The failed test should be able to run tomorrow. |
apoelstra
previously approved these changes
Mar 17, 2023
Member
apoelstra
left a comment
There was a problem hiding this comment.
ACK 3790d1346a95bc95161bed5dbc35cc679782beec
3790d13 to
8f42f4c
Compare
Collaborator
Author
|
Just removed the empty line to satisfy rustfmt. |
tcharding
reviewed
Mar 17, 2023
Closed
512c6cf to
637bd94
Compare
Some smart contracts or simplified wallets statically know the sizes of transactions or inputs. The possible approaches to handling them so far were re-computing the values (and hoping the optimizer will const fold them) or using a simple constant which may be harder to understand and get right. It's much nicer to just use a `const` but our code didn't support it until now. This change adds methods that can compute the prediction in `const` context for Rust versions >= 1.46.0 which allow use of loops (and conditions but those could be workaround anyway). As a side effect of this, the change also adds `const` to `VarInt::len` in Rust 1.46+. While this one could be made unconditional using array trick it's probably not worth it because of the planned MSRV bump. Note: this commit is intentionally unformatted to make diff easier to understand. Formatting will be done in future commit.
This fixes indentatiion that was intentionally "messed up" to make code review easier.
637bd94 to
00b46d6
Compare
apoelstra
approved these changes
Mar 17, 2023
tcharding
approved these changes
Mar 19, 2023
apoelstra
added a commit
that referenced
this pull request
Mar 22, 2023
ffee8ad Bump version to v0.30.0 (Tobin C. Harding) Pull request description: Add changelog notes and bump the version number to v0.30.0. ## TODO - pre-merge - [x] Release `bitcoin_hashes` 0.12: #1694 - [x] Release secp 0.27: rust-bitcoin/rust-secp256k1#588 - rust-bitcoin/rust-secp256k1#590 - [x] Update `secp256k1` dependency to use newly released v0.27: #1714 - [x] Merge - ~#1696 - #1695 - #1111 - [x] If time permits merge these: - #1710 - #1705 - #1713 - [x] Set the release date in changelog header - [x] And merge these: - #1721 - #1720 - #1719 - #1717 ## TODO - post release - [ ] Release the blogpost: rust-bitcoin/www.rust-bitcoin.org#2 - ~Set the date in the blog post to match the date 0.30 is released~ ACKs for top commit: sanket1729: reACK ffee8ad Kixunil: ACK ffee8ad apoelstra: ACK ffee8ad Tree-SHA512: b0ea113ee1726fd9b263d0e01fe14bd544c007c05a9ac43b6c2d4edbeef3bb3ad456b061ef086626e1e1b27a0cda49cb6bc28aac3ad1691d72ffe00400ed5b45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes for reviewers:
This is something that I want to use in my code and hopefully reasonably easy to review, so if this can get into 0.30 that'd be really nice. No hard feelings if it doesn't.
I tried to put extra effort into making review easier by:
VarInt::lenand simply accepting the limitation of Rust 1.46+ (I use 1.48 BTW).Description
Some smart contracts or simplified wallets statically know the sizes of
transactions or inputs. The possible approaches to handling them so far
were re-computing the values (and hoping the optimizer will const fold
them) or using a simple constant which may be harder to understand and
get right. It's much nicer to just use a
constbut our code didn'tsupport it until now.
This change adds methods that can compute the prediction in
constcontext for Rust versions >= 1.46.0 which allow use of loops (and
conditions but those could be workaround anyway).
As a side effect of this, the change also adds
consttoVarInt::lenin Rust 1.46+. While this one could be made unconditional using array
trick it's probably not worth it because of the planned MSRV bump.