Remove archiver and storage program (#9992)

automerge
This commit is contained in:
Jack May
2020-05-14 18:22:47 -07:00
committed by GitHub
parent 9ef9969d29
commit eb1acaf927
117 changed files with 383 additions and 7735 deletions

View File

@ -1,4 +1,4 @@
//! Provides information about the network's clock which is made up of ticks, slots, segments, etc...
//! Provides information about the network's clock which is made up of ticks, slots, etc...
// The default tick rate that the cluster attempts to achieve. Note that the actual tick
// rate at any given time should be expected to drift
@ -22,9 +22,6 @@ pub const TICKS_PER_DAY: u64 = DEFAULT_TICKS_PER_SECOND * SECONDS_PER_DAY;
// 1 Epoch ~= 2 days
pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 2 * TICKS_PER_DAY / DEFAULT_TICKS_PER_SLOT;
// Storage segment configuration
pub const DEFAULT_SLOTS_PER_SEGMENT: u64 = 1024;
// 4 times longer than the max_lockout to allow enough time for PoRep (128 slots)
pub const DEFAULT_SLOTS_PER_TURN: u64 = 32 * 4;
@ -55,32 +52,10 @@ pub const MAX_TRANSACTION_FORWARDING_DELAY_GPU: usize = 2;
/// More delay is expected if CUDA is not enabled (as signature verification takes longer)
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 6;
/// Converts a slot to a storage segment. Does not indicate that a segment is complete.
pub fn get_segment_from_slot(rooted_slot: Slot, slots_per_segment: u64) -> Segment {
(rooted_slot + (slots_per_segment - 1)) / slots_per_segment
}
/// Given a slot returns the latest complete segment, if no segment could possibly be complete
/// for a given slot it returns `None` (i.e if `slot < slots_per_segment`)
pub fn get_complete_segment_from_slot(
rooted_slot: Slot,
slots_per_segment: u64,
) -> Option<Segment> {
let completed_segment = rooted_slot / slots_per_segment;
if rooted_slot < slots_per_segment {
None
} else {
Some(completed_segment)
}
}
/// Slot is a unit of time given to a leader for encoding,
/// is some some number of Ticks long.
pub type Slot = u64;
/// A segment is some number of slots stored by archivers
pub type Segment = u64;
/// Epoch is a unit of time a given leader schedule is honored,
/// some number of Slots.
pub type Epoch = u64;
@ -105,8 +80,8 @@ pub type UnixTimestamp = i64;
pub struct Clock {
/// the current network/bank Slot
pub slot: Slot,
/// the current Segment, used for archiver rounds
pub segment: Segment,
/// unused
pub unused: u64,
/// the bank Epoch
pub epoch: Epoch,
/// the future Epoch for which the leader schedule has
@ -116,29 +91,3 @@ pub struct Clock {
/// in slots, drifts!
pub unix_timestamp: UnixTimestamp,
}
#[cfg(test)]
mod tests {
use super::*;
fn get_segments(slot: Slot, slots_per_segment: u64) -> (Segment, Segment) {
(
get_segment_from_slot(slot, slots_per_segment),
get_complete_segment_from_slot(slot, slots_per_segment).unwrap(),
)
}
#[test]
fn test_complete_segment_impossible() {
// slot < slots_per_segment so there can be no complete segments
assert_eq!(get_complete_segment_from_slot(5, 10), None);
}
#[test]
fn test_segment_conversion() {
let (current, complete) = get_segments(2048, 1024);
assert_eq!(current, complete);
let (current, complete) = get_segments(2049, 1024);
assert!(complete < current);
}
}

View File

@ -2,7 +2,7 @@
use crate::{
account::Account,
clock::{UnixTimestamp, DEFAULT_SLOTS_PER_SEGMENT, DEFAULT_TICKS_PER_SLOT},
clock::{UnixTimestamp, DEFAULT_TICKS_PER_SLOT},
epoch_schedule::EpochSchedule,
fee_calculator::FeeRateGovernor,
hash::{hash, Hash},
@ -27,6 +27,9 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
// deprecated default that is no longer used
pub const UNUSED_DEFAULT: u64 = 1024;
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub enum OperatingMode {
Preview, // Next set of cluster features to be promoted to Stable
@ -45,7 +48,7 @@ pub struct GenesisConfig {
/// accounts for network rewards, these do not count towards capitalization
pub rewards_pools: BTreeMap<Pubkey, Account>,
pub ticks_per_slot: u64,
pub slots_per_segment: u64,
pub unused: u64,
/// network speed configuration
pub poh_config: PohConfig,
/// this field exists only to ensure that the binary layout of GenesisConfig remains compatible
@ -89,7 +92,7 @@ impl Default for GenesisConfig {
native_instruction_processors: Vec::default(),
rewards_pools: BTreeMap::default(),
ticks_per_slot: DEFAULT_TICKS_PER_SLOT,
slots_per_segment: DEFAULT_SLOTS_PER_SEGMENT,
unused: UNUSED_DEFAULT,
poh_config: PohConfig::default(),
inflation: Inflation::default(),
__backwards_compat_with_v0_23: 0,

View File

@ -8,19 +8,15 @@ crate::declare_sysvar_id!("SysvarRewards111111111111111111111111111111", Rewards
#[derive(Serialize, Deserialize, Debug, Default, PartialEq)]
pub struct Rewards {
pub validator_point_value: f64,
pub storage_point_value: f64,
pub unused: f64,
}
impl Sysvar for Rewards {}
pub fn create_account(
lamports: u64,
validator_point_value: f64,
storage_point_value: f64,
) -> Account {
pub fn create_account(lamports: u64, validator_point_value: f64) -> Account {
Rewards {
validator_point_value,
storage_point_value,
unused: 0.0,
}
.create_account(lamports)
}
@ -31,7 +27,7 @@ mod tests {
#[test]
fn test_create_account() {
let account = create_account(1, 0.0, 0.0);
let account = create_account(1, 0.0);
let rewards = Rewards::from_account(&account).unwrap();
assert_eq!(rewards, Rewards::default());
}