From caf2f1a325ff08d56494cef9b4d3d98aa70485b8 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Fri, 6 Sep 2024 08:27:50 +0200 Subject: [PATCH 1/6] Deprecate the `hashes` reexport We don't use `hashes` in public API and we also use ranged version which makes items accessed through the reexport to break on `cargo update`. We want to remove it eventually, so deprecate it first. --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 20ff5d44e..17756f42e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,8 +153,12 @@ extern crate core; #[cfg(bench)] extern crate test; +/// Deprecated reexport of the `bitcoin-hashes` crate. #[cfg(feature = "hashes")] -pub extern crate hashes; +#[deprecated(since = "TBD", note = "Depend on `hashes` in your own crate.")] +pub mod hashes { + pub use ::hashes::*; +} #[macro_use] mod macros; From ad69619e151024d0fe61e76384da2cefc49df3cb Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Fri, 6 Sep 2024 08:29:28 +0200 Subject: [PATCH 2/6] Fix the `hashes` dependency range. Use of `<= 0.14` was wrong because it would prevent upgrading to 0.14.1+ We expand the range by using `< 0.15` instead. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a1958d945..bf78b3982 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ serde = { version = "1.0.103", default-features = false, optional = true } # You likely only want to enable these if you explicitly do not want to use "std", otherwise enable # the respective -std feature e.g., hashes-std -hashes = { package = "bitcoin_hashes", version = ">= 0.12, <= 0.14", default-features = false, optional = true } +hashes = { package = "bitcoin_hashes", version = ">= 0.12, < 0.15", default-features = false, optional = true } rand = { version = "0.8", default-features = false, optional = true } [dev-dependencies] From 938dba6e02c77191457568f5887aa632a5d30222 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Wed, 3 Jul 2024 06:02:12 +0200 Subject: [PATCH 3/6] Whitelist known cfgs Rust is now checking cfg attributes for typos but this interferes with our cfgs that rustc/cargo don't recognize. This whitelists them so they no longer produce warnings. This is a backport of 614fe817 because the warnings make development very annoying. --- Cargo.toml | 2 ++ secp256k1-sys/Cargo.toml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index bf78b3982..38b2dcb86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,8 @@ bincode = "1.3.3" wasm-bindgen-test = "0.3" getrandom = { version = "0.2", features = ["js"] } +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] } [[example]] name = "sign_verify_recovery" diff --git a/secp256k1-sys/Cargo.toml b/secp256k1-sys/Cargo.toml index 5d591ffcb..1ca432045 100644 --- a/secp256k1-sys/Cargo.toml +++ b/secp256k1-sys/Cargo.toml @@ -32,3 +32,6 @@ recovery = [] lowmemory = [] std = ["alloc"] alloc = [] + +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] } From 05c5937aa59693505d4a648886a64af8b4aabb5e Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Wed, 3 Jul 2024 06:43:40 +0200 Subject: [PATCH 4/6] Update panic message handling The newest nightly stabilized `PanicMessage` with a slightly different API. This updates the API and removes the `#![feature()]` attribute. --- no_std_test/src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/no_std_test/src/main.rs b/no_std_test/src/main.rs index eb3871f47..e93c2eb09 100644 --- a/no_std_test/src/main.rs +++ b/no_std_test/src/main.rs @@ -29,7 +29,6 @@ #![feature(start)] #![feature(core_intrinsics)] -#![feature(panic_info_message)] #![feature(alloc_error_handler)] #![no_std] extern crate libc; @@ -48,7 +47,7 @@ extern crate wee_alloc; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; -use core::fmt::{self, write, Write}; +use core::fmt::{self, Write}; use core::intrinsics; use core::panic::PanicInfo; @@ -170,9 +169,9 @@ impl Write for Print { #[panic_handler] fn panic(info: &PanicInfo) -> ! { unsafe { libc::printf("shi1\n\0".as_ptr() as _) }; - let msg = info.message().unwrap(); + let msg = info.message(); let mut buf = Print::new(); - write(&mut buf, *msg).unwrap(); + write!(&mut buf, "{}", msg).unwrap(); buf.print(); intrinsics::abort() } From 7ad2f2e53a958aa3c11bc662727a489a906ddfbe Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Wed, 3 Jul 2024 05:46:18 +0200 Subject: [PATCH 5/6] Don't use `core::i32::MAX` This is a legacy constant and it's better to just use `i32::MAX`. Note that one cannot `use` an associated constant so this just removed the import. This is better anyway since it's only used once and it didn't provide meaningful line length reduction. --- src/key.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/key.rs b/src/key.rs index 012f09d36..9a868980d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -638,10 +638,9 @@ impl PublicKey { /// # } /// ``` pub fn combine_keys(keys: &[&PublicKey]) -> Result { - use core::i32::MAX; use core::mem::transmute; - if keys.is_empty() || keys.len() > MAX as usize { + if keys.is_empty() || keys.len() > i32::MAX as usize { return Err(InvalidPublicKeySum); } From f74877a5011de973fe9c56c1c43440c8024d8fd6 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Fri, 6 Sep 2024 08:42:41 +0200 Subject: [PATCH 6/6] Release version 0.29.1 --- CHANGELOG.md | 9 +++++++++ Cargo-minimal.lock | 2 +- Cargo-recent.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc561427..c2d71383e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 0.29.1 - 2024-09-06 + +* Deprecate `hashes` reexport + + Because the reexport can have any of the *incompatible* versions using it is prone to breakage. + The `bitcoin_hashes` crate is not used in our API anyway, so you should just depend on it yourself + using a version range that's appropriate for your crate. +* Fix version range of the `bitcoin_hashes` crate. + # 0.29.0 - 2024-04-02 * Deprecate `ThirtyTwoByteHash` [#686](https://github.com/rust-bitcoin/rust-secp256k1/pull/686) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index 209baba14..b3e2cc9df 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -257,7 +257,7 @@ checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" dependencies = [ "bincode", "bitcoin_hashes", diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 86a3094e5..eafcab858 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -178,7 +178,7 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" dependencies = [ "bincode", "bitcoin_hashes", diff --git a/Cargo.toml b/Cargo.toml index 38b2dcb86..39c170aa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" authors = [ "Dawid Ciężarkiewicz ", "Andrew Poelstra " ] license = "CC0-1.0" diff --git a/src/lib.rs b/src/lib.rs index 17756f42e..39b6713f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,7 +155,7 @@ extern crate test; /// Deprecated reexport of the `bitcoin-hashes` crate. #[cfg(feature = "hashes")] -#[deprecated(since = "TBD", note = "Depend on `hashes` in your own crate.")] +#[deprecated(since = "0.29.1", note = "Depend on `hashes` in your own crate.")] pub mod hashes { pub use ::hashes::*; }