Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 42 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ members = [
resolver = "3"

[workspace.dependencies]
base58ck = { version = "0.4.0", default-features = false }
base58ck = { version = "0.5.0", default-features = false }
bitcoin_hashes = { version = "1.2.0", default-features = false }
bitcoin-consensus-encoding = { version = "1.2.0", default-features = false }
bitcoin-internals = { version = "0.6.0", default-features = false }
bitcoin-primitives = { version = "0.103.0", default-features = false }
bitcoin-units = { version = "0.5.0", default-features = false }
divan = "0.1"
hex-conservative = { version = "1.3", default-features = false }
rand_core = { version = "0.10.1", default-features = false }
rstest = "0.25"
serde = { version = "1", default-features = false }
subtle = { version = "2.6.1", default-features = false }
zeroize = { version = "1.9.0", default-features = false }

Expand Down
3 changes: 3 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ all-features = true
yanked = "deny"

[bans]
deny = [
{ crate = "hex-literal", reason = "use `hex_conservative` instead" },
]
multiple-versions = "warn"

[licenses]
Expand Down
4 changes: 2 additions & 2 deletions maint/codeql/rust/policy.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extensions:
# Crate-level re-exports a macro expands into, kept out of the public API
- ["", "__private", "", ""]
# Emits types relying on traits defined by a dependency, part of public API
- ["dash-num", "", "dash_types", "Numeric"]
- ["dash-num", "__deps", "dash_types", ""]
# Emits types relying on types or traits defined by a dependency, part of public API
- ["dash-pkc", "__deps", "blst", ""]
- ["dash-pkc", "__deps", "dash_num", ""]
Expand All @@ -55,4 +55,4 @@ extensions:
# Sub-crate isolation demands re-exports, part of public API
- ["dash-types", "", "dash_types_marker", ""]
# Emits types relying on types or traits defined by a dependency, part of public API
- ["dash-types", "", "zeroize", ""]
- ["dash-types", "__deps", "zeroize", ""]
14 changes: 7 additions & 7 deletions maint/lint/lint_cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def shorten(out: str, err: str) -> None:
)


def _check_yanked(repo_root: Path) -> int | None:
"""Fail on a yanked release, or None when cargo-deny is absent."""
def _check_deny(repo_root: Path) -> int | None:
"""Fail on a yanked or banned crate, or None when cargo-deny is absent."""
try:
deny_bin = require_bin("cargo-deny")
except FileNotFoundError as e:
print(f"{e}, skipping the yanked check", file=sys.stderr)
print(f"{e}, skipping the yanked and banned check", file=sys.stderr)
return None

print("checking yanked: every crate the graph resolves")
print("checking yanked and banned: every crate the graph resolves")
result = subprocess.run( # noqa: S603
[deny_bin, "check", "advisories"],
[deny_bin, "check", "--hide-inclusion-graph", "advisories", "bans"],
capture_output=True,
check=False,
cwd=str(repo_root),
Expand All @@ -101,7 +101,7 @@ def _check_yanked(repo_root: Path) -> int | None:

def main() -> int:
args = declare_verbs(
"Validate the crate graph against yanked releases.",
"Validate the crate graph against yanked releases and banned crates.",
{
"check": "report every fault, changing nothing",
"apply": f"also rewrite TOML this branch changed vs {DEFAULT_BASE}",
Expand All @@ -114,7 +114,7 @@ def main() -> int:

verdicts: list[int | None] = [
_check_format(repo_root, fix=fix, only=only),
_check_yanked(repo_root),
_check_deny(repo_root),
]
ran = [v for v in verdicts if v is not None]
if not ran:
Expand Down
2 changes: 1 addition & 1 deletion pkgs/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ clap = { version = "4", default-features = false, features = [
indicatif = { version = "0.18", default-features = false, optional = true }
json5 = { version = "0.4", optional = true }
rayon = { version = "1", optional = true }
serde = { version = "1", default-features = false, features = [
serde = { workspace = true, features = [
"derive",
"alloc",
], optional = true }
Expand Down
3 changes: 2 additions & 1 deletion pkgs/dev/src/bin/bsdk_util/bspcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::policy;
use crate::Application;

use dash_primitives::{Block, BlockHash, BlockInvalid};
use dash_types::codec::{BaseCodec, Checkable, DecodeError};
use dash_types::codec::{BaseCodec, DecodeError};
use dash_types::Checkable;
use indicatif::{ProgressBar, ProgressStyle};
use rayon::prelude::*;

Expand Down
3 changes: 2 additions & 1 deletion pkgs/dev/src/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use crate::prelude::*;

use bitcoin_consensus_encoding::{decode_from_slice, encode_to_vec, Decode, Decoder, Encode};
use dash_primitives::{Transaction, TxHash};
use dash_types::codec::{BaseCodec, Checkable, Hashable};
use dash_types::codec::BaseCodec;
use dash_types::{Checkable, Hashable};

use core::fmt::{Debug, Display};

Expand Down
2 changes: 2 additions & 0 deletions pkgs/num/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Removed

- `ParseHexError` has moved to `dash-types` as `dash_types::ParseHexError`.
- The `dash_types::Numeric` re-export in favour of a wholesale crate re-export. `dash_num::Numeric` imports must switch
to `dash_num::__deps::dash_types::Numeric` or depend on `dash-types` directly.

## [0.1.0-beta] - 2026-09-14

Expand Down
9 changes: 4 additions & 5 deletions pkgs/num/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ serde = [
bitcoin-consensus-encoding = { workspace = true, optional = true }
dash-types = { version = "0.1.0-beta", path = "../types", default-features = false }
hex-conservative = { workspace = true }
serde = { version = "1", default-features = false, features = [
serde = { workspace = true, features = [
"derive",
"alloc",
], optional = true }

[dev-dependencies]
dash-dev = { path = "../dev", features = ["full"] }
divan = "0.1"
hex-literal = "0.4"
rstest = "0.25"
serde = { version = "1", features = ["derive"] }
divan = { workspace = true }
rstest = { workspace = true }
serde = { workspace = true, features = ["derive", "std"] }

[[test]]
name = "hash"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/num/src/arith256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Arith256 {

/// Construct from big-endian bytes (consensus display order).
///
/// This is the natural byte order produced by `hex_literal::hex!()` when
/// This is the natural byte order produced by `hex_conservative::hex!()` when
/// given a consensus hex value. Internally the value is stored
/// little-endian, so this reverses the input before decoding.
///
Expand Down
2 changes: 1 addition & 1 deletion pkgs/num/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<const N: usize> HashBlob<N> {

/// Construct from big-endian bytes (consensus display order).
///
/// This is the natural byte order produced by `hex_literal::hex!()` when
/// This is the natural byte order produced by `hex_conservative::hex!()` when
/// given a block hash or other consensus hex value. Internally the bytes
/// are stored little-endian, so this reverses the input.
#[inline]
Expand Down
14 changes: 7 additions & 7 deletions pkgs/num/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ mod compact;
mod hash;
mod util;

#[doc(hidden)]
pub mod __deps {
pub use dash_types;
}
#[doc(hidden)]
pub mod __private {
#[cfg(feature = "codec")]
pub use bitcoin_consensus_encoding;
pub use dash_types;
#[cfg(feature = "serde")]
pub use serde;
}

pub use crate::arith256::Arith256;
pub use crate::compact::{CompactTarget, DecodedTarget};
pub use crate::hash::{Hash160, Hash256, HashBlob};

// TODO(kwvg): move to mod __deps with crate-level export
pub use dash_types::Numeric;
pub use arith256::Arith256;
pub use compact::{CompactTarget, DecodedTarget};
pub use hash::{Hash160, Hash256, HashBlob};
40 changes: 20 additions & 20 deletions pkgs/num/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ macro_rules! make_hash {
// The codec half, split out for gating with `cfg_codec!`.
(@codec $len:literal, $name:ident) => {
$crate::cfg_codec! {
impl $crate::__private::dash_types::codec::BaseCodec for $name {
impl $crate::__deps::dash_types::codec::BaseCodec for $name {
fn decode(
data: &mut &[u8],
) -> Result<Self, $crate::__private::dash_types::codec::DecodeError> {
$crate::__private::dash_types::codec::take::<$len>(data)
.map(<Self as $crate::__private::dash_types::Numeric>::from_lendian)
) -> Result<Self, $crate::__deps::dash_types::codec::DecodeError> {
$crate::__deps::dash_types::codec::take::<$len>(data)
.map(<Self as $crate::__deps::dash_types::Numeric>::from_lendian)
}

fn encode(&self, buf: &mut impl $crate::__private::dash_types::codec::EncodeBuf) {
fn encode(&self, buf: &mut impl $crate::__deps::dash_types::codec::EncodeBuf) {
buf.extend_from_slice(self.as_bytes());
}
}

$crate::__private::dash_types::impl_type!($name);
$crate::__deps::dash_types::impl_type!($name);
}
};
(
Expand All @@ -75,7 +75,7 @@ macro_rules! make_hash {
$(#[$attr])*
#[derive(
Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
$crate::__private::dash_types::type_id::TypeId,
$crate::__deps::dash_types::type_id::TypeId,
)]
pub struct $name($crate::HashBlob<$len>);
} else {
Expand Down Expand Up @@ -118,17 +118,17 @@ macro_rules! make_hash {

/// Parse from a big-endian hex string.
#[inline]
pub fn from_hex(s: &str) -> Result<Self, $crate::__private::dash_types::ParseHexError> {
pub fn from_hex(s: &str) -> Result<Self, $crate::__deps::dash_types::ParseHexError> {
<$crate::HashBlob<$len>>::from_hex(s).map(Self)
}
}

impl $crate::__private::dash_types::Numeric for $name {
impl $crate::__deps::dash_types::Numeric for $name {
type Base = $crate::HashBlob<$len>;

type Bytes = [u8; $len];

const ZERO: Self = Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::ZERO);
const ZERO: Self = Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::ZERO);

#[inline]
fn from_base(v: $crate::HashBlob<$len>) -> Self {
Expand All @@ -142,28 +142,28 @@ macro_rules! make_hash {

#[inline]
fn from_lendian(bytes: [u8; $len]) -> Self {
Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::from_lendian(bytes))
Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::from_lendian(bytes))
}

#[inline]
fn to_lendian(&self) -> [u8; $len] {
<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::to_lendian(&self.0)
<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::to_lendian(&self.0)
}

#[inline]
fn from_bendian(bytes: [u8; $len]) -> Self {
Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::from_bendian(bytes))
Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::from_bendian(bytes))
}

#[inline]
fn to_bendian(&self) -> [u8; $len] {
<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::to_bendian(&self.0)
<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::to_bendian(&self.0)
}
}

impl Default for $name {
#[inline]
fn default() -> Self { <Self as $crate::__private::dash_types::Numeric>::ZERO }
fn default() -> Self { <Self as $crate::__deps::dash_types::Numeric>::ZERO }
}

impl ::core::fmt::Display for $name {
Expand Down Expand Up @@ -191,17 +191,17 @@ macro_rules! make_hash {
}

impl ::core::str::FromStr for $name {
type Err = $crate::__private::dash_types::ParseHexError;
type Err = $crate::__deps::dash_types::ParseHexError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::from_hex(s)
}
}

$crate::__private::dash_types::type_cvrt!(From<[u8; $len]> for $name, |b| <Self as $crate::__private::dash_types::Numeric>::from_lendian(*b));
$crate::__private::dash_types::type_cvrt!(From<$name> for [u8; $len], |h| $crate::__private::dash_types::Numeric::to_lendian(h));
$crate::__private::dash_types::type_cvrt!(From<$crate::HashBlob<$len>> for $name, |h| Self(*h));
$crate::__private::dash_types::type_cvrt!(From<$name> for $crate::HashBlob<$len>, |h| h.0);
$crate::__deps::dash_types::type_cvrt!(From<[u8; $len]> for $name, |b| <Self as $crate::__deps::dash_types::Numeric>::from_lendian(*b));
$crate::__deps::dash_types::type_cvrt!(From<$name> for [u8; $len], |h| $crate::__deps::dash_types::Numeric::to_lendian(h));
$crate::__deps::dash_types::type_cvrt!(From<$crate::HashBlob<$len>> for $name, |h| Self(*h));
$crate::__deps::dash_types::type_cvrt!(From<$name> for $crate::HashBlob<$len>, |h| h.0);

impl AsRef<[u8]> for $name {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion pkgs/num/tests/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use dash_num::{Arith256, Hash256};
use dash_types::Numeric;
use hex_literal::hex;
use hex_conservative::hex;
use rstest::*;

use core::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/num/tests/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use dash_num::{Hash160, Hash256};
use dash_types::{Numeric, ParseHexError};
use hex_literal::hex;
use hex_conservative::hex;
use rstest::*;

use core::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/num/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use dash_dev::{assert_cbor_raw, assert_json_rt, from_json, json_rejects, to_json};
use dash_num::{Arith256, CompactTarget, Hash160, Hash256};
use dash_types::Numeric;
use hex_literal::hex;
use hex_conservative::hex;

#[test]
fn hash256_json_roundtrip() {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/p2p_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ dash-primitives = { version = "0.0.0", path = "../primitives" }
dash-types = { version = "0.1.0-beta", path = "../types", default-features = false, features = [
"codec",
] }
serde = { version = "1", default-features = false, features = [
serde = { workspace = true, features = [
"alloc",
"derive",
], optional = true }

[dev-dependencies]
dash-dev = { version = "0.0.0", path = "../dev", features = ["full"] }
hex-conservative = { workspace = true, features = ["std"] }
rstest = "0.25"
rstest = { workspace = true }

[lints]
workspace = true
4 changes: 2 additions & 2 deletions pkgs/p2p_core/src/msg/headers2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use crate::prelude::*;
use crate::version::ProtocolVersion;

use dash_primitives::{hash_impl, BlockHash, BlockHeader, MerkleRoot};
use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf, Hashable};
use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf};
use dash_types::type_id::{TypeId, Unencodable};
use dash_types::CompactSize;
use dash_types::{CompactSize, Hashable};

/// Maximum headers per message.
const MAX_HEADERS: usize = 2_000;
Expand Down
5 changes: 2 additions & 3 deletions pkgs/params/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ dash-script = { version = "0.0.0", path = "../script" }
dash-types = { version = "0.1.0-beta", path = "../types", default-features = false, features = [
"codec",
] }
hex-literal = "0.4"
hex-conservative = { workspace = true }

[dev-dependencies]
bitcoin-consensus-encoding = { workspace = true, features = ["alloc"] }
hex-literal = "0.4"
rstest = "0.25"
rstest = { workspace = true }

[lints]
workspace = true
Loading