Skip to content
Open
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
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ exclude = ["contrib/tools/config-docs-generator"]
[workspace.dependencies]
ed25519-dalek = { version = "2.1.1", default-features = false }
hashbrown = { version = "0.15.2", features = ["serde"] }
lazy_static = "1.4.0"
pinny = { git = "https://github.com/stx-labs/pinny-rs.git", rev = "54ba9d533a7b84525a5e65a3eae1a3ae76b9ea49" } #v0.0.2
rand_core = "0.6.4"
rand = "0.8"
Expand Down
1 change: 0 additions & 1 deletion clarity-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized"
readme = "README.md"

[dependencies]
lazy_static = { workspace = true }
regex = { version = "1", default-features = false }
rusqlite = { workspace = true, optional = true }
serde = { workspace = true }
Expand Down
32 changes: 13 additions & 19 deletions clarity-types/src/representations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,42 @@ use std::fmt;
use std::io::{Read, Write};
use std::ops::Deref;

use lazy_static::lazy_static;
use regex::Regex;
use stacks_common::codec::{Error as codec_error, StacksMessageCodec, read_next, write_next};

use crate::Value;
use crate::errors::ClarityTypeError;
use crate::types::TraitIdentifier;
use std::sync::LazyLock;

pub const CONTRACT_MIN_NAME_LENGTH: usize = 1;
pub const CONTRACT_MAX_NAME_LENGTH: usize = 40;
pub const MAX_STRING_LEN: u8 = 128;

lazy_static! {
pub static ref STANDARD_PRINCIPAL_REGEX_STRING: String =
"[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}".into();
pub static ref CONTRACT_NAME_REGEX_STRING: String = format!(
pub static STANDARD_PRINCIPAL_REGEX_STRING: LazyLock<String> = LazyLock::new(|| "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}".into());
pub static CONTRACT_NAME_REGEX_STRING: LazyLock<String> = LazyLock::new(|| format!(
r#"([a-zA-Z](([a-zA-Z0-9]|[-_])){{{},{}}})"#,
CONTRACT_MIN_NAME_LENGTH - 1,
// NOTE: this is deliberate. Earlier versions of the node will accept contract principals whose names are up to
// 128 bytes. This behavior must be preserved for backwards-compatibility.
MAX_STRING_LEN - 1
);
pub static ref CONTRACT_PRINCIPAL_REGEX_STRING: String = format!(
));
pub static CONTRACT_PRINCIPAL_REGEX_STRING: LazyLock<String> = LazyLock::new(|| format!(
r#"{}(\.){}"#,
*STANDARD_PRINCIPAL_REGEX_STRING, *CONTRACT_NAME_REGEX_STRING
);
pub static ref PRINCIPAL_DATA_REGEX_STRING: String = format!(
));
pub static PRINCIPAL_DATA_REGEX_STRING: LazyLock<String> = LazyLock::new(|| format!(
"({})|({})",
*STANDARD_PRINCIPAL_REGEX_STRING, *CONTRACT_PRINCIPAL_REGEX_STRING
);
pub static ref CLARITY_NAME_REGEX_STRING: String =
"^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$".into();
pub static ref CLARITY_NAME_REGEX: Regex =
{
));
pub static CLARITY_NAME_REGEX_STRING: LazyLock<String> = LazyLock::new(|| "^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$".into());
pub static CLARITY_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(CLARITY_NAME_REGEX_STRING.as_str()).unwrap()
};
pub static ref CONTRACT_NAME_REGEX: Regex =
{
});
pub static CONTRACT_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(format!("^{}$|^__transient$", CONTRACT_NAME_REGEX_STRING.as_str()).as_str())
.unwrap()
};
}
});

guarded_string!(
ClarityName,
Expand Down
8 changes: 3 additions & 5 deletions clarity-types/src/types/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use std::io::{Read, Write};
use std::{cmp, error, str};

use lazy_static::lazy_static;
use stacks_common::codec::{Error as codec_error, StacksMessageCodec};
use stacks_common::types::StacksEpochId;
use stacks_common::util::hash::{hex_bytes, to_hex};
Expand All @@ -30,6 +29,7 @@ use crate::types::{
MAX_VALUE_SIZE, OptionalData, PrincipalData, QualifiedContractIdentifier, SequenceData,
SequenceSubtype, StandardPrincipalData, StringSubtype, TupleData, TypeSignature, Value,
};
use std::sync::LazyLock;

/// Errors that may occur in serialization or deserialization
/// If deserialization failed because the described type is a bad type and
Expand All @@ -48,12 +48,10 @@ pub enum SerializationError {
UnexpectedSerialization,
}

lazy_static! {
pub static ref NONE_SERIALIZATION_LEN: u64 = {
pub static NONE_SERIALIZATION_LEN: LazyLock<u64> = LazyLock::new(|| {
#[allow(clippy::unwrap_used)]
u64::try_from(Value::none().serialize_to_vec().unwrap().len()).unwrap()
};
}
});

/// Deserialization uses a specific epoch for passing to the type signature checks
/// The reason this is pinned to Epoch21 is so that values stored before epoch-2.4
Expand Down
1 change: 0 additions & 1 deletion clarity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
regex = "1"
lazy_static = { workspace = true }
integer-sqrt = "0.1.3"
slog = { workspace = true }
stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false }
Expand Down
27 changes: 11 additions & 16 deletions clarity/src/vm/ast/parser/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use lazy_static::lazy_static;
use regex::{Captures, Regex};
use stacks_common::util::hash::hex_bytes;

Expand All @@ -24,6 +23,7 @@ use crate::vm::representations::{
ClarityName, ContractName, MAX_STRING_LEN, PreSymbolicExpression,
};
use crate::vm::types::{PrincipalData, TraitIdentifier, Value};
use std::sync::LazyLock;

pub const CONTRACT_MIN_NAME_LENGTH: usize = 1;
pub const CONTRACT_MAX_NAME_LENGTH: usize = 40;
Expand Down Expand Up @@ -107,26 +107,22 @@ fn get_lines_at(input: &str) -> Vec<usize> {
out
}

lazy_static! {
pub static ref STANDARD_PRINCIPAL_REGEX: String =
"[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}".into();
pub static ref CONTRACT_NAME_REGEX: String = format!(
pub static STANDARD_PRINCIPAL_REGEX: LazyLock<String> = LazyLock::new(|| "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}".into());
pub static CONTRACT_NAME_REGEX: LazyLock<String> = LazyLock::new(|| format!(
r#"([a-zA-Z](([a-zA-Z0-9]|[-_])){{{},{}}})"#,
CONTRACT_MIN_NAME_LENGTH - 1,
CONTRACT_MAX_NAME_LENGTH - 1
);
pub static ref CONTRACT_PRINCIPAL_REGEX: String = format!(
));
pub static CONTRACT_PRINCIPAL_REGEX: LazyLock<String> = LazyLock::new(|| format!(
r#"{}(\.){}"#,
*STANDARD_PRINCIPAL_REGEX, *CONTRACT_NAME_REGEX
);
pub static ref PRINCIPAL_DATA_REGEX: String = format!(
));
pub static PRINCIPAL_DATA_REGEX: LazyLock<String> = LazyLock::new(|| format!(
"({})|({})",
*STANDARD_PRINCIPAL_REGEX, *CONTRACT_PRINCIPAL_REGEX
);
pub static ref CLARITY_NAME_REGEX: String =
format!(r#"([[:word:]]|[-!?+<>=/*]){{1,{MAX_STRING_LEN}}}"#);

static ref lex_matchers: Vec<LexMatcher> = vec![
));
pub static CLARITY_NAME_REGEX: LazyLock<String> = LazyLock::new(|| format!(r#"([[:word:]]|[-!?+<>=/*]){{1,{MAX_STRING_LEN}}}"#));
static lex_matchers: LazyLock<Vec<LexMatcher>> = LazyLock::new(|| vec![
LexMatcher::new(
r#"u"(?P<value>((\\")|([[ -~]&&[^"]]))*)""#,
TokenType::StringUTF8Literal,
Expand Down Expand Up @@ -181,8 +177,7 @@ lazy_static! {
&format!("(?P<value>{})", *CLARITY_NAME_REGEX),
TokenType::Variable,
),
];
}
]);

/// Lex the contract, permitting nesting of lists and tuples up to
/// `depth_limits.max_nesting_depth()`.
Expand Down
8 changes: 3 additions & 5 deletions clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use costs_2::Costs2;
use costs_2_testnet::Costs2Testnet;
use costs_3::Costs3;
use costs_4::Costs4;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use stacks_common::types::StacksEpochId;

Expand All @@ -42,6 +41,7 @@ use crate::vm::types::{
FunctionType, PrincipalData, QualifiedContractIdentifier, TupleData, TypeSignature,
};
use crate::vm::{CallStack, ClarityName, LocalContext, SymbolicExpression, Value};
use std::sync::LazyLock;
pub mod constants;
pub mod cost_functions;
#[allow(unused_variables)]
Expand All @@ -65,8 +65,7 @@ pub const COSTS_2_NAME: &str = "costs-2";
pub const COSTS_3_NAME: &str = "costs-3";
pub const COSTS_4_NAME: &str = "costs-4";

lazy_static! {
static ref COST_TUPLE_TYPE_SIGNATURE: TypeSignature = {
static COST_TUPLE_TYPE_SIGNATURE: LazyLock<TypeSignature> = LazyLock::new(|| {
#[allow(clippy::expect_used)]
TypeSignature::TupleType(
TupleTypeSignature::try_from(vec![
Expand All @@ -93,8 +92,7 @@ lazy_static! {
])
.expect("BUG: failed to construct type signature for cost tuple"),
)
};
}
});

pub fn runtime_cost<T: TryInto<u64>, C: CostTracker>(
cost_function: ClarityCostFunction,
Expand Down
1 change: 0 additions & 1 deletion contrib/clarity-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ clarity = { path = "../../clarity", default-features = false }
stackslib = { package = "stackslib", path = "../../stackslib", default-features = false }
stacks-common = { path = "../../stacks-common", default-features = false }
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
lazy_static = { version = "1.4.0", default-features = false }
serde = { version = "1" }
serde_derive = "1"
serde_json = { workspace = true }
Expand Down
12 changes: 5 additions & 7 deletions contrib/clarity-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use clarity::vm::{
ClarityVersion, ContractContext, ContractName, SymbolicExpression, Value, analysis, ast,
eval_all,
};
use lazy_static::lazy_static;
use rand::Rng;
use rusqlite::{Connection, OpenFlags};
use serde::Deserialize;
Expand All @@ -61,9 +60,9 @@ use stackslib::clarity_vm::database::marf::{MarfedKV, PersistentWritableMarfStor
use stackslib::core::{BLOCK_LIMIT_MAINNET_205, HELIUM_BLOCK_LIMIT_20, StacksEpochId};
use stackslib::util_lib::boot::{boot_code_addr, boot_code_id};
use stackslib::util_lib::db::{FromColumn, sqlite_open};
use std::sync::LazyLock;

lazy_static! {
pub static ref STACKS_BOOT_CODE_MAINNET_2_1: [(&'static str, &'static str); 10] = [
pub static STACKS_BOOT_CODE_MAINNET_2_1: LazyLock<[(&'static str, &'static str); 10]> = LazyLock::new(|| [
("pox", &BOOT_CODE_POX_MAINNET),
("lockup", BOOT_CODE_LOCKUP),
("costs", BOOT_CODE_COSTS),
Expand All @@ -74,8 +73,8 @@ lazy_static! {
("pox-2", &POX_2_MAINNET_CODE),
("costs-3", BOOT_CODE_COSTS_3),
("costs-4", BOOT_CODE_COSTS_4),
];
pub static ref STACKS_BOOT_CODE_TESTNET_2_1: [(&'static str, &'static str); 10] = [
]);
pub static STACKS_BOOT_CODE_TESTNET_2_1: LazyLock<[(&'static str, &'static str); 10]> = LazyLock::new(|| [
("pox", &BOOT_CODE_POX_TESTNET),
("lockup", BOOT_CODE_LOCKUP),
("costs", BOOT_CODE_COSTS),
Expand All @@ -86,8 +85,7 @@ lazy_static! {
("pox-2", &POX_2_TESTNET_CODE),
("costs-3", BOOT_CODE_COSTS_3),
("costs-4", BOOT_CODE_COSTS_4),
];
}
]);

#[cfg(test)]
macro_rules! panic_test {
Expand Down
1 change: 0 additions & 1 deletion stacks-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ chrono = { version = "0.4.41", default-features = false, features = ["clock"] }
curve25519-dalek = { version = "4.1.3", default-features = false, features = ["serde"] }
ed25519-dalek = { workspace = true }
hashbrown = { workspace = true }
lazy_static = { workspace = true }
ripemd = { version = "0.1.1", default-features = false }
serde = { workspace = true , features = ["derive"] }
serde_derive = { workspace = true }
Expand Down
12 changes: 4 additions & 8 deletions stacks-common/src/util/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ use std::time::{Duration, SystemTime};
use std::{env, io, thread};

use chrono::prelude::*;
use lazy_static::lazy_static;
use slog::{Drain, Level, Logger, OwnedKVList, Record, KV};
use slog_term::{CountingWriter, Decorator, RecordDecorator, Serializer};
use std::sync::LazyLock;

lazy_static! {
pub static ref LOGGER: Logger = make_logger();
pub static ref STACKS_LOG_FORMAT_TIME: Option<String> = env::var("STACKS_LOG_FORMAT_TIME").ok();
}
pub static LOGGER: LazyLock<Logger> = LazyLock::new(|| make_logger());
pub static STACKS_LOG_FORMAT_TIME: LazyLock<Option<String>> = LazyLock::new(|| env::var("STACKS_LOG_FORMAT_TIME").ok());
struct TermFormat<D: Decorator> {
decorator: D,
pretty_print: bool,
Expand Down Expand Up @@ -267,9 +265,7 @@ fn inner_get_loglevel() -> slog::Level {
}
}

lazy_static! {
static ref LOGLEVEL: slog::Level = inner_get_loglevel();
}
static LOGLEVEL: LazyLock<slog::Level> = LazyLock::new(|| inner_get_loglevel());

pub fn get_loglevel() -> slog::Level {
*LOGLEVEL
Expand Down
1 change: 0 additions & 1 deletion stacks-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Jude Nelson <jude@stacks.org>", "Aaron Blankstein <aaron@blockstack.
edition = "2021"

[dependencies]
lazy_static = "1.4.0"
pico-args = "0.5.0"
serde = "1"
serde_derive = "1"
Expand Down
6 changes: 1 addition & 5 deletions stacks-node/src/event_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use clarity::vm::costs::ExecutionCost;
use clarity::vm::events::{FTEventType, NFTEventType, STXEventType};
use clarity::vm::types::{AssetIdentifier, QualifiedContractIdentifier};
#[cfg(any(test, feature = "testing"))]
use lazy_static::lazy_static;
use rand::Rng;
use serde_json::json;
use stacks::burnchains::{PoxConstants, Txid};
Expand Down Expand Up @@ -82,10 +81,7 @@ use crate::event_dispatcher::db::PendingPayload;
mod tests;

#[cfg(any(test, feature = "testing"))]
lazy_static! {
/// Do not announce a signed/mined block to the network when set to true.
pub static ref TEST_SKIP_BLOCK_ANNOUNCEMENT: TestFlag<bool> = TestFlag::default();
}
pub static TEST_SKIP_BLOCK_ANNOUNCEMENT: LazyLock<TestFlag<bool>> = LazyLock::new(|| TestFlag::default());

#[derive(Debug)]
enum EventDispatcherError {
Expand Down
Loading