Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Move stake_weighted_timestamp module (backport #18114) (#18119)
Browse files Browse the repository at this point in the history
* Move stake_weighted_timestamp module (#18114)

* Move timestamp module into runtime

* Less public

* Remove unused enum

(cherry picked from commit 19fe1dd)

# Conflicts:
#	runtime/src/bank.rs
#	runtime/src/lib.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <[email protected]>
Co-authored-by: Tyera Eulberg <[email protected]>
  • Loading branch information
3 people authored Jun 22, 2021
1 parent 06d6e35 commit e259388
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
8 changes: 4 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<I, K, V, T>(
pub(crate) fn calculate_stake_weighted_timestamp<I, K, V, T>(
unique_timestamps: I,
stakes: &HashMap<Pubkey, (u64, T /*Account|ArcVoteAccount*/)>,
slot: Slot,
Expand Down
1 change: 0 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e259388

Please sign in to comment.