diff --git a/Cargo.lock b/Cargo.lock
index f1d69dc5b..4ea7bc865 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -717,6 +717,7 @@ name = "clarity"
version = "0.0.1"
dependencies = [
"assert-json-diff",
+ "hashbrown 0.14.3",
"integer-sqrt",
"lazy_static",
"rand 0.8.5",
@@ -2756,6 +2757,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "relay-server"
version = "0.0.1"
+dependencies = [
+ "hashbrown 0.14.3",
+]
[[package]]
name = "reqwest"
@@ -3452,6 +3456,7 @@ dependencies = [
"chrono",
"curve25519-dalek 2.0.0",
"ed25519-dalek",
+ "hashbrown 0.14.3",
"lazy_static",
"libc",
"nix",
diff --git a/Cargo.toml b/Cargo.toml
index 1d447d00c..b6606497c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,11 +14,12 @@ members = [
# Dependencies we want to keep the same between workspace members
[workspace.dependencies]
-wsts = { version = "8.1", default-features = false }
ed25519-dalek = { version = "2.1.1", features = ["serde", "rand_core"] }
+hashbrown = "0.14.3"
rand_core = "0.6"
rand = "0.8"
rand_chacha = "0.3.1"
+wsts = { version = "8.1", default-features = false }
# Use a bit more than default optimization for
# dev builds to speed up test execution
diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml
index eb8bcad38..c0b82a7fd 100644
--- a/clarity/Cargo.toml
+++ b/clarity/Cargo.toml
@@ -30,6 +30,7 @@ slog = { version = "2.5.2", features = [ "max_level_trace" ] }
stacks_common = { package = "stacks-common", path = "../stacks-common" }
rstest = "0.17.0"
rstest_reuse = "0.5.0"
+hashbrown = { workspace = true }
[dependencies.serde_json]
version = "1.0"
diff --git a/clarity/src/vm/analysis/analysis_db.rs b/clarity/src/vm/analysis/analysis_db.rs
index 0fe0a83d5..1bef2834a 100644
--- a/clarity/src/vm/analysis/analysis_db.rs
+++ b/clarity/src/vm/analysis/analysis_db.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, BTreeSet, HashMap};
+use std::collections::{BTreeMap, BTreeSet};
use stacks_common::types::StacksEpochId;
diff --git a/clarity/src/vm/analysis/arithmetic_checker/mod.rs b/clarity/src/vm/analysis/arithmetic_checker/mod.rs
index c38451c74..5595905a4 100644
--- a/clarity/src/vm/analysis/arithmetic_checker/mod.rs
+++ b/clarity/src/vm/analysis/arithmetic_checker/mod.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
+use hashbrown::HashMap;
pub use super::errors::{
check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult,
diff --git a/clarity/src/vm/analysis/read_only_checker/mod.rs b/clarity/src/vm/analysis/read_only_checker/mod.rs
index 8261eb8ee..c34692d55 100644
--- a/clarity/src/vm/analysis/read_only_checker/mod.rs
+++ b/clarity/src/vm/analysis/read_only_checker/mod.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
pub use super::errors::{
diff --git a/clarity/src/vm/analysis/trait_checker/mod.rs b/clarity/src/vm/analysis/trait_checker/mod.rs
index 811d436a1..835749671 100644
--- a/clarity/src/vm/analysis/trait_checker/mod.rs
+++ b/clarity/src/vm/analysis/trait_checker/mod.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
diff --git a/clarity/src/vm/analysis/type_checker/contexts.rs b/clarity/src/vm/analysis/type_checker/contexts.rs
index 03968a186..b56214807 100644
--- a/clarity/src/vm/analysis/type_checker/contexts.rs
+++ b/clarity/src/vm/analysis/type_checker/contexts.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
diff --git a/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs b/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs
index 8e23dd082..2a11f6839 100644
--- a/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs
+++ b/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs
@@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, HashMap, HashSet};
+use std::collections::BTreeMap;
+
+use hashbrown::{HashMap, HashSet};
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::types::ContractAnalysis;
diff --git a/clarity/src/vm/analysis/type_checker/v2_05/mod.rs b/clarity/src/vm/analysis/type_checker/v2_05/mod.rs
index 9ea729d47..27d32ee31 100644
--- a/clarity/src/vm/analysis/type_checker/v2_05/mod.rs
+++ b/clarity/src/vm/analysis/type_checker/v2_05/mod.rs
@@ -18,9 +18,10 @@ pub mod contexts;
//mod maps;
pub mod natives;
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
use std::convert::TryInto;
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use self::contexts::ContractContext;
diff --git a/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs b/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs
index 95b856b88..8cbed1a41 100644
--- a/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs
+++ b/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs
@@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, HashMap, HashSet};
+use std::collections::BTreeMap;
+
+use hashbrown::{HashMap, HashSet};
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::types::ContractAnalysis;
diff --git a/clarity/src/vm/analysis/type_checker/v2_1/mod.rs b/clarity/src/vm/analysis/type_checker/v2_1/mod.rs
index e87db175a..993f9f73c 100644
--- a/clarity/src/vm/analysis/type_checker/v2_1/mod.rs
+++ b/clarity/src/vm/analysis/type_checker/v2_1/mod.rs
@@ -17,9 +17,10 @@
pub mod contexts;
pub mod natives;
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
use std::convert::TryInto;
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use self::contexts::ContractContext;
diff --git a/clarity/src/vm/analysis/types.rs b/clarity/src/vm/analysis/types.rs
index 2471919b5..f2723289f 100644
--- a/clarity/src/vm/analysis/types.rs
+++ b/clarity/src/vm/analysis/types.rs
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, BTreeSet, HashMap};
+use std::collections::{BTreeMap, BTreeSet};
+use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use crate::vm::analysis::analysis_db::AnalysisDatabase;
diff --git a/clarity/src/vm/ast/definition_sorter/mod.rs b/clarity/src/vm/ast/definition_sorter/mod.rs
index 73bba88ab..19dcf1254 100644
--- a/clarity/src/vm/ast/definition_sorter/mod.rs
+++ b/clarity/src/vm/ast/definition_sorter/mod.rs
@@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
+use hashbrown::{HashMap, HashSet};
+
use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult};
use crate::vm::ast::types::{BuildASTPass, ContractAST};
use crate::vm::costs::cost_functions::ClarityCostFunction;
diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs
index d1c21b507..1cff95969 100644
--- a/clarity/src/vm/ast/mod.rs
+++ b/clarity/src/vm/ast/mod.rs
@@ -319,8 +319,7 @@ pub fn build_ast(
#[cfg(test)]
mod test {
- use std::collections::HashMap;
-
+ use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;
use crate::vm::ast::errors::ParseErrors;
diff --git a/clarity/src/vm/ast/sugar_expander/mod.rs b/clarity/src/vm/ast/sugar_expander/mod.rs
index 9ec552b34..481e1039d 100644
--- a/clarity/src/vm/ast/sugar_expander/mod.rs
+++ b/clarity/src/vm/ast/sugar_expander/mod.rs
@@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
+use hashbrown::{HashMap, HashSet};
+
use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult};
use crate::vm::ast::types::{BuildASTPass, ContractAST, PreExpressionsDrain};
use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed};
diff --git a/clarity/src/vm/ast/traits_resolver/mod.rs b/clarity/src/vm/ast/traits_resolver/mod.rs
index 2fcb271d5..7c4cdbf95 100644
--- a/clarity/src/vm/ast/traits_resolver/mod.rs
+++ b/clarity/src/vm/ast/traits_resolver/mod.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{HashMap, HashSet};
+use hashbrown::{HashMap, HashSet};
use crate::vm::analysis::AnalysisDatabase;
use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult};
diff --git a/clarity/src/vm/ast/types.rs b/clarity/src/vm/ast/types.rs
index 79c5513b3..e8183220a 100644
--- a/clarity/src/vm/ast/types.rs
+++ b/clarity/src/vm/ast/types.rs
@@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{HashMap, HashSet};
use std::vec::Drain;
+use hashbrown::{HashMap, HashSet};
+
use crate::vm::ast::errors::ParseResult;
use crate::vm::representations::{PreSymbolicExpression, SymbolicExpression, TraitDefinition};
use crate::vm::types::signatures::FunctionSignature;
diff --git a/clarity/src/vm/callables.rs b/clarity/src/vm/callables.rs
index 764c1479b..077a44087 100644
--- a/clarity/src/vm/callables.rs
+++ b/clarity/src/vm/callables.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
use std::convert::TryInto;
use std::fmt;
use std::iter::FromIterator;
diff --git a/clarity/src/vm/contexts.rs b/clarity/src/vm/contexts.rs
index c007ee255..3276c61b6 100644
--- a/clarity/src/vm/contexts.rs
+++ b/clarity/src/vm/contexts.rs
@@ -14,11 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+use std::collections::{BTreeMap, BTreeSet};
use std::convert::TryInto;
use std::fmt;
use std::mem::replace;
+use hashbrown::{HashMap, HashSet};
use serde::Serialize;
use serde_json::json;
use stacks_common::consts::CHAIN_ID_TESTNET;
@@ -277,7 +278,7 @@ impl AssetMap {
amount: u128,
) -> Result {
let current_amount = match self.token_map.get(principal) {
- Some(principal_map) => *principal_map.get(&asset).unwrap_or(&0),
+ Some(principal_map) => *principal_map.get(asset).unwrap_or(&0),
None => 0,
};
@@ -1948,7 +1949,7 @@ impl CallStack {
)
.into());
}
- if tracked && !self.set.remove(&function) {
+ if tracked && !self.set.remove(function) {
return Err(InterpreterError::InterpreterError(
"Tried to remove tracked function from call stack, but could not find in current context.".into()
)
diff --git a/clarity/src/vm/costs/mod.rs b/clarity/src/vm/costs/mod.rs
index 96a501809..2222aa4c1 100644
--- a/clarity/src/vm/costs/mod.rs
+++ b/clarity/src/vm/costs/mod.rs
@@ -14,10 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
use std::convert::{TryFrom, TryInto};
use std::{cmp, fmt};
+use hashbrown::HashMap;
use lazy_static::lazy_static;
use rusqlite::types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use serde::{Deserialize, Serialize};
@@ -814,7 +815,7 @@ impl TrackerData {
let mut cost_contracts = HashMap::new();
let mut m = HashMap::new();
for f in ClarityCostFunction::ALL.iter() {
- let cost_function_ref = cost_function_references.remove(&f).unwrap_or_else(|| {
+ let cost_function_ref = cost_function_references.remove(f).unwrap_or_else(|| {
ClarityCostFunctionReference::new(boot_costs_id.clone(), f.get_name())
});
if !cost_contracts.contains_key(&cost_function_ref.contract_id) {
diff --git a/clarity/src/vm/coverage.rs b/clarity/src/vm/coverage.rs
index bfb01e89c..6f2de9f5c 100644
--- a/clarity/src/vm/coverage.rs
+++ b/clarity/src/vm/coverage.rs
@@ -1,7 +1,8 @@
-use std::collections::{BTreeMap, HashMap, HashSet};
+use std::collections::BTreeMap;
use std::fs::File;
use std::io::Write;
+use hashbrown::{HashMap, HashSet};
use serde_json::Value as JsonValue;
use super::functions::define::DefineFunctionsParsed;
diff --git a/clarity/src/vm/database/clarity_db.rs b/clarity/src/vm/database/clarity_db.rs
index 3d6cf40ae..5ef6c458d 100644
--- a/clarity/src/vm/database/clarity_db.rs
+++ b/clarity/src/vm/database/clarity_db.rs
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{HashMap, VecDeque};
use std::convert::{TryFrom, TryInto};
use serde_json;
diff --git a/clarity/src/vm/database/key_value_wrapper.rs b/clarity/src/vm/database/key_value_wrapper.rs
index 74b2c724f..bc4b85a9b 100644
--- a/clarity/src/vm/database/key_value_wrapper.rs
+++ b/clarity/src/vm/database/key_value_wrapper.rs
@@ -16,9 +16,9 @@
use std::clone::Clone;
use std::cmp::Eq;
-use std::collections::HashMap;
use std::hash::Hash;
+use hashbrown::HashMap;
use stacks_common::types::chainstate::StacksBlockId;
use stacks_common::types::StacksEpochId;
use stacks_common::util::hash::Sha512Trunc256Sum;
diff --git a/clarity/src/vm/database/mod.rs b/clarity/src/vm/database/mod.rs
index e02aee5c3..109299298 100644
--- a/clarity/src/vm/database/mod.rs
+++ b/clarity/src/vm/database/mod.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
+use hashbrown::HashMap;
pub use self::clarity_db::{
BurnStateDB, ClarityDatabase, HeadersDB, StoreType, NULL_BURN_STATE_DB, NULL_HEADER_DB,
diff --git a/clarity/src/vm/docs/contracts.rs b/clarity/src/vm/docs/contracts.rs
index ff864b26d..b9f95d39d 100644
--- a/clarity/src/vm/docs/contracts.rs
+++ b/clarity/src/vm/docs/contracts.rs
@@ -1,6 +1,7 @@
-use std::collections::{BTreeMap, HashMap, HashSet};
+use std::collections::BTreeMap;
use std::iter::FromIterator;
+use hashbrown::{HashMap, HashSet};
use stacks_common::consts::CHAIN_ID_TESTNET;
use stacks_common::types::StacksEpochId;
diff --git a/clarity/src/vm/functions/define.rs b/clarity/src/vm/functions/define.rs
index 9451f17ff..c9489c432 100644
--- a/clarity/src/vm/functions/define.rs
+++ b/clarity/src/vm/functions/define.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
use crate::vm::callables::{DefineType, DefinedFunction};
use crate::vm::contexts::{ContractContext, Environment, LocalContext};
diff --git a/clarity/src/vm/mod.rs b/clarity/src/vm/mod.rs
index 9f7c56559..7231ad584 100644
--- a/clarity/src/vm/mod.rs
+++ b/clarity/src/vm/mod.rs
@@ -587,8 +587,7 @@ pub fn execute_v2(program: &str) -> Result