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

View File

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

View File

@ -39,7 +39,6 @@ arbitrary = { version = "1.4", 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 = "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 }
[dev-dependencies]

View File

@ -5,10 +5,10 @@
# shellcheck disable=SC2034
# 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.
FEATURES_WITHOUT_STD="rand serde secp-recovery bitcoinconsensus base64 ordered arbitrary"
FEATURES_WITHOUT_STD="rand serde secp-recovery bitcoinconsensus base64 arbitrary"
# 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"

View File

@ -16,7 +16,6 @@
//! * `base64` (dependency) - enables encoding of PSBTs and message signatures.
//! * `bitcoinconsensus` (dependency) - enables validating scripts and transactions.
//! * `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-std` - same as `rand` but also enables `std` here and in `secp256k1`.
//! * `serde` (dependency) - implements `serde`-based serialization and deserialization.
@ -80,10 +79,6 @@ pub extern crate hex;
/// Re-export the `bitcoin-io` crate.
pub extern crate io;
/// Re-export the `ordered` crate.
#[cfg(feature = "ordered")]
pub extern crate ordered;
/// Re-export the `rust-secp256k1` crate.
///
/// 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 }
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 }
[dev-dependencies]

View File

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

View File

@ -5,7 +5,6 @@
//! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by
//! whether `LockTime < LOCKTIME_THRESHOLD`.
use core::cmp::Ordering;
use core::fmt;
#[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
/// 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"
/// feature is enabled.
/// consensus encoding to order it.
///
/// ### 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")]
impl<'a> Arbitrary<'a> for LockTime {
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
//! whether bit 22 of the `u32` consensus value is set.
#[cfg(feature = "ordered")]
use core::cmp::Ordering;
use core::{convert, fmt};
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 {
type Error = DisabledLockTimeError;
fn try_from(seq: Sequence) -> Result<LockTime, DisabledLockTimeError> {