From e2593880696a1cc2cfb805bb9b2dd07fcc31cfd5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 22 Jun 2021 00:28:02 +0000 Subject: [PATCH] Move stake_weighted_timestamp module (backport #18114) (#18119) * Move stake_weighted_timestamp module (#18114) * Move timestamp module into runtime * Less public * Remove unused enum (cherry picked from commit 19fe1dd46327717e9a95f94db567fed96705624f) # Conflicts: # runtime/src/bank.rs # runtime/src/lib.rs * Fix conflicts Co-authored-by: Tyera Eulberg Co-authored-by: Tyera Eulberg --- runtime/src/bank.rs | 8 ++++---- runtime/src/lib.rs | 1 + {sdk => runtime}/src/stake_weighted_timestamp.rs | 15 +++++---------- sdk/src/lib.rs | 1 - 4 files changed, 10 insertions(+), 15 deletions(-) rename {sdk => runtime}/src/stake_weighted_timestamp.rs (98%) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 87ae83bad6..93e2469809 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -18,6 +18,10 @@ use crate::{ log_collector::LogCollector, message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor}, rent_collector::RentCollector, + stake_weighted_timestamp::{ + calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE, + MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW, + }, stakes::Stakes, status_cache::{SlotDelta, StatusCache}, system_instruction_processor::{get_system_account_kind, SystemAccountKind}, @@ -63,10 +67,6 @@ use solana_sdk::{ signature::{Keypair, Signature}, slot_hashes::SlotHashes, slot_history::SlotHistory, - stake_weighted_timestamp::{ - calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE, - MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW, - }, system_transaction, sysvar::{self}, timing::years_as_slots, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7c5c627904..d2224422b9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -31,6 +31,7 @@ pub mod secondary_index; pub mod serde_snapshot; pub mod snapshot_package; pub mod snapshot_utils; +pub mod stake_weighted_timestamp; pub mod stakes; pub mod status_cache; mod system_instruction_processor; diff --git a/sdk/src/stake_weighted_timestamp.rs b/runtime/src/stake_weighted_timestamp.rs similarity index 98% rename from sdk/src/stake_weighted_timestamp.rs rename to runtime/src/stake_weighted_timestamp.rs index 44478e2856..6674024686 100644 --- a/sdk/src/stake_weighted_timestamp.rs +++ b/runtime/src/stake_weighted_timestamp.rs @@ -11,22 +11,17 @@ use std::{ time::Duration, }; -pub const MAX_ALLOWABLE_DRIFT_PERCENTAGE: u32 = 50; -pub const MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST: u32 = 25; -pub const MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW: u32 = 80; - -pub enum EstimateType { - Bounded(MaxAllowableDrift), // Value represents max allowable drift percentage - Unbounded, // Deprecated. Remove in the Solana v1.6.0 timeframe -} +pub(crate) const MAX_ALLOWABLE_DRIFT_PERCENTAGE: u32 = 50; +pub(crate) const MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST: u32 = 25; +pub(crate) const MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW: u32 = 80; #[derive(Copy, Clone)] -pub struct MaxAllowableDrift { +pub(crate) struct MaxAllowableDrift { pub fast: u32, // Max allowable drift percentage faster than poh estimate pub slow: u32, // Max allowable drift percentage slower than poh estimate } -pub fn calculate_stake_weighted_timestamp( +pub(crate) fn calculate_stake_weighted_timestamp( unique_timestamps: I, stakes: &HashMap, slot: Slot, diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 16d531e541..722444c214 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -43,7 +43,6 @@ pub mod secp256k1_instruction; pub mod shred_version; pub mod signature; pub mod signer; -pub mod stake_weighted_timestamp; pub mod system_transaction; pub mod timing; pub mod transaction;