diff --git a/Cargo.lock b/Cargo.lock index e7ddaefcdc..0a94c3c042 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1244,6 +1244,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + [[package]] name = "bytecheck" version = "0.6.12" @@ -1948,26 +1954,6 @@ dependencies = [ "syn 2.0.82", ] -[[package]] -name = "custom_debug" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89e0ae2c2a42be29595d05c50e3ce6096c0698a97e021c3289790f0750cc8e2" -dependencies = [ - "custom_debug_derive", -] - -[[package]] -name = "custom_debug_derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f3941234c9f62ceaa2782974827749de9b0a8a6487275a278da068e1baf7" -dependencies = [ - "proc-macro2", - "syn 1.0.109", - "synstructure 0.12.6", -] - [[package]] name = "darling" version = "0.20.10" @@ -2187,6 +2173,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.82", + "unicode-xid", ] [[package]] @@ -2388,11 +2375,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "espresso-systems-common" -version = "0.4.1" -source = "git+https://github.com/espressosystems/espresso-systems-common?tag=0.4.1#2e889e878866c2a5cce1daaab947f7c93d5811ae" - [[package]] name = "etcetera" version = "0.8.0" @@ -2404,31 +2386,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-serde", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-serde", - "primitive-types", - "uint", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -2505,6 +2462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -3111,11 +3069,9 @@ dependencies = [ "chrono", "clap", "committable", - "custom_debug", "dashmap", "derive_more 1.0.0", "either", - "ethereum-types", "futures", "hotshot-task", "hotshot-task-impls", @@ -3127,6 +3083,7 @@ dependencies = [ "num_enum", "parking_lot", "portpicker", + "primitive-types", "rand 0.8.5", "serde", "sha2 0.10.8", @@ -3171,12 +3128,12 @@ dependencies = [ "bitvec", "committable", "either", - "ethereum-types", "futures", "hotshot", "hotshot-task", "hotshot-task-impls", "hotshot-types", + "primitive-types", "rand 0.8.5", "reqwest", "serde", @@ -3208,7 +3165,6 @@ dependencies = [ "chrono", "clap", "committable", - "custom_debug", "dashmap", "derive_more 1.0.0", "either", @@ -3307,12 +3263,12 @@ dependencies = [ "ark-serialize", "ark-std", "digest 0.10.7", - "ethereum-types", "hotshot-types", "jf-crhf", "jf-rescue", "jf-signature", "jf-utils", + "primitive-types", "rand_chacha 0.3.1", "serde", "tagged-base64", @@ -3344,7 +3300,6 @@ dependencies = [ "async-trait", "bincode", "bitvec", - "cdn-proto", "chrono", "committable", "either", @@ -3382,7 +3337,6 @@ dependencies = [ "bitvec", "committable", "either", - "ethereum-types", "futures", "hotshot", "hotshot-builder-api", @@ -3398,6 +3352,7 @@ dependencies = [ "jf-vid", "lru 0.12.5", "portpicker", + "primitive-types", "rand 0.8.5", "reqwest", "serde", @@ -3431,34 +3386,30 @@ dependencies = [ "bincode", "bitvec", "blake3", - "cdn-proto", "clap", "committable", - "custom_debug", - "derivative", + "derive_more 1.0.0", "digest 0.10.7", "displaydoc", "dyn-clone 1.0.17 (git+https://github.com/dtolnay/dyn-clone?tag=1.0.17)", "either", - "espresso-systems-common", - "ethereum-types", "futures", "jf-pcs", "jf-signature", "jf-utils", "jf-vid", "lazy_static", - "libp2p", + "libp2p-identity", "memoize", + "mnemonic", + "multiaddr", + "primitive-types", "rand 0.8.5", "rand_chacha 0.3.1", - "reqwest", "serde", "serde-inline-default", - "serde_bytes", "serde_json", "sha2 0.10.8", - "surf-disco", "tagged-base64", "thiserror", "time 0.3.36", @@ -3819,15 +3770,35 @@ dependencies = [ "xmltree", ] +[[package]] +name = "impl-codec" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67aa010c1e3da95bf151bd8b4c059b2ed7e75387cdb969b4f8f2723a43f9941" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "impl-serde" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" dependencies = [ "serde", ] +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "include_dir" version = "0.7.3" @@ -4487,7 +4458,7 @@ dependencies = [ "smallvec", "thiserror", "tracing", - "uint", + "uint 0.9.5", "void", ] @@ -4543,9 +4514,9 @@ dependencies = [ "async-trait", "bincode", "blake3", - "custom_debug", "delegate", "derive_builder", + "derive_more 1.0.0", "either", "futures", "hotshot-types", @@ -5413,6 +5384,32 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "parity-scale-codec" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "parking" version = "2.2.0" @@ -5681,13 +5678,14 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.12.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" dependencies = [ "fixed-hash", + "impl-codec", "impl-serde", - "uint", + "uint 0.10.0", ] [[package]] @@ -8249,6 +8247,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicase" version = "2.7.0" @@ -8432,15 +8442,14 @@ dependencies = [ [[package]] name = "vbs" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9d83afb293d109ae418271619046cd9d87d63ba83e473e25a5e36101edc453" +checksum = "9cf4ed425fa4976d51e35f5882764612c5f735457118d6ef7b6c684b7d34a74d" dependencies = [ "anyhow", "bincode", "derive_more 0.99.18", "serde", - "serde_with", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 099fff2882..5e921d5190 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,18 +12,18 @@ repository = "https://github.com/EspressoSystems/HotShot" # when implementing traits externally [workspace] members = [ - "crates/hotshot", - "crates/hotshot-stake-table", - "crates/libp2p-networking", - "crates/macros", - "crates/task", - "crates/task-impls", - "crates/testing", - "crates/examples", - "crates/example-types", - "crates/types", - "crates/builder-api", - "crates/fakeapi", + "crates/hotshot", + "crates/hotshot-stake-table", + "crates/libp2p-networking", + "crates/macros", + "crates/task", + "crates/task-impls", + "crates/testing", + "crates/examples", + "crates/example-types", + "crates/types", + "crates/builder-api", + "crates/fakeapi", ] resolver = "2" @@ -35,28 +35,27 @@ ark-serialize = "0.4" ark-std = { version = "0.4", default-features = false } async-broadcast = "0.7" async-compatibility-layer = { version = "1.2.1", default-features = false, features = [ - "logging-utils", + "logging-utils", ] } async-lock = "2" async-std = { version = "1", features = ["attributes"] } async-trait = "0.1" bincode = "1" bitvec = { version = "1", default-features = false, features = [ - "alloc", - "atomic", - "serde", + "alloc", + "atomic", + "serde", ] } blake3 = "1.5" chrono = { version = "0.4", default-features = false, features = ["now"] } committable = "0.2" -custom_debug = "0.5" digest = "0.10" either = "1.13" espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.4.1" } -ethereum-types = { version = "0.14", default-features = false, features = [ - "serialize", +primitive-types = { version = "0.13.1", default-features = false, features = [ + "serde", ] } -derive_more = { version = "1.0", features = ["from"] } +derive_more = { version = "1.0", features = ["from", "debug"] } futures = { version = "0.3", default-features = false } jf-crhf = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5" } jf-vid = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5" } @@ -67,8 +66,9 @@ jf-utils = { version = "0.4.4", git = "https://github.com/espressosystems/jellyf lazy_static = "1" libp2p-identity = "0.2" libp2p-networking = { path = "./crates/libp2p-networking", version = "0.5", default-features = false } -libp2p-swarm-derive = { version = "0.34" } +libp2p-swarm-derive = "0.34" lru = "0.12" +multiaddr = "0.18" portpicker = "0.1" rand = { version = "0.8", features = ["small_rng"] } rand_chacha = { version = "0.3", default-features = false } @@ -81,7 +81,7 @@ surf-disco = "0.9" tagged-base64 = "0.4" tide-disco = "0.9" time = "0.3" -toml = "0.8" +toml = { version = "0.8", default-features = false } tracing = "0.1" typenum = "1" memoize = { version = "0.4", features = ["full"] } @@ -92,26 +92,26 @@ vec1 = { version = "1", features = ["serde"] } reqwest = { version = "0.12", features = ["json"] } libp2p = { package = "libp2p", version = "0.53", default-features = false, features = [ - "macros", - "autonat", - "cbor", - "dns", - "gossipsub", - "identify", - "kad", - "quic", - "request-response", - "secp256k1", - "serde", + "macros", + "autonat", + "cbor", + "dns", + "gossipsub", + "identify", + "kad", + "quic", + "request-response", + "secp256k1", + "serde", ] } tokio = { version = "1", default-features = false, features = [ - "macros", - "net", - "parking_lot", - "rt-multi-thread", - "sync", - "time", - "tracing", + "macros", + "net", + "parking_lot", + "rt-multi-thread", + "sync", + "time", + "tracing", ] } anyhow = "1" @@ -120,7 +120,6 @@ anyhow = "1" cdn-client = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" } cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" } cdn-marshal = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" } -cdn-proto = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" } ### Profiles ### diff --git a/crates/example-types/Cargo.toml b/crates/example-types/Cargo.toml index 1c38092bc1..f423a3daeb 100644 --- a/crates/example-types/Cargo.toml +++ b/crates/example-types/Cargo.toml @@ -31,7 +31,7 @@ sha2 = { workspace = true } time = { workspace = true } async-lock = { workspace = true } bitvec = { workspace = true } -ethereum-types = { workspace = true } +primitive-types = { workspace = true } hotshot-task = { path = "../task" } vbs = { workspace = true } url = { workspace = true } diff --git a/crates/examples/Cargo.toml b/crates/examples/Cargo.toml index 313c6ac746..6e007a8c78 100644 --- a/crates/examples/Cargo.toml +++ b/crates/examples/Cargo.toml @@ -88,7 +88,6 @@ async-trait = { workspace = true } bimap = "0.6" clap = { workspace = true, optional = true } committable = { workspace = true } -custom_debug = { workspace = true } dashmap = "6" either = { workspace = true } futures = { workspace = true } @@ -128,12 +127,12 @@ cdn-marshal = { workspace = true } async-std = { workspace = true } cdn-client = { workspace = true, features = ["runtime-async-std"] } cdn-broker = { workspace = true, features = [ - "runtime-async-std", - "global-permits", + "runtime-async-std", + "global-permits", ] } cdn-marshal = { workspace = true, features = [ - "runtime-async-std", - "global-permits", + "runtime-async-std", + "global-permits", ] } [dev-dependencies] diff --git a/crates/hotshot-stake-table/Cargo.toml b/crates/hotshot-stake-table/Cargo.toml index ef3d9bca62..7337fe0c8d 100644 --- a/crates/hotshot-stake-table/Cargo.toml +++ b/crates/hotshot-stake-table/Cargo.toml @@ -13,7 +13,7 @@ ark-ff = "0.4" ark-serialize = { workspace = true } ark-std = { workspace = true } digest = { workspace = true } -ethereum-types = { workspace = true } +primitive-types = { workspace = true } hotshot-types = { path = "../types" } jf-crhf = { workspace = true } jf-signature = { workspace = true, features = ["bls", "schnorr"] } diff --git a/crates/hotshot-stake-table/src/mt_based.rs b/crates/hotshot-stake-table/src/mt_based.rs index 0929b78bee..a6804662be 100644 --- a/crates/hotshot-stake-table/src/mt_based.rs +++ b/crates/hotshot-stake-table/src/mt_based.rs @@ -11,8 +11,8 @@ mod internal; use ark_std::{collections::HashMap, rand::SeedableRng, sync::Arc}; use digest::crypto_common::rand_core::CryptoRngCore; -use ethereum_types::{U256, U512}; use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableError, StakeTableScheme}; +use primitive_types::{U256, U512}; use serde::{Deserialize, Serialize}; use self::internal::{to_merkle_path, Key, MerkleCommitment, MerkleProof, PersistentMerkleNode}; @@ -230,8 +230,8 @@ impl StakeTable { #[cfg(test)] mod tests { use ark_std::{rand::SeedableRng, vec::Vec}; - use ethereum_types::U256; use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableError, StakeTableScheme}; + use primitive_types::U256; use super::StakeTable; diff --git a/crates/hotshot-stake-table/src/mt_based/internal.rs b/crates/hotshot-stake-table/src/mt_based/internal.rs index ee98af4670..b08301ee30 100644 --- a/crates/hotshot-stake-table/src/mt_based/internal.rs +++ b/crates/hotshot-stake-table/src/mt_based/internal.rs @@ -8,10 +8,10 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::{hash::Hash, sync::Arc, vec, vec::Vec}; -use ethereum_types::U256; use hotshot_types::traits::stake_table::StakeTableError; use jf_crhf::CRHF; use jf_utils::canonical; +use primitive_types::U256; use serde::{Deserialize, Serialize}; use tagged_base64::tagged; @@ -631,8 +631,8 @@ mod tests { vec, vec::Vec, }; - use ethereum_types::U256; use jf_utils::test_rng; + use primitive_types::U256; use super::{super::config, to_merkle_path, PersistentMerkleNode}; diff --git a/crates/hotshot-stake-table/src/utils.rs b/crates/hotshot-stake-table/src/utils.rs index e3ef251fd0..b295cdeb28 100644 --- a/crates/hotshot-stake-table/src/utils.rs +++ b/crates/hotshot-stake-table/src/utils.rs @@ -7,7 +7,7 @@ //! Utilities to help building a stake table. use ark_ff::{Field, PrimeField}; -use ethereum_types::U256; +use primitive_types::U256; /// A trait that converts into a field element. pub trait ToFields { @@ -21,6 +21,6 @@ pub trait ToFields { /// convert a U256 to a field element. pub(crate) fn u256_to_field(v: &U256) -> F { let mut bytes = vec![0u8; 32]; - v.to_little_endian(&mut bytes); + v.write_as_little_endian(&mut bytes); F::from_le_bytes_mod_order(&bytes) } diff --git a/crates/hotshot-stake-table/src/vec_based.rs b/crates/hotshot-stake-table/src/vec_based.rs index 66b9f23d05..6267dd21ca 100644 --- a/crates/hotshot-stake-table/src/vec_based.rs +++ b/crates/hotshot-stake-table/src/vec_based.rs @@ -8,10 +8,10 @@ use ark_std::{collections::HashMap, hash::Hash, rand::SeedableRng}; use digest::crypto_common::rand_core::CryptoRngCore; -use ethereum_types::{U256, U512}; use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableError, StakeTableScheme}; use jf_crhf::CRHF; use jf_rescue::{crhf::VariableLengthRescueCRHF, RescueParameter}; +use primitive_types::{U256, U512}; use serde::{Deserialize, Serialize}; use crate::{ @@ -387,12 +387,12 @@ where #[cfg(test)] mod tests { use ark_std::{rand::SeedableRng, vec::Vec}; - use ethereum_types::U256; use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableError, StakeTableScheme}; use jf_signature::{ bls_over_bn254::BLSOverBN254CurveSignatureScheme, schnorr::SchnorrSignatureScheme, SignatureScheme, }; + use primitive_types::U256; use super::{ config::{FieldType as F, QCVerKey, StateVerKey}, diff --git a/crates/hotshot/Cargo.toml b/crates/hotshot/Cargo.toml index 874e94939d..a108480302 100644 --- a/crates/hotshot/Cargo.toml +++ b/crates/hotshot/Cargo.toml @@ -32,11 +32,10 @@ bincode = { workspace = true } chrono = { workspace = true } clap = { workspace = true, optional = true } committable = { workspace = true } -custom_debug = { workspace = true } dashmap = "6" derive_more = { workspace = true } either = { workspace = true } -ethereum-types = { workspace = true } +primitive-types = { workspace = true } futures = { workspace = true } hotshot-task = { path = "../task" } hotshot-task-impls = { path = "../task-impls", version = "0.5.36", default-features = false } @@ -69,12 +68,12 @@ cdn-marshal = { workspace = true } async-std = { workspace = true } cdn-client = { workspace = true, features = ["runtime-async-std"] } cdn-broker = { workspace = true, features = [ - "runtime-async-std", - "global-permits", + "runtime-async-std", + "global-permits", ] } cdn-marshal = { workspace = true, features = [ - "runtime-async-std", - "global-permits", + "runtime-async-std", + "global-permits", ] } diff --git a/crates/hotshot/src/traits/election/randomized_committee.rs b/crates/hotshot/src/traits/election/randomized_committee.rs index 4fed098e9c..3166f7e3b0 100644 --- a/crates/hotshot/src/traits/election/randomized_committee.rs +++ b/crates/hotshot/src/traits/election/randomized_committee.rs @@ -6,7 +6,6 @@ use std::{cmp::max, collections::BTreeMap, num::NonZeroU64}; -use ethereum_types::U256; use hotshot_types::{ traits::{ election::Membership, @@ -16,6 +15,7 @@ use hotshot_types::{ }, PeerConfig, }; +use primitive_types::U256; use rand::{rngs::StdRng, Rng}; #[derive(Clone, Debug, Eq, PartialEq, Hash)] diff --git a/crates/hotshot/src/traits/election/static_committee.rs b/crates/hotshot/src/traits/election/static_committee.rs index 2ef52a66e2..007adf3fd6 100644 --- a/crates/hotshot/src/traits/election/static_committee.rs +++ b/crates/hotshot/src/traits/election/static_committee.rs @@ -6,7 +6,6 @@ use std::{cmp::max, collections::BTreeMap, num::NonZeroU64}; -use ethereum_types::U256; use hotshot_types::{ traits::{ election::Membership, @@ -16,6 +15,7 @@ use hotshot_types::{ }, PeerConfig, }; +use primitive_types::U256; #[derive(Clone, Debug, Eq, PartialEq, Hash)] diff --git a/crates/hotshot/src/traits/election/static_committee_leader_two_views.rs b/crates/hotshot/src/traits/election/static_committee_leader_two_views.rs index db41aad2ab..c9874c2afa 100644 --- a/crates/hotshot/src/traits/election/static_committee_leader_two_views.rs +++ b/crates/hotshot/src/traits/election/static_committee_leader_two_views.rs @@ -6,7 +6,6 @@ use std::{collections::BTreeMap, num::NonZeroU64}; -use ethereum_types::U256; use hotshot_types::{ traits::{ election::Membership, @@ -16,6 +15,7 @@ use hotshot_types::{ }, PeerConfig, }; +use primitive_types::U256; #[derive(Clone, Debug, Eq, PartialEq, Hash)] diff --git a/crates/hotshot/src/traits/networking/memory_network.rs b/crates/hotshot/src/traits/networking/memory_network.rs index 54fcdd9d1b..3443483b15 100644 --- a/crates/hotshot/src/traits/networking/memory_network.rs +++ b/crates/hotshot/src/traits/networking/memory_network.rs @@ -47,7 +47,7 @@ use super::{NetworkError, NetworkReliability}; /// /// This type is responsible for keeping track of the channels to each [`MemoryNetwork`], and is /// used to group the [`MemoryNetwork`] instances. -#[derive(custom_debug::Debug)] +#[derive(derive_more::Debug)] pub struct MasterMap { /// The list of `MemoryNetwork`s #[debug(skip)] diff --git a/crates/libp2p-networking/Cargo.toml b/crates/libp2p-networking/Cargo.toml index ecf4aa20fb..1f444a6f6a 100644 --- a/crates/libp2p-networking/Cargo.toml +++ b/crates/libp2p-networking/Cargo.toml @@ -18,9 +18,9 @@ async-lock = { workspace = true } async-trait = { workspace = true } blake3 = { workspace = true } bincode = { workspace = true } -custom_debug = { workspace = true } delegate = "0.13" derive_builder = "0.20" +derive_more = { workspace = true } either = { workspace = true } futures = { workspace = true } hotshot-types = { path = "../types" } @@ -32,7 +32,7 @@ serde_bytes = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } tide = { version = "0.16", optional = true, default-features = false, features = [ - "h1-server", + "h1-server", ] } tracing = { workspace = true } void = "1" diff --git a/crates/libp2p-networking/src/network/def.rs b/crates/libp2p-networking/src/network/def.rs index 39d6bdd1b2..56d27b1c81 100644 --- a/crates/libp2p-networking/src/network/def.rs +++ b/crates/libp2p-networking/src/network/def.rs @@ -24,7 +24,7 @@ use super::{behaviours::dht::store::ValidatedStore, NetworkEventInternal}; /// - direct messaging /// - p2p broadcast /// - connection management -#[derive(NetworkBehaviour, custom_debug::Debug)] +#[derive(NetworkBehaviour, derive_more::Debug)] #[behaviour(to_swarm = "NetworkEventInternal")] pub struct NetworkDef { /// purpose: broadcasting messages to many peers diff --git a/crates/libp2p-networking/src/network/node.rs b/crates/libp2p-networking/src/network/node.rs index 08e896d785..63440a88b4 100644 --- a/crates/libp2p-networking/src/network/node.rs +++ b/crates/libp2p-networking/src/network/node.rs @@ -81,7 +81,7 @@ pub const ESTABLISHED_LIMIT: NonZeroU32 = pub const ESTABLISHED_LIMIT_UNWR: u32 = 10; /// Network definition -#[derive(custom_debug::Debug)] +#[derive(derive_more::Debug)] pub struct NetworkNode { /// The keypair for the node keypair: Keypair, diff --git a/crates/libp2p-networking/src/network/node/config.rs b/crates/libp2p-networking/src/network/node/config.rs index c51fc281ea..8aa4915a5e 100644 --- a/crates/libp2p-networking/src/network/node/config.rs +++ b/crates/libp2p-networking/src/network/node/config.rs @@ -16,7 +16,7 @@ use super::MAX_GOSSIP_MSG_SIZE; pub const DEFAULT_REPLICATION_FACTOR: Option = NonZeroUsize::new(10); /// describe the configuration of the network -#[derive(Clone, Default, derive_builder::Builder, custom_debug::Debug)] +#[derive(Clone, Default, derive_builder::Builder, derive_more::Debug)] pub struct NetworkNodeConfig { /// The keypair for the node #[builder(setter(into, strip_option), default)] diff --git a/crates/task-impls/Cargo.toml b/crates/task-impls/Cargo.toml index 2492438ea4..fd592290fc 100644 --- a/crates/task-impls/Cargo.toml +++ b/crates/task-impls/Cargo.toml @@ -19,7 +19,6 @@ async-lock = { workspace = true } async-trait = { workspace = true } bincode = { workspace = true } bitvec = { workspace = true } -cdn-proto = { workspace = true } chrono = { workspace = true } committable = { workspace = true } either = { workspace = true } diff --git a/crates/task-impls/src/view_sync.rs b/crates/task-impls/src/view_sync.rs index fb00054f88..ff04d5ab33 100644 --- a/crates/task-impls/src/view_sync.rs +++ b/crates/task-impls/src/view_sync.rs @@ -462,7 +462,7 @@ impl, V: Versions> ViewSyncTaskSta let leader = self.membership.leader(view_number, self.current_epoch); warn!( %leader, - leader_mnemonic = cdn_proto::util::mnemonic(&leader), + leader_mnemonic = hotshot_types::utils::mnemonic(&leader), view_number = *view_number, num_timeouts_tracked = self.num_timeouts_tracked, "view timed out", diff --git a/crates/testing/Cargo.toml b/crates/testing/Cargo.toml index 82473f3d34..2890e070e3 100644 --- a/crates/testing/Cargo.toml +++ b/crates/testing/Cargo.toml @@ -23,7 +23,7 @@ async-trait = { workspace = true } bitvec = { workspace = true } committable = { workspace = true } either = { workspace = true } -ethereum-types = { workspace = true } +primitive-types = { workspace = true } futures = { workspace = true } hotshot = { path = "../hotshot", features = ["hotshot-testing"] } hotshot-example-types = { path = "../example-types" } diff --git a/crates/testing/src/helpers.rs b/crates/testing/src/helpers.rs index 842ef3e538..01febfbe3a 100644 --- a/crates/testing/src/helpers.rs +++ b/crates/testing/src/helpers.rs @@ -10,7 +10,6 @@ use std::{fmt::Debug, hash::Hash, marker::PhantomData, sync::Arc}; use async_broadcast::{Receiver, Sender}; use bitvec::bitvec; use committable::Committable; -use ethereum_types::U256; use hotshot::{ traits::{NodeImplementation, TestableNodeImplementation}, types::{SignatureKey, SystemContextHandle}, @@ -43,6 +42,7 @@ use hotshot_types::{ ValidatorConfig, }; use jf_vid::VidScheme; +use primitive_types::U256; use serde::Serialize; use crate::{test_builder::TestDescription, test_launcher::TestLauncher}; diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index ca2541d709..0572fae6e3 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -20,40 +20,36 @@ bincode = { workspace = true } bitvec = { workspace = true } blake3 = { workspace = true } committable = { workspace = true } -custom_debug = { workspace = true } digest = { workspace = true, features = ["rand_core"] } +derive_more = { workspace = true } either = { workspace = true } -espresso-systems-common = { workspace = true } -ethereum-types = { workspace = true } +primitive-types = { workspace = true } futures = { workspace = true } -cdn-proto = { workspace = true } -reqwest = { workspace = true } serde-inline-default = "0.2" lazy_static = { workspace = true } memoize = { workspace = true } +mnemonic = "1" +multiaddr = { workspace = true } rand = { workspace = true } sha2 = { workspace = true } thiserror = { workspace = true } time = { workspace = true } tracing = { workspace = true } typenum = { workspace = true } -derivative = "2" jf-vid = { workspace = true } jf-pcs = { workspace = true } jf-signature = { workspace = true, features = ["schnorr"] } jf-utils = { workspace = true } rand_chacha = { workspace = true } serde = { workspace = true } -serde_bytes = { workspace = true } tagged-base64 = { workspace = true } vbs = { workspace = true } displaydoc = { version = "0.2.5", default-features = false } dyn-clone = { git = "https://github.com/dtolnay/dyn-clone", tag = "1.0.17" } url = { workspace = true } vec1 = { workspace = true } -libp2p = { workspace = true } +libp2p-identity = { workspace = true } serde_json = { workspace = true } -surf-disco = { workspace = true } toml = { workspace = true } clap = { workspace = true } diff --git a/crates/types/src/consensus.rs b/crates/types/src/consensus.rs index b84ab99b19..7ec4a519db 100644 --- a/crates/types/src/consensus.rs +++ b/crates/types/src/consensus.rs @@ -269,7 +269,7 @@ impl HotShotActionViews { /// A reference to the consensus algorithm /// /// This will contain the state of all rounds. -#[derive(custom_debug::Debug, Clone)] +#[derive(derive_more::Debug, Clone)] pub struct Consensus { /// The validated states that are currently loaded in memory. validated_state_map: BTreeMap>, diff --git a/crates/types/src/data.rs b/crates/types/src/data.rs index 3518f2e8bd..12ed4955d6 100644 --- a/crates/types/src/data.rs +++ b/crates/types/src/data.rs @@ -9,6 +9,14 @@ //! This module provides types for representing consensus internal state, such as leaves, //! `HotShot`'s version of a block, and proposals, messages upon which to reach the consensus. +use std::{ + collections::BTreeMap, + fmt::{Debug, Display}, + hash::Hash, + marker::PhantomData, + sync::Arc, +}; + use anyhow::{ensure, Result}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use async_lock::RwLock; @@ -16,17 +24,9 @@ use async_lock::RwLock; use async_std::task::spawn_blocking; use bincode::Options; use committable::{Commitment, CommitmentBoundsArkless, Committable, RawCommitmentBuilder}; -use derivative::Derivative; use jf_vid::{precomputable::Precomputable, VidDisperse as JfVidDisperse, VidScheme}; use rand::Rng; use serde::{Deserialize, Serialize}; -use std::{ - collections::BTreeMap, - fmt::{Debug, Display}, - hash::Hash, - marker::PhantomData, - sync::Arc, -}; use thiserror::Error; #[cfg(async_executor_impl = "tokio")] use tokio::task::spawn_blocking; @@ -164,7 +164,7 @@ impl Committable for EpochNumber { impl_u64_wrapper!(EpochNumber); /// A proposal to start providing data availability for a block. -#[derive(custom_debug::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] +#[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound = "TYPES: NodeType")] pub struct DaProposal { /// Encoded transactions in the block to be applied. @@ -176,7 +176,7 @@ pub struct DaProposal { } /// A proposal to upgrade the network -#[derive(custom_debug::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] +#[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound = "TYPES: NodeType")] pub struct UpgradeProposal where @@ -263,7 +263,7 @@ impl VidDisperse { /// Helper type to encapsulate the various ways that proposal certificates can be captured and /// stored. -#[derive(custom_debug::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] +#[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound(deserialize = ""))] pub enum ViewChangeEvidence { /// Holds a timeout certificate. @@ -381,7 +381,7 @@ impl VidDisperseShare { } /// Proposal to append a block. -#[derive(custom_debug::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] +#[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound(deserialize = ""))] pub struct QuorumProposal { /// The block header to append @@ -461,7 +461,7 @@ pub trait TestableLeaf { /// This is the consensus-internal analogous concept to a block, and it contains the block proper, /// as well as the hash of its parent `Leaf`. /// NOTE: `State` is constrained to implementing `BlockContents`, is `TypeMap::BlockPayload` -#[derive(Serialize, Deserialize, Clone, Debug, Derivative, Eq)] +#[derive(Serialize, Deserialize, Clone, Debug, Eq)] #[serde(bound(deserialize = ""))] pub struct Leaf { /// CurView from leader when proposing leaf diff --git a/crates/types/src/hotshot_config_file.rs b/crates/types/src/hotshot_config_file.rs index 08b81af3e4..96b95122e5 100644 --- a/crates/types/src/hotshot_config_file.rs +++ b/crates/types/src/hotshot_config_file.rs @@ -6,7 +6,7 @@ use std::{num::NonZeroUsize, time::Duration, vec}; -use surf_disco::Url; +use url::Url; use vec1::Vec1; use crate::{ @@ -20,7 +20,7 @@ fn default_builder_urls() -> Vec1 { } /// Holds configuration for a `HotShot` -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[derive(derive_more::Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(bound(deserialize = ""))] pub struct HotShotConfigFile { /// The proportion of nodes required before the orchestrator issues the ready signal, diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 897fef5c73..d803ec9317 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -8,7 +8,6 @@ use std::{fmt::Debug, future::Future, num::NonZeroUsize, pin::Pin, time::Duration}; use bincode::Options; -use derivative::Derivative; use displaydoc::Display; use light_client::StateVerKey; use tracing::error; @@ -76,15 +75,14 @@ pub enum ExecutionType { Incremental, } -#[derive(serde::Serialize, serde::Deserialize, Clone, Derivative, Display)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Display, derive_more::Debug)] #[serde(bound(deserialize = ""))] -#[derivative(Debug(bound = ""))] /// config for validator, including public key, private key, stake value pub struct ValidatorConfig { /// The validator's public key and stake value pub public_key: KEY, /// The validator's private key, should be in the mempool, not public - #[derivative(Debug = "ignore")] + #[debug(ignore)] pub private_key: KEY::PrivateKey, /// The validator's stake pub stake_value: u64, @@ -175,7 +173,7 @@ impl Default for PeerConfig { } /// Holds configuration for a `HotShot` -#[derive(Clone, custom_debug::Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, derive_more::Debug, serde::Serialize, serde::Deserialize)] #[serde(bound(deserialize = ""))] pub struct HotShotConfig { /// Whether to run one view or continuous views diff --git a/crates/types/src/light_client.rs b/crates/types/src/light_client.rs index 1fac6614e4..9a535242a8 100644 --- a/crates/types/src/light_client.rs +++ b/crates/types/src/light_client.rs @@ -11,8 +11,8 @@ use std::collections::HashMap; use ark_ed_on_bn254::EdwardsConfig as Config; use ark_ff::PrimeField; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; -use ethereum_types::U256; use jf_signature::schnorr; +use primitive_types::U256; use rand::SeedableRng; use rand_chacha::ChaCha20Rng; use serde::{Deserialize, Serialize}; diff --git a/crates/types/src/message.rs b/crates/types/src/message.rs index 42ae087b9a..5288f38cff 100644 --- a/crates/types/src/message.rs +++ b/crates/types/src/message.rs @@ -17,8 +17,6 @@ use std::{ use anyhow::{bail, ensure, Context, Result}; use async_lock::RwLock; -use cdn_proto::util::mnemonic; -use derivative::Derivative; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use vbs::{ version::{StaticVersionType, Version}, @@ -46,7 +44,7 @@ use crate::{ }; /// Incoming message -#[derive(Serialize, Deserialize, Clone, Derivative, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] #[serde(bound(deserialize = "", serialize = ""))] pub struct Message { /// The sender of this message @@ -59,7 +57,7 @@ pub struct Message { impl fmt::Debug for Message { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Message") - .field("sender", &mnemonic(&self.sender)) + .field("sender", &crate::utils::mnemonic(&self.sender)) .field("kind", &self.kind) .finish() } @@ -333,7 +331,7 @@ impl SequencingMessage { } } -#[derive(Serialize, Deserialize, Derivative, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(bound(deserialize = ""))] #[allow(clippy::large_enum_variant)] /// TODO: Put `DataResponse` content in a `Box` to make enum smaller diff --git a/crates/types/src/network.rs b/crates/types/src/network.rs index 31312bc13f..3544608e75 100644 --- a/crates/types/src/network.rs +++ b/crates/types/src/network.rs @@ -7,7 +7,8 @@ use std::{fs, ops::Range, path::Path, time::Duration, vec}; use clap::ValueEnum; -use libp2p::{Multiaddr, PeerId}; +use libp2p_identity::PeerId; +use multiaddr::Multiaddr; use serde_inline_default::serde_inline_default; use thiserror::Error; use tracing::error; @@ -107,7 +108,7 @@ impl Default for RandomBuilderConfig { } /// a network configuration -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +#[derive(serde::Serialize, serde::Deserialize, Clone, derive_more::Debug)] #[serde(bound(deserialize = ""))] pub struct NetworkConfig { /// number of views to run diff --git a/crates/types/src/qc.rs b/crates/types/src/qc.rs index 2f556159a2..cf86646104 100644 --- a/crates/types/src/qc.rs +++ b/crates/types/src/qc.rs @@ -17,8 +17,8 @@ use ark_std::{ }; use bitvec::prelude::*; use digest::generic_array::GenericArray; -use ethereum_types::U256; use jf_signature::{AggregateableSignatureSchemes, SignatureError}; +use primitive_types::U256; use serde::{Deserialize, Serialize}; use typenum::U32; diff --git a/crates/types/src/signature_key.rs b/crates/types/src/signature_key.rs index 2741912f14..f90ee79e79 100644 --- a/crates/types/src/signature_key.rs +++ b/crates/types/src/signature_key.rs @@ -9,11 +9,11 @@ use ark_serialize::SerializationError; use bitvec::{slice::BitSlice, vec::BitVec}; use digest::generic_array::GenericArray; -use ethereum_types::U256; use jf_signature::{ bls_over_bn254::{BLSOverBN254CurveSignatureScheme, KeyPair, SignKey, VerKey}, SignatureError, SignatureScheme, }; +use primitive_types::U256; use rand::SeedableRng; use rand_chacha::ChaCha20Rng; use tracing::instrument; diff --git a/crates/types/src/simple_certificate.rs b/crates/types/src/simple_certificate.rs index bbdc88eb05..a4dcc9ec7b 100644 --- a/crates/types/src/simple_certificate.rs +++ b/crates/types/src/simple_certificate.rs @@ -16,7 +16,7 @@ use std::{ use anyhow::{ensure, Result}; use async_lock::RwLock; use committable::{Commitment, Committable}; -use ethereum_types::U256; +use primitive_types::U256; use serde::{Deserialize, Serialize}; use crate::{ diff --git a/crates/types/src/stake_table.rs b/crates/types/src/stake_table.rs index eddfd1caef..106894c4ac 100644 --- a/crates/types/src/stake_table.rs +++ b/crates/types/src/stake_table.rs @@ -6,7 +6,7 @@ //! Types and structs related to the stake table -use ethereum_types::U256; +use primitive_types::U256; use serde::{Deserialize, Serialize}; use crate::traits::signature_key::{SignatureKey, StakeTableEntryType}; diff --git a/crates/types/src/traits/network.rs b/crates/types/src/traits/network.rs index 27fe0ec3c9..2cd17381aa 100644 --- a/crates/types/src/traits/network.rs +++ b/crates/types/src/traits/network.rs @@ -9,7 +9,6 @@ //! Contains types and traits used by `HotShot` to abstract over network access use async_compatibility_layer::art::async_sleep; -use derivative::Derivative; use dyn_clone::DynClone; use futures::Future; use thiserror::Error; @@ -133,7 +132,7 @@ pub trait ViewMessage { } /// A request for some data that the consensus layer is asking for. -#[derive(Serialize, Deserialize, Derivative, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(bound(deserialize = ""))] pub struct DataRequest { /// Request @@ -146,7 +145,7 @@ pub struct DataRequest { } /// Underlying data request -#[derive(Serialize, Deserialize, Derivative, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] pub enum RequestKind { /// Request VID data by our key and the VID commitment Vid(TYPES::View, TYPES::SignatureKey), @@ -158,7 +157,7 @@ pub enum RequestKind { /// A response for a request. `SequencingMessage` is the same as other network messages /// The kind of message `M` is is determined by what we requested -#[derive(Serialize, Deserialize, Derivative, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(bound(deserialize = ""))] #[allow(clippy::large_enum_variant)] /// TODO: Put `Found` content in a `Box` to make enum smaller diff --git a/crates/types/src/traits/signature_key.rs b/crates/types/src/traits/signature_key.rs index e9133e9286..b6184cfcb2 100644 --- a/crates/types/src/traits/signature_key.rs +++ b/crates/types/src/traits/signature_key.rs @@ -17,8 +17,8 @@ use std::{ use ark_serialize::SerializationError; use bitvec::prelude::*; use committable::Committable; -use ethereum_types::U256; use jf_vid::VidScheme; +use primitive_types::U256; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use tagged_base64::TaggedBase64; diff --git a/crates/types/src/utils.rs b/crates/types/src/utils.rs index e3d19a8286..ea20ee9280 100644 --- a/crates/types/src/utils.rs +++ b/crates/types/src/utils.rs @@ -6,7 +6,11 @@ //! Utility functions, type aliases, helper structs and enum definitions. -use std::{ops::Deref, sync::Arc}; +use std::{ + hash::{Hash, Hasher}, + ops::Deref, + sync::Arc, +}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use bincode::{ @@ -210,3 +214,11 @@ pub fn bincode_opts() -> WithOtherTrailing< .with_fixint_encoding() .reject_trailing_bytes() } + +/// A function for generating a cute little user mnemonic from a hash +#[must_use] +pub fn mnemonic(bytes: H) -> String { + let mut state = std::collections::hash_map::DefaultHasher::new(); + bytes.hash(&mut state); + mnemonic::to_string(state.finish().to_le_bytes()) +} diff --git a/crates/types/src/vote.rs b/crates/types/src/vote.rs index 882512eae9..02773be134 100644 --- a/crates/types/src/vote.rs +++ b/crates/types/src/vote.rs @@ -15,7 +15,7 @@ use anyhow::Result; use bitvec::{bitvec, vec::BitVec}; use committable::{Commitment, Committable}; use either::Either; -use ethereum_types::U256; +use primitive_types::U256; use tracing::error; use crate::{