diff --git a/Cargo.lock b/Cargo.lock index dc4d871ed1a..8ba4064cd6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1272,6 +1272,15 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2470,6 +2479,7 @@ dependencies = [ name = "radix-rust" version = "1.3.0-dev" dependencies = [ + "fxhash", "hashbrown 0.13.2", "indexmap 2.2.6", "serde", diff --git a/radix-engine-tests/assets/blueprints/Cargo.lock b/radix-engine-tests/assets/blueprints/Cargo.lock index efb280d4a85..4f46139283d 100644 --- a/radix-engine-tests/assets/blueprints/Cargo.lock +++ b/radix-engine-tests/assets/blueprints/Cargo.lock @@ -115,6 +115,12 @@ dependencies = [ "scrypto", ] +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "cast" version = "1.0.0" @@ -384,6 +390,15 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -812,6 +827,7 @@ dependencies = [ name = "radix-rust" version = "1.3.0-dev" dependencies = [ + "fxhash", "indexmap", "serde", ] diff --git a/radix-engine-toolkit-common/src/receipt/receipt/runtime.rs b/radix-engine-toolkit-common/src/receipt/receipt/runtime.rs index b6fe00066ed..c27273f178d 100644 --- a/radix-engine-toolkit-common/src/receipt/receipt/runtime.rs +++ b/radix-engine-toolkit-common/src/receipt/receipt/runtime.rs @@ -130,7 +130,7 @@ impl TryFrom for RuntimeToolkitTransactionReceipt { .collect(), // We get the newly minted non-fungibles from the events. newly_minted_non_fungibles: application_events.iter().fold( - IndexSet::new(), + radix_rust::indexset!(), |mut acc, (EventTypeIdentifier(emitter, event_name), event_data)| { match emitter { Emitter::Method(node_id, ModuleId::Main) => { @@ -234,7 +234,7 @@ fn get_metadata_updates( .map(|partition_state_updates| (node_id, partition_state_updates)) }) .fold( - IndexMap::new(), + radix_rust::indexmap!(), |mut acc, (node_id, partition_state_updates)| { acc.entry(*node_id).or_default().extend( partition_state_updates diff --git a/radix-rust/Cargo.toml b/radix-rust/Cargo.toml index 5446e413080..ff5e980bf97 100644 --- a/radix-rust/Cargo.toml +++ b/radix-rust/Cargo.toml @@ -11,6 +11,7 @@ repository = "https://github.com/radixdlt/radixdlt-scrypto" serde = { workspace = true, optional = true } hashbrown = { workspace = true, optional = true } indexmap = { workspace = true } +fxhash = { version = "0.2.1" } [features] default = ["std"] diff --git a/radix-rust/src/rust.rs b/radix-rust/src/rust.rs index c28725c2857..86759aaaf2a 100644 --- a/radix-rust/src/rust.rs +++ b/radix-rust/src/rust.rs @@ -266,19 +266,19 @@ pub mod collections { #[cfg(all(not(feature = "fuzzing"), feature = "alloc"))] pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder; #[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))] - pub type DefaultHashBuilder = std::collections::hash_map::RandomState; + pub type DefaultHashBuilder = fxhash::FxBuildHasher; #[cfg(feature = "alloc")] pub use hashbrown::hash_map::*; #[cfg(not(feature = "alloc"))] pub use std::collections::hash_map::*; + #[cfg(not(feature = "alloc"))] + pub use fxhash::FxHashMap as ext_HashMap; #[cfg(feature = "alloc")] pub use hashbrown::HashMap as ext_HashMap; - #[cfg(not(feature = "alloc"))] - pub use std::collections::HashMap as ext_HashMap; - pub type HashMap = ext_HashMap; + pub type HashMap = ext_HashMap; /// Creates an empty map with capacity 0 and default Hasher pub fn new() -> HashMap { @@ -319,19 +319,19 @@ pub mod collections { #[cfg(all(not(feature = "fuzzing"), feature = "alloc"))] pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder; #[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))] - pub type DefaultHashBuilder = std::collections::hash_map::RandomState; + pub type DefaultHashBuilder = fxhash::FxBuildHasher; #[cfg(feature = "alloc")] pub use hashbrown::hash_set::*; #[cfg(not(feature = "alloc"))] pub use std::collections::hash_set::*; + #[cfg(not(feature = "alloc"))] + pub use fxhash::FxHashSet as ext_HashSet; #[cfg(feature = "alloc")] pub use hashbrown::HashSet as ext_HashSet; - #[cfg(not(feature = "alloc"))] - pub use std::collections::HashSet as ext_HashSet; - pub type HashSet = ext_HashSet; + pub type HashSet = ext_HashSet; /// Creates an empty set with capacity 0 and default Hasher pub fn new() -> HashSet { @@ -394,7 +394,7 @@ pub mod collections { #[cfg(all(not(feature = "fuzzing"), feature = "alloc"))] pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder; #[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))] - pub type DefaultHashBuilder = std::collections::hash_map::RandomState; + pub type DefaultHashBuilder = fxhash::FxBuildHasher; // See https://github.com/bluss/indexmap/pull/207 // By defining an alias with a default `DefaultHashBuilder`, we ensure that this type works as `IndexMap` and that the `FromIter` impl works in no-std. @@ -456,7 +456,7 @@ pub mod collections { #[cfg(all(not(feature = "fuzzing"), feature = "alloc"))] pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder; #[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))] - pub type DefaultHashBuilder = std::collections::hash_map::RandomState; + pub type DefaultHashBuilder = fxhash::FxBuildHasher; // See https://github.com/bluss/indexmap/pull/207 // By defining an alias with a default `DefaultHashBuilder`, we ensure that this type works as `IndexSet` and that the `FromIter` impl works in no-std. @@ -516,7 +516,7 @@ pub mod collections { #[cfg(all(not(feature = "fuzzing"), feature = "alloc"))] pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder; #[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))] - pub type DefaultHashBuilder = std::collections::hash_map::RandomState; + pub type DefaultHashBuilder = fxhash::FxBuildHasher; /// A thin wrapper around a `HashMap`, which guarantees that a `HashMap` usage will not /// result in a non-deterministic execution (simply by disallowing the iteration over its