From f03f52a045d7b29898aad6b55af35f8985437556 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 21 Aug 2025 16:31:57 +0700 Subject: [PATCH 01/16] clean up --- dash/Cargo.toml | 11 +- dash/src/address.rs | 1 - dash/src/base58.rs | 10 +- dash/src/blockdata/locktime/absolute.rs | 4 - dash/src/blockdata/locktime/relative.rs | 7 - dash/src/blockdata/script/borrowed.rs | 4 - dash/src/blockdata/script/mod.rs | 45 - dash/src/blockdata/transaction/hash_type.rs | 2323 ----------------- dash/src/blockdata/transaction/mod.rs | 138 +- .../provider_registration.rs | 5 +- dash/src/crypto/key.rs | 61 +- dash/src/lib.rs | 5 +- dash/src/network/message_qrinfo.rs | 2 +- dash/src/pow.rs | 33 +- dash/src/signer.rs | 11 +- dash/src/sml/masternode_list/debug_helpers.rs | 2 +- .../message_request_verification.rs | 2 +- .../rotated_quorum_construction.rs | 2 +- dash/src/sml/quorum_entry/validation.rs | 8 +- 19 files changed, 92 insertions(+), 2582 deletions(-) delete mode 100644 dash/src/blockdata/transaction/hash_type.rs diff --git a/dash/Cargo.toml b/dash/Cargo.toml index d45f5e808..dd1e358c9 100644 --- a/dash/Cargo.toml +++ b/dash/Cargo.toml @@ -63,14 +63,12 @@ anyhow = { version= "1.0" } hex = { version= "0.4" } bincode = { version= "=2.0.0-rc.3", optional = true } bincode_derive = { version= "=2.0.0-rc.3", optional = true } -bitflags = "2.9.0" blsful = { git = "https://github.com/dashpay/agora-blsful", rev = "be108b2cf6ac64eedbe04f91c63731533c8956bc", optional = true } ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true } blake3 = "1.8.1" thiserror = "2" bitvec = "1.0" log = "0.4" -# bls-signatures removed during migration to agora-blsful [dev-dependencies] serde_json = "1.0.140" @@ -80,6 +78,8 @@ secp256k1 = { features = [ "recovery", "rand", "hashes" ], version="0.30.0" } bincode = { version= "=2.0.0-rc.3" } assert_matches = "1.5.0" dashcore = { path = ".", features = ["core-block-hash-use-x11", "message_verification", "quorum_validation", "signer"] } +criterion = "0.5" + [[example]] name = "handshake" @@ -92,3 +92,10 @@ required-features = ["std", "bitcoinconsensus"] [[example]] name = "taproot-psbt" required-features = ["std", "rand-std", "bitcoinconsensus"] + +[[bench]] +name = "transaction" +harness = false + +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(fuzzing)', 'cfg(kani)'] } diff --git a/dash/src/address.rs b/dash/src/address.rs index 01521c772..02c4ade0a 100644 --- a/dash/src/address.rs +++ b/dash/src/address.rs @@ -885,7 +885,6 @@ impl bincode::Encode for AddressType { &self, encoder: &mut E, ) -> Result<(), bincode::error::EncodeError> { - use bincode::Encode; (*self as u8).encode(encoder) } } diff --git a/dash/src/base58.rs b/dash/src/base58.rs index 30a2cb132..26ebb7cd4 100644 --- a/dash/src/base58.rs +++ b/dash/src/base58.rs @@ -52,6 +52,10 @@ pub enum Error { // TODO: Remove this as part of crate-smashing, there should not be any key related errors in this module Hex(hex::Error), + /// blsful related error + #[cfg(feature = "blsful")] + BLSError(String), + /// edwards 25519 related error #[cfg(feature = "ed25519-dalek")] Ed25519Dalek(String), @@ -77,6 +81,8 @@ impl fmt::Display for Error { Error::TooShort(_) => write!(f, "base58ck data not even long enough for a checksum"), Error::Secp256k1(ref e) => fmt::Display::fmt(&e, f), Error::Hex(ref e) => write!(f, "Hexadecimal decoding error: {}", e), + #[cfg(feature = "blsful")] + Error::BLSError(ref e) => write!(f, "BLS error: {}", e), #[cfg(feature = "ed25519-dalek")] Error::Ed25519Dalek(ref e) => write!(f, "Ed25519-Dalek error: {}", e), Error::NotSupported(ref e) => write!(f, "Not supported: {}", e), @@ -85,7 +91,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error {} +impl std::error::Error for Error {} /// Vector-like object that holds the first 100 elements on the stack. If more space is needed it /// will be allocated on the heap. @@ -417,7 +423,7 @@ impl From for Error { key::Error::InvalidKeyPrefix(_) => Error::Secp256k1(secp256k1::Error::InvalidPublicKey), key::Error::Hex(e) => Error::Hex(e), key::Error::InvalidHexLength(size) => Error::InvalidLength(size), - #[cfg(feature = "bls-signatures")] + #[cfg(feature = "blsful")] key::Error::BLSError(e) => Error::BLSError(e), #[cfg(feature = "ed25519-dalek")] key::Error::Ed25519Dalek(e) => Error::Ed25519Dalek(e), diff --git a/dash/src/blockdata/locktime/absolute.rs b/dash/src/blockdata/locktime/absolute.rs index 76dd90ebf..059750331 100644 --- a/dash/src/blockdata/locktime/absolute.rs +++ b/dash/src/blockdata/locktime/absolute.rs @@ -11,8 +11,6 @@ use core::cmp::{Ordering, PartialOrd}; use core::{fmt, mem}; use internals::write_err; -#[cfg(all(test, mutate))] -use mutagen::mutate; #[cfg(doc)] use crate::absolute; @@ -197,7 +195,6 @@ impl LockTime { /// } /// ```` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by(&self, height: Height, time: Time) -> bool { use LockTime::*; @@ -227,7 +224,6 @@ impl LockTime { /// assert!(lock_time.is_implied_by(check)); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_implied_by(&self, other: LockTime) -> bool { use LockTime::*; diff --git a/dash/src/blockdata/locktime/relative.rs b/dash/src/blockdata/locktime/relative.rs index 6d00dc191..56bd0f644 100644 --- a/dash/src/blockdata/locktime/relative.rs +++ b/dash/src/blockdata/locktime/relative.rs @@ -10,9 +10,6 @@ use core::convert::TryFrom; use core::fmt; -#[cfg(all(test, mutate))] -use mutagen::mutate; - use crate::parse::impl_parse_str_from_int_infallible; use crate::prelude::*; #[cfg(doc)] @@ -58,7 +55,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by(current_height(), current_time())); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by(&self, h: Height, t: Time) -> bool { if let Ok(true) = self.is_satisfied_by_height(h) { true @@ -93,7 +89,6 @@ impl LockTime { /// assert!(lock.is_implied_by(test_lock)); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_implied_by(&self, other: LockTime) -> bool { use LockTime::*; @@ -120,7 +115,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by_height(Height::from(height+1)).expect("a height")); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by_height(&self, h: Height) -> Result { use LockTime::*; @@ -146,7 +140,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by_time(Time::from_512_second_intervals(intervals + 10)).expect("a time")); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by_time(&self, t: Time) -> Result { use LockTime::*; diff --git a/dash/src/blockdata/script/borrowed.rs b/dash/src/blockdata/script/borrowed.rs index 1cf0c652c..d1b0a50b0 100644 --- a/dash/src/blockdata/script/borrowed.rs +++ b/dash/src/blockdata/script/borrowed.rs @@ -3,8 +3,6 @@ use core::convert::{TryFrom, TryInto}; use core::fmt; -#[cfg(rust_v_1_53)] -use core::ops::Bound; use core::ops::{Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive}; use hashes::Hash; @@ -556,5 +554,3 @@ delegate_index!( RangeInclusive, RangeToInclusive ); -#[cfg(rust_v_1_53)] -delegate_index!((Bound, Bound)); diff --git a/dash/src/blockdata/script/mod.rs b/dash/src/blockdata/script/mod.rs index e01c8c91d..bd31ff71d 100644 --- a/dash/src/blockdata/script/mod.rs +++ b/dash/src/blockdata/script/mod.rs @@ -49,7 +49,6 @@ //! is minimal but we may extend it in the future if needed. use alloc::rc::Rc; -#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))] use alloc::sync::Arc; use core::borrow::{Borrow, BorrowMut}; use core::cmp::Ordering; @@ -293,8 +292,6 @@ impl<'a> From<&'a Script> for Cow<'a, Script> { } } -/// Note: This will fail to compile on old Rust for targets that don't support atomics -#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))] impl<'a> From<&'a Script> for Arc