Remove rust-ordered dependency

It has turned out that the `rust-ordered` crate and it's
`ArbitraryOrd` trait are only useful for locktimes and only marginally
useful for them at best.

Remove the `ArbitraryOrd` impls and the `rust-ordered` dependency.

This topic was discussed in various places including:

- #2500
- #4002
- #3881

Close: #4029
This commit is contained in:
Tobin C. Harding 2025-02-18 13:31:24 +11:00
parent d392cdbd7d
commit 4259dab93a
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
9 changed files with 5 additions and 60 deletions

View File

@ -62,7 +62,6 @@ dependencies = [
"bitcoinconsensus", "bitcoinconsensus",
"hex-conservative 0.3.0", "hex-conservative 0.3.0",
"hex_lit", "hex_lit",
"ordered",
"secp256k1", "secp256k1",
"serde", "serde",
"serde_json", "serde_json",
@ -111,7 +110,6 @@ dependencies = [
"bitcoin-units", "bitcoin-units",
"bitcoin_hashes 0.16.0", "bitcoin_hashes 0.16.0",
"hex-conservative 0.3.0", "hex-conservative 0.3.0",
"ordered",
"serde", "serde",
"serde_json", "serde_json",
] ]
@ -254,12 +252,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ordered"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79c12388aac4f817eae0359011d67d4072ed84cfc63b0d9a7958ef476fb74bec"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.8" version = "0.2.8"

View File

@ -61,7 +61,6 @@ dependencies = [
"bitcoinconsensus", "bitcoinconsensus",
"hex-conservative 0.3.0", "hex-conservative 0.3.0",
"hex_lit", "hex_lit",
"ordered",
"secp256k1", "secp256k1",
"serde", "serde",
"serde_json", "serde_json",
@ -110,7 +109,6 @@ dependencies = [
"bitcoin-units", "bitcoin-units",
"bitcoin_hashes 0.16.0", "bitcoin_hashes 0.16.0",
"hex-conservative 0.3.0", "hex-conservative 0.3.0",
"ordered",
"serde", "serde",
"serde_json", "serde_json",
] ]
@ -262,12 +260,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ordered"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79c12388aac4f817eae0359011d67d4072ed84cfc63b0d9a7958ef476fb74bec"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.20" version = "0.2.20"

View File

@ -39,7 +39,6 @@ arbitrary = { version = "1.4", optional = true }
base64 = { version = "0.22.0", optional = true } base64 = { version = "0.22.0", optional = true }
# `bitcoinconsensus` version includes metadata which indicates the version of Core. Use `cargo tree` to see it. # `bitcoinconsensus` version includes metadata which indicates the version of Core. Use `cargo tree` to see it.
bitcoinconsensus = { version = "0.106.0", default-features = false, optional = true } bitcoinconsensus = { version = "0.106.0", default-features = false, optional = true }
ordered = { version = "0.4.0", optional = true }
serde = { version = "1.0.103", default-features = false, features = [ "derive", "alloc" ], optional = true } serde = { version = "1.0.103", default-features = false, features = [ "derive", "alloc" ], optional = true }
[dev-dependencies] [dev-dependencies]

View File

@ -5,10 +5,10 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
# Test all these features with "std" enabled. # Test all these features with "std" enabled.
FEATURES_WITH_STD="rand-std serde secp-recovery bitcoinconsensus base64 ordered arbitrary" FEATURES_WITH_STD="rand-std serde secp-recovery bitcoinconsensus base64 arbitrary"
# Test all these features without "std" or "alloc" enabled. # Test all these features without "std" or "alloc" enabled.
FEATURES_WITHOUT_STD="rand serde secp-recovery bitcoinconsensus base64 ordered arbitrary" FEATURES_WITHOUT_STD="rand serde secp-recovery bitcoinconsensus base64 arbitrary"
# Run these examples. # Run these examples.
EXAMPLES="ecdsa-psbt:std,bitcoinconsensus sign-tx-segwit-v0:rand-std sign-tx-taproot:rand-std taproot-psbt:bitcoinconsensus,rand-std sighash:std" EXAMPLES="ecdsa-psbt:std,bitcoinconsensus sign-tx-segwit-v0:rand-std sign-tx-taproot:rand-std taproot-psbt:bitcoinconsensus,rand-std sighash:std"

View File

@ -16,7 +16,6 @@
//! * `base64` (dependency) - enables encoding of PSBTs and message signatures. //! * `base64` (dependency) - enables encoding of PSBTs and message signatures.
//! * `bitcoinconsensus` (dependency) - enables validating scripts and transactions. //! * `bitcoinconsensus` (dependency) - enables validating scripts and transactions.
//! * `default` - enables `std` and `secp-recovery`. //! * `default` - enables `std` and `secp-recovery`.
//! * `ordered` (dependency) - adds implementations of `ArbitraryOrd` to some structs.
//! * `rand` (transitive dependency) - makes it more convenient to generate random values. //! * `rand` (transitive dependency) - makes it more convenient to generate random values.
//! * `rand-std` - same as `rand` but also enables `std` here and in `secp256k1`. //! * `rand-std` - same as `rand` but also enables `std` here and in `secp256k1`.
//! * `serde` (dependency) - implements `serde`-based serialization and deserialization. //! * `serde` (dependency) - implements `serde`-based serialization and deserialization.
@ -80,10 +79,6 @@ pub extern crate hex;
/// Re-export the `bitcoin-io` crate. /// Re-export the `bitcoin-io` crate.
pub extern crate io; pub extern crate io;
/// Re-export the `ordered` crate.
#[cfg(feature = "ordered")]
pub extern crate ordered;
/// Re-export the `rust-secp256k1` crate. /// Re-export the `rust-secp256k1` crate.
/// ///
/// Rust wrapper library for Pieter Wuille's libsecp256k1. Implements ECDSA and BIP-340 signatures /// Rust wrapper library for Pieter Wuille's libsecp256k1. Implements ECDSA and BIP-340 signatures

View File

@ -28,7 +28,6 @@ internals = { package = "bitcoin-internals", version = "0.4.0" }
units = { package = "bitcoin-units", version = "0.2.0", default-features = false } units = { package = "bitcoin-units", version = "0.2.0", default-features = false }
arbitrary = { version = "1.4", optional = true } arbitrary = { version = "1.4", optional = true }
ordered = { version = "0.4.0", optional = true }
serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"], optional = true }
[dev-dependencies] [dev-dependencies]

View File

@ -5,10 +5,10 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
# Test these features with "std" enabled. # Test these features with "std" enabled.
FEATURES_WITH_STD="ordered serde arbitrary" FEATURES_WITH_STD="serde arbitrary"
# Test these features without "std" enabled. # Test these features without "std" enabled.
FEATURES_WITHOUT_STD="alloc ordered serde arbitrary" FEATURES_WITHOUT_STD="alloc serde arbitrary"
# Run these examples. # Run these examples.
EXAMPLES="" EXAMPLES=""

View File

@ -5,7 +5,6 @@
//! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by //! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by
//! whether `LockTime < LOCKTIME_THRESHOLD`. //! whether `LockTime < LOCKTIME_THRESHOLD`.
use core::cmp::Ordering;
use core::fmt; use core::fmt;
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
@ -33,8 +32,7 @@ pub use units::locktime::absolute::{ConversionError, Height, ParseHeightError, P
/// ///
/// For [`Transaction`], which has a locktime field, we implement a total ordering to make /// For [`Transaction`], which has a locktime field, we implement a total ordering to make
/// it easy to store transactions in sorted data structures, and use the locktime's 32-bit integer /// it easy to store transactions in sorted data structures, and use the locktime's 32-bit integer
/// consensus encoding to order it. We also implement [`ordered::ArbitraryOrd`] if the "ordered" /// consensus encoding to order it.
/// feature is enabled.
/// ///
/// ### Relevant BIPs /// ### Relevant BIPs
/// ///
@ -389,20 +387,6 @@ impl<'de> serde::Deserialize<'de> for LockTime {
} }
} }
#[cfg(feature = "ordered")]
impl ordered::ArbitraryOrd for LockTime {
fn arbitrary_cmp(&self, other: &Self) -> Ordering {
use LockTime::*;
match (self, other) {
(Blocks(_), Seconds(_)) => Ordering::Less,
(Seconds(_), Blocks(_)) => Ordering::Greater,
(Blocks(this), Blocks(that)) => this.cmp(that),
(Seconds(this), Seconds(that)) => this.cmp(that),
}
}
}
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for LockTime { impl<'a> Arbitrary<'a> for LockTime {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {

View File

@ -5,8 +5,6 @@
//! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by //! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by
//! whether bit 22 of the `u32` consensus value is set. //! whether bit 22 of the `u32` consensus value is set.
#[cfg(feature = "ordered")]
use core::cmp::Ordering;
use core::{convert, fmt}; use core::{convert, fmt};
use crate::Sequence; use crate::Sequence;
@ -370,20 +368,6 @@ impl fmt::Display for LockTime {
} }
} }
#[cfg(feature = "ordered")]
impl ordered::ArbitraryOrd for LockTime {
fn arbitrary_cmp(&self, other: &Self) -> Ordering {
use LockTime::*;
match (self, other) {
(Blocks(_), Time(_)) => Ordering::Less,
(Time(_), Blocks(_)) => Ordering::Greater,
(Blocks(this), Blocks(that)) => this.cmp(that),
(Time(this), Time(that)) => this.cmp(that),
}
}
}
impl convert::TryFrom<Sequence> for LockTime { impl convert::TryFrom<Sequence> for LockTime {
type Error = DisabledLockTimeError; type Error = DisabledLockTimeError;
fn try_from(seq: Sequence) -> Result<LockTime, DisabledLockTimeError> { fn try_from(seq: Sequence) -> Result<LockTime, DisabledLockTimeError> {