From b20b6fdee155e7fa82057290f3c5e4fff5a3d030 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 21 Jan 2024 15:18:25 +0000 Subject: [PATCH] remove primitive-types for crypto-bigint we already have crypto-bigint in our tree --- Cargo.lock | 51 +++++++++-------------------------- Cargo.toml | 2 +- consensus/rules/Cargo.toml | 2 +- consensus/rules/src/blocks.rs | 6 ++--- p2p/monero-p2p/Cargo.toml | 2 +- 5 files changed, 19 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1ad93a..b73592f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -655,15 +655,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "static_assertions", -] - [[package]] name = "flexible-transcript" version = "0.3.2" @@ -725,6 +716,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -746,6 +748,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-io", + "futures-macro", "futures-sink", "futures-task", "memchr", @@ -1112,6 +1115,7 @@ dependencies = [ name = "monero-consensus" version = "0.1.0" dependencies = [ + "crypto-bigint", "cryptonight-cuprate", "cuprate-common", "curve25519-dalek", @@ -1120,7 +1124,6 @@ dependencies = [ "hex-literal", "monero-serai", "multiexp", - "primitive-types", "proptest", "proptest-derive", "rand", @@ -1377,16 +1380,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "uint", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -1852,12 +1845,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "std-shims" version = "0.1.1" @@ -2152,18 +2139,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unarray" version = "0.1.4" diff --git a/Cargo.toml b/Cargo.toml index c70d105..84492c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ borsh = { version = "1.2.1", default-features = false } bytes = { version = "1.5.0", default-features = false } clap = { version = "4.4.7", default-features = false } chrono = { version = "0.4.31", default-features = false } -primitive-types = { version = "0.12.2", default-features = false } +crypto-bigint = { version = "0.5.5", default-features = false } curve25519-dalek = { version = "4.1.1", default-features = false } dalek-ff-group = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false } dirs = { version = "5.0.1", default-features = false } diff --git a/consensus/rules/Cargo.toml b/consensus/rules/Cargo.toml index 7f19e9e..7a16341 100644 --- a/consensus/rules/Cargo.toml +++ b/consensus/rules/Cargo.toml @@ -21,7 +21,7 @@ rand = { workspace = true, features = ["std"] } hex = { workspace = true, features = ["std"] } hex-literal = { workspace = true } -primitive-types = { workspace = true } # enabiling std pulls in 9 extra crates! +crypto-bigint = { workspace = true } tracing = { workspace = true, features = ["std"] } thiserror = { workspace = true } diff --git a/consensus/rules/src/blocks.rs b/consensus/rules/src/blocks.rs index 57dfdbe..c35094b 100644 --- a/consensus/rules/src/blocks.rs +++ b/consensus/rules/src/blocks.rs @@ -1,5 +1,5 @@ +use crypto_bigint::{CheckedMul, U256}; use monero_serai::block::Block; -use primitive_types::U256; use cryptonight_cuprate::*; @@ -100,11 +100,11 @@ pub fn calculate_pow_hash( /// /// ref: https://monero-book.cuprate.org/consensus_rules/blocks.html#checking-pow-hash pub fn check_block_pow(hash: &[u8; 32], difficulty: u128) -> Result<(), BlockError> { - let int_hash = U256::from_little_endian(hash); + let int_hash = U256::from_le_slice(hash); let difficulty = U256::from(difficulty); - if int_hash.checked_mul(difficulty).is_none() { + if int_hash.checked_mul(&difficulty).is_none().unwrap_u8() == 1 { tracing::debug!( "Invalid POW: {}, difficulty: {}", hex::encode(hash), diff --git a/p2p/monero-p2p/Cargo.toml b/p2p/monero-p2p/Cargo.toml index 378e4ae..779a22d 100644 --- a/p2p/monero-p2p/Cargo.toml +++ b/p2p/monero-p2p/Cargo.toml @@ -16,7 +16,7 @@ cuprate-common = {path = "../../common", features = ["borsh"]} tokio = { workspace = true, features = ["net", "sync", "macros"]} tokio-util = { workspace = true, features = ["codec"] } tokio-stream = { workspace = true, features = ["sync"]} -futures = { workspace = true, features = ["std"] } +futures = { workspace = true, features = ["std", "async-await"] } async-trait = { workspace = true } tower = { workspace = true, features = ["util"] }