From e9616d08fa9308d461b3f73be31f1afc0f004482 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Wed, 30 Oct 2024 02:01:46 +0400 Subject: [PATCH] extract timing-utils crate (#3327) * extract timing-utils crate * missing dev dep * sort deps * typo * remove solana-logger dep * rename to solana-time-utils * update time-utils version --- Cargo.lock | 5 +++++ Cargo.toml | 2 ++ programs/sbf/Cargo.lock | 5 +++++ sdk/Cargo.toml | 1 + sdk/src/lib.rs | 3 ++- sdk/time-utils/Cargo.toml | 16 ++++++++++++++++ sdk/{src/timing.rs => time-utils/src/lib.rs} | 3 +-- 7 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 sdk/time-utils/Cargo.toml rename sdk/{src/timing.rs => time-utils/src/lib.rs} (98%) diff --git a/Cargo.lock b/Cargo.lock index 91a9f007a306ff..0d522ff3580112 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8070,6 +8070,7 @@ dependencies = [ "solana-serde-varint", "solana-short-vec", "solana-signature", + "solana-time-utils", "solana-transaction-error", "static_assertions", "thiserror", @@ -8529,6 +8530,10 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-time-utils" +version = "2.2.0" + [[package]] name = "solana-timings" version = "2.2.0" diff --git a/Cargo.toml b/Cargo.toml index af053d9745d203..51b9aa1c42fb09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,6 +144,7 @@ members = [ "sdk/slot-history", "sdk/stable-layout", "sdk/sysvar-id", + "sdk/time-utils", "sdk/transaction-error", "send-transaction-service", "short-vec", @@ -483,6 +484,7 @@ solana-sha256-hasher = { path = "sdk/sha256-hasher", version = "=2.2.0" } solana-signature = { path = "sdk/signature", version = "=2.2.0", default-features = false } solana-slot-hashes = { path = "sdk/slot-hashes", version = "=2.2.0" } solana-slot-history = { path = "sdk/slot-history", version = "=2.2.0" } +solana-time-utils = { path = "sdk/time-utils", version = "=2.2.0" } solana-timings = { path = "timings", version = "=2.2.0" } solana-unified-scheduler-logic = { path = "unified-scheduler-logic", version = "=2.2.0" } solana-unified-scheduler-pool = { path = "unified-scheduler-pool", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index ad5da64434aabd..17ca6b9ee419b9 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -6819,6 +6819,7 @@ dependencies = [ "solana-serde-varint", "solana-short-vec", "solana-signature", + "solana-time-utils", "solana-transaction-error", "thiserror", "wasm-bindgen", @@ -7144,6 +7145,10 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-time-utils" +version = "2.2.0" + [[package]] name = "solana-timings" version = "2.2.0" diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 59e9cfabbbfe22..bfbfef5ffc9a69 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -119,6 +119,7 @@ solana-signature = { workspace = true, features = [ "std", "verify", ], optional = true } +solana-time-utils = { workspace = true } solana-transaction-error = { workspace = true, features = ["serde"], optional = true } thiserror = { workspace = true } diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 7b5b8e472ea602..d087624aab1195 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -97,7 +97,6 @@ pub mod signature; pub mod signer; pub mod simple_vote_transaction_checker; pub mod system_transaction; -pub mod timing; pub mod transaction; pub mod transaction_context; pub mod transport; @@ -175,6 +174,8 @@ pub use solana_secp256k1_recover as secp256k1_recover; pub use solana_serde_varint as serde_varint; #[deprecated(since = "2.1.0", note = "Use `solana-short-vec` crate instead")] pub use solana_short_vec as short_vec; +#[deprecated(since = "2.2.0", note = "Use `solana-time-utils` crate instead")] +pub use solana_time_utils as timing; /// Convenience macro for `AddAssign` with saturating arithmetic. /// Replace by `std::num::Saturating` once stable diff --git a/sdk/time-utils/Cargo.toml b/sdk/time-utils/Cargo.toml new file mode 100644 index 00000000000000..e2b97725ecd13e --- /dev/null +++ b/sdk/time-utils/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "solana-time-utils" +description = "`std::time` utilities for Solana" +documentation = "https://docs.rs/solana-time-utils" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[lints] +workspace = true diff --git a/sdk/src/timing.rs b/sdk/time-utils/src/lib.rs similarity index 98% rename from sdk/src/timing.rs rename to sdk/time-utils/src/lib.rs index 526c9cb66adf0f..4cc6caabff193c 100644 --- a/sdk/src/timing.rs +++ b/sdk/time-utils/src/lib.rs @@ -1,4 +1,4 @@ -//! The `timing` module provides std::time utility functions. +//! `std::time` utility functions. use std::{ sync::atomic::{AtomicU64, Ordering}, time::{Duration, SystemTime, UNIX_EPOCH}, @@ -103,7 +103,6 @@ mod test { #[test] fn test_interval_update() { - solana_logger::setup(); let i = AtomicInterval::default(); assert!(!i.should_update(1000));