@ -7,9 +7,11 @@ extern crate test;
|
||||
extern crate solana_ledger;
|
||||
|
||||
use rand::Rng;
|
||||
use solana_ledger::blocktree::{entries_to_test_shreds, get_tmp_ledger_path, Blocktree};
|
||||
use solana_ledger::entry::{create_ticks, Entry};
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_ledger::{
|
||||
blocktree::{entries_to_test_shreds, get_tmp_ledger_path, Blocktree},
|
||||
entry::{create_ticks, Entry},
|
||||
};
|
||||
use solana_sdk::{clock::Slot, hash::Hash};
|
||||
use std::path::Path;
|
||||
use test::Bencher;
|
||||
|
||||
@ -30,7 +32,7 @@ fn setup_read_bench(
|
||||
blocktree: &mut Blocktree,
|
||||
num_small_shreds: u64,
|
||||
num_large_shreds: u64,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
) {
|
||||
// Make some big and small entries
|
||||
let entries = create_ticks(
|
||||
|
@ -1,54 +1,58 @@
|
||||
use crate::chacha::{chacha_cbc_encrypt_ledger, CHACHA_BLOCK_SIZE};
|
||||
use crate::cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE};
|
||||
use crate::contact_info::ContactInfo;
|
||||
use crate::gossip_service::GossipService;
|
||||
use crate::packet::to_shared_blob;
|
||||
use crate::recycler::Recycler;
|
||||
use crate::repair_service;
|
||||
use crate::repair_service::{RepairService, RepairSlotRange, RepairStrategy};
|
||||
use crate::result::{Error, Result};
|
||||
use crate::service::Service;
|
||||
use crate::shred_fetch_stage::ShredFetchStage;
|
||||
use crate::sigverify_stage::{DisabledSigVerifier, SigVerifyStage};
|
||||
use crate::storage_stage::NUM_STORAGE_SAMPLES;
|
||||
use crate::streamer::{receiver, responder, PacketReceiver};
|
||||
use crate::window_service::WindowService;
|
||||
use crate::{
|
||||
chacha::{chacha_cbc_encrypt_ledger, CHACHA_BLOCK_SIZE},
|
||||
cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE},
|
||||
contact_info::ContactInfo,
|
||||
gossip_service::GossipService,
|
||||
packet::to_shared_blob,
|
||||
recycler::Recycler,
|
||||
repair_service,
|
||||
repair_service::{RepairService, RepairSlotRange, RepairStrategy},
|
||||
result::{Error, Result},
|
||||
service::Service,
|
||||
shred_fetch_stage::ShredFetchStage,
|
||||
sigverify_stage::{DisabledSigVerifier, SigVerifyStage},
|
||||
storage_stage::NUM_STORAGE_SAMPLES,
|
||||
streamer::{receiver, responder, PacketReceiver},
|
||||
window_service::WindowService,
|
||||
};
|
||||
use bincode::deserialize;
|
||||
use crossbeam_channel::unbounded;
|
||||
use rand::thread_rng;
|
||||
use rand::Rng;
|
||||
use rand::SeedableRng;
|
||||
use rand::{thread_rng, Rng, SeedableRng};
|
||||
use rand_chacha::ChaChaRng;
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_client::rpc_request::RpcRequest;
|
||||
use solana_client::thin_client::ThinClient;
|
||||
use solana_client::{rpc_client::RpcClient, rpc_request::RpcRequest, thin_client::ThinClient};
|
||||
use solana_ed25519_dalek as ed25519_dalek;
|
||||
use solana_ledger::blocktree::Blocktree;
|
||||
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
|
||||
use solana_ledger::shred::Shred;
|
||||
use solana_ledger::{
|
||||
blocktree::Blocktree, leader_schedule_cache::LeaderScheduleCache, shred::Shred,
|
||||
};
|
||||
use solana_netutil::bind_in_range;
|
||||
use solana_sdk::account_utils::State;
|
||||
use solana_sdk::client::{AsyncClient, SyncClient};
|
||||
use solana_sdk::clock::{get_complete_segment_from_slot, get_segment_from_slot};
|
||||
use solana_sdk::hash::{Hash, Hasher};
|
||||
use solana_sdk::message::Message;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
|
||||
use solana_sdk::timing::timestamp;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::transport::TransportError;
|
||||
use solana_storage_api::storage_contract::StorageContract;
|
||||
use solana_storage_api::storage_instruction::{self, StorageAccountType};
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufReader, ErrorKind, Read, Seek, SeekFrom};
|
||||
use std::mem::size_of;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::result;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::{sleep, spawn, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use solana_sdk::{
|
||||
account_utils::State,
|
||||
client::{AsyncClient, SyncClient},
|
||||
clock::{get_complete_segment_from_slot, get_segment_from_slot, Slot},
|
||||
hash::{Hash, Hasher},
|
||||
message::Message,
|
||||
signature::{Keypair, KeypairUtil, Signature},
|
||||
timing::timestamp,
|
||||
transaction::Transaction,
|
||||
transport::TransportError,
|
||||
};
|
||||
use solana_storage_api::{
|
||||
storage_contract::StorageContract,
|
||||
storage_instruction::{self, StorageAccountType},
|
||||
};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, BufReader, ErrorKind, Read, Seek, SeekFrom},
|
||||
mem::size_of,
|
||||
net::{SocketAddr, UdpSocket},
|
||||
path::{Path, PathBuf},
|
||||
result,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::mpsc::{channel, Receiver, Sender},
|
||||
sync::{Arc, RwLock},
|
||||
thread::{sleep, spawn, JoinHandle},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
static ENCRYPTED_FILENAME: &str = "ledger.enc";
|
||||
|
||||
@ -65,7 +69,7 @@ pub struct Archiver {
|
||||
// Shared Archiver Meta struct used internally
|
||||
#[derive(Default)]
|
||||
struct ArchiverMeta {
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
ledger_path: PathBuf,
|
||||
signature: Signature,
|
||||
@ -497,7 +501,7 @@ impl Archiver {
|
||||
}
|
||||
|
||||
fn wait_for_segment_download(
|
||||
start_slot: u64,
|
||||
start_slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
blocktree: &Arc<Blocktree>,
|
||||
exit: &Arc<AtomicBool>,
|
||||
@ -905,7 +909,7 @@ impl Archiver {
|
||||
}
|
||||
|
||||
fn segment_complete(
|
||||
start_slot: u64,
|
||||
start_slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
blocktree: &Arc<Blocktree>,
|
||||
) -> bool {
|
||||
|
@ -23,7 +23,7 @@ use solana_runtime::{accounts_db::ErrorCounters, bank::Bank, transaction_batch::
|
||||
use solana_sdk::clock::MAX_TRANSACTION_FORWARDING_DELAY_GPU;
|
||||
use solana_sdk::{
|
||||
clock::{
|
||||
DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE,
|
||||
Slot, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE,
|
||||
MAX_TRANSACTION_FORWARDING_DELAY,
|
||||
},
|
||||
poh_config::PohConfig,
|
||||
@ -428,7 +428,7 @@ impl BankingStage {
|
||||
|
||||
#[allow(clippy::match_wild_err_arm)]
|
||||
fn record_transactions(
|
||||
bank_slot: u64,
|
||||
bank_slot: Slot,
|
||||
txs: &[Transaction],
|
||||
results: &[transaction::Result<()>],
|
||||
poh: &Arc<Mutex<PohRecorder>>,
|
||||
|
@ -7,8 +7,7 @@ use bincode::serialize;
|
||||
use chrono::{SecondsFormat, Utc};
|
||||
use serde_json::json;
|
||||
use solana_ledger::entry::Entry;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
|
||||
use std::cell::RefCell;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@ -72,14 +71,14 @@ impl EntryWriter for EntrySocket {
|
||||
pub trait BlockstreamEvents {
|
||||
fn emit_entry_event(
|
||||
&self,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
tick_height: u64,
|
||||
leader_pubkey: &Pubkey,
|
||||
entries: &Entry,
|
||||
) -> Result<()>;
|
||||
fn emit_block_event(
|
||||
&self,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
tick_height: u64,
|
||||
leader_pubkey: &Pubkey,
|
||||
blockhash: Hash,
|
||||
@ -97,7 +96,7 @@ where
|
||||
{
|
||||
fn emit_entry_event(
|
||||
&self,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
tick_height: u64,
|
||||
leader_pubkey: &Pubkey,
|
||||
entry: &Entry,
|
||||
@ -123,7 +122,7 @@ where
|
||||
|
||||
fn emit_block_event(
|
||||
&self,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
tick_height: u64,
|
||||
leader_pubkey: &Pubkey,
|
||||
blockhash: Hash,
|
||||
|
@ -2,9 +2,12 @@ use crate::poh_recorder::WorkingBankEntry;
|
||||
use crate::result::Result;
|
||||
use solana_ledger::entry::Entry;
|
||||
use solana_runtime::bank::Bank;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::{
|
||||
sync::mpsc::Receiver,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
pub(super) struct ReceiveResults {
|
||||
pub entries: Vec<Entry>,
|
||||
@ -16,8 +19,8 @@ pub(super) struct ReceiveResults {
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct UnfinishedSlotInfo {
|
||||
pub next_shred_index: u32,
|
||||
pub slot: u64,
|
||||
pub parent: u64,
|
||||
pub slot: Slot,
|
||||
pub parent: Slot,
|
||||
}
|
||||
|
||||
/// This parameter tunes how many entries are received in one iteration of recv loop
|
||||
|
@ -282,17 +282,22 @@ mod test {
|
||||
use super::*;
|
||||
use crate::cluster_info::{ClusterInfo, Node};
|
||||
use crate::genesis_utils::create_genesis_block;
|
||||
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
|
||||
use solana_ledger::entry::create_ticks;
|
||||
use solana_ledger::shred::max_ticks_per_n_shreds;
|
||||
use solana_ledger::{
|
||||
blocktree::{get_tmp_ledger_path, Blocktree},
|
||||
entry::create_ticks,
|
||||
shred::max_ticks_per_n_shreds,
|
||||
};
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::genesis_block::GenesisBlock;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
genesis_block::GenesisBlock,
|
||||
signature::{Keypair, KeypairUtil},
|
||||
};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::time::Duration;
|
||||
|
||||
fn setup(
|
||||
num_shreds_per_slot: u64,
|
||||
num_shreds_per_slot: Slot,
|
||||
) -> (
|
||||
Arc<Blocktree>,
|
||||
GenesisBlock,
|
||||
|
@ -1,4 +1,5 @@
|
||||
use solana_ledger::blocktree::Blocktree;
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::{BufWriter, Write};
|
||||
@ -12,7 +13,7 @@ pub const CHACHA_KEY_SIZE: usize = 32;
|
||||
|
||||
pub fn chacha_cbc_encrypt_ledger(
|
||||
blocktree: &Arc<Blocktree>,
|
||||
start_slot: u64,
|
||||
start_slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
out_path: &Path,
|
||||
ivec: &mut [u8; CHACHA_BLOCK_SIZE],
|
||||
|
@ -12,43 +12,48 @@
|
||||
//! * layer 2 - Everyone else, if layer 1 is `2^10`, layer 2 should be able to fit `2^20` number of nodes.
|
||||
//!
|
||||
//! Bank needs to provide an interface for us to query the stake weight
|
||||
use crate::contact_info::ContactInfo;
|
||||
use crate::crds_gossip::CrdsGossip;
|
||||
use crate::crds_gossip_error::CrdsGossipError;
|
||||
use crate::crds_gossip_pull::{CrdsFilter, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS};
|
||||
use crate::crds_value::{CrdsValue, CrdsValueLabel, EpochSlots, Vote};
|
||||
use crate::packet::{to_shared_blob, Blob, Packet, SharedBlob};
|
||||
use crate::repair_service::RepairType;
|
||||
use crate::result::{Error, Result};
|
||||
use crate::sendmmsg::{multicast, send_mmsg};
|
||||
use crate::streamer::{BlobReceiver, BlobSender};
|
||||
use crate::weighted_shuffle::{weighted_best, weighted_shuffle};
|
||||
use crate::{
|
||||
contact_info::ContactInfo,
|
||||
crds_gossip::CrdsGossip,
|
||||
crds_gossip_error::CrdsGossipError,
|
||||
crds_gossip_pull::{CrdsFilter, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
|
||||
crds_value::{CrdsValue, CrdsValueLabel, EpochSlots, Vote},
|
||||
packet::{to_shared_blob, Blob, Packet, SharedBlob},
|
||||
repair_service::RepairType,
|
||||
result::{Error, Result},
|
||||
sendmmsg::{multicast, send_mmsg},
|
||||
streamer::{BlobReceiver, BlobSender},
|
||||
weighted_shuffle::{weighted_best, weighted_shuffle},
|
||||
};
|
||||
use bincode::{deserialize, serialize, serialized_size};
|
||||
use core::cmp;
|
||||
use itertools::Itertools;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_ledger::blocktree::Blocktree;
|
||||
use solana_ledger::staking_utils;
|
||||
use solana_ledger::{bank_forks::BankForks, blocktree::Blocktree, staking_utils};
|
||||
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_error};
|
||||
use solana_netutil::{
|
||||
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
|
||||
multi_bind_in_range, PortRange,
|
||||
};
|
||||
use solana_sdk::packet::PACKET_DATA_SIZE;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil, Signable, Signature};
|
||||
use solana_sdk::timing::{duration_as_ms, timestamp};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::min;
|
||||
use std::collections::{BTreeSet, HashMap, HashSet};
|
||||
use std::fmt;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::{sleep, Builder, JoinHandle};
|
||||
use std::time::{Duration, Instant};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
packet::PACKET_DATA_SIZE,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, KeypairUtil, Signable, Signature},
|
||||
timing::{duration_as_ms, timestamp},
|
||||
transaction::Transaction,
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cmp::min,
|
||||
collections::{BTreeSet, HashMap, HashSet},
|
||||
fmt,
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::{Arc, RwLock},
|
||||
thread::{sleep, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
pub const VALIDATOR_PORT_RANGE: PortRange = (8000, 10_000);
|
||||
|
||||
@ -776,19 +781,19 @@ impl ClusterInfo {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn window_index_request_bytes(&self, slot: u64, blob_index: u64) -> Result<Vec<u8>> {
|
||||
pub fn window_index_request_bytes(&self, slot: Slot, blob_index: u64) -> Result<Vec<u8>> {
|
||||
let req = Protocol::RequestWindowIndex(self.my_data().clone(), slot, blob_index);
|
||||
let out = serialize(&req)?;
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn window_highest_index_request_bytes(&self, slot: u64, blob_index: u64) -> Result<Vec<u8>> {
|
||||
fn window_highest_index_request_bytes(&self, slot: Slot, blob_index: u64) -> Result<Vec<u8>> {
|
||||
let req = Protocol::RequestHighestWindowIndex(self.my_data().clone(), slot, blob_index);
|
||||
let out = serialize(&req)?;
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn orphan_bytes(&self, slot: u64) -> Result<Vec<u8>> {
|
||||
fn orphan_bytes(&self, slot: Slot) -> Result<Vec<u8>> {
|
||||
let req = Protocol::RequestOrphan(self.my_data().clone(), slot);
|
||||
let out = serialize(&req)?;
|
||||
Ok(out)
|
||||
@ -1043,7 +1048,7 @@ impl ClusterInfo {
|
||||
|
||||
fn get_data_shred_as_blob(
|
||||
blocktree: &Arc<Blocktree>,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
shred_index: u64,
|
||||
) -> Result<Option<Blob>> {
|
||||
let bytes = blocktree.get_data_shred(slot, shred_index)?;
|
||||
@ -1055,7 +1060,7 @@ impl ClusterInfo {
|
||||
from_addr: &SocketAddr,
|
||||
blocktree: Option<&Arc<Blocktree>>,
|
||||
me: &ContactInfo,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
blob_index: u64,
|
||||
) -> Vec<SharedBlob> {
|
||||
if let Some(blocktree) = blocktree {
|
||||
@ -1085,7 +1090,7 @@ impl ClusterInfo {
|
||||
fn run_highest_window_request(
|
||||
from_addr: &SocketAddr,
|
||||
blocktree: Option<&Arc<Blocktree>>,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
highest_index: u64,
|
||||
) -> Vec<SharedBlob> {
|
||||
if let Some(blocktree) = blocktree {
|
||||
@ -1111,7 +1116,7 @@ impl ClusterInfo {
|
||||
fn run_orphan(
|
||||
from_addr: &SocketAddr,
|
||||
blocktree: Option<&Arc<Blocktree>>,
|
||||
mut slot: u64,
|
||||
mut slot: Slot,
|
||||
max_responses: usize,
|
||||
) -> Vec<SharedBlob> {
|
||||
let mut res = vec![];
|
||||
|
@ -1,14 +1,18 @@
|
||||
use crate::result::{Error, Result};
|
||||
use crate::service::Service;
|
||||
use crate::{
|
||||
result::{Error, Result},
|
||||
service::Service,
|
||||
};
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_vote_api::vote_state::VoteState;
|
||||
use solana_vote_api::vote_state::MAX_LOCKOUT_HISTORY;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::{self, Builder, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use solana_sdk::clock::Slot;
|
||||
use solana_vote_api::{vote_state::VoteState, vote_state::MAX_LOCKOUT_HISTORY};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
|
||||
sync::{Arc, RwLock},
|
||||
thread::{self, Builder, JoinHandle},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct BankConfidence {
|
||||
@ -33,20 +37,20 @@ impl BankConfidence {
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ForkConfidenceCache {
|
||||
bank_confidence: HashMap<u64, BankConfidence>,
|
||||
bank_confidence: HashMap<Slot, BankConfidence>,
|
||||
total_stake: u64,
|
||||
}
|
||||
|
||||
impl ForkConfidenceCache {
|
||||
pub fn new(bank_confidence: HashMap<u64, BankConfidence>, total_stake: u64) -> Self {
|
||||
pub fn new(bank_confidence: HashMap<Slot, BankConfidence>, total_stake: u64) -> Self {
|
||||
Self {
|
||||
bank_confidence,
|
||||
total_stake,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_fork_confidence(&self, fork: u64) -> Option<&BankConfidence> {
|
||||
self.bank_confidence.get(&fork)
|
||||
pub fn get_fork_confidence(&self, slot: Slot) -> Option<&BankConfidence> {
|
||||
self.bank_confidence.get(&slot)
|
||||
}
|
||||
|
||||
pub fn total_stake(&self) -> u64 {
|
||||
@ -57,7 +61,7 @@ impl ForkConfidenceCache {
|
||||
&self,
|
||||
minimum_depth: usize,
|
||||
minimum_stake_percentage: f64,
|
||||
) -> Option<u64> {
|
||||
) -> Option<Slot> {
|
||||
self.bank_confidence
|
||||
.iter()
|
||||
.filter(|&(_, bank_confidence)| {
|
||||
@ -160,7 +164,7 @@ impl AggregateConfidenceService {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn aggregate_confidence(ancestors: &[u64], bank: &Bank) -> HashMap<u64, BankConfidence> {
|
||||
pub fn aggregate_confidence(ancestors: &[Slot], bank: &Bank) -> HashMap<Slot, BankConfidence> {
|
||||
assert!(!ancestors.is_empty());
|
||||
|
||||
// Check ancestors is sorted
|
||||
@ -191,9 +195,9 @@ impl AggregateConfidenceService {
|
||||
}
|
||||
|
||||
fn aggregate_confidence_for_vote_account(
|
||||
confidence: &mut HashMap<u64, BankConfidence>,
|
||||
confidence: &mut HashMap<Slot, BankConfidence>,
|
||||
vote_state: &VoteState,
|
||||
ancestors: &[u64],
|
||||
ancestors: &[Slot],
|
||||
lamports: u64,
|
||||
) {
|
||||
assert!(!ancestors.is_empty());
|
||||
|
@ -1,12 +1,12 @@
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_metrics::datapoint_debug;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::{account::Account, clock::Slot, hash::Hash, pubkey::Pubkey};
|
||||
use solana_vote_api::vote_state::{Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub const VOTE_THRESHOLD_DEPTH: usize = 8;
|
||||
pub const VOTE_THRESHOLD_SIZE: f64 = 2f64 / 3f64;
|
||||
@ -66,8 +66,8 @@ impl Tower {
|
||||
&self,
|
||||
bank_slot: u64,
|
||||
vote_accounts: F,
|
||||
ancestors: &HashMap<u64, HashSet<u64>>,
|
||||
) -> (HashMap<u64, StakeLockout>, u64)
|
||||
ancestors: &HashMap<Slot, HashSet<u64>>,
|
||||
) -> (HashMap<Slot, StakeLockout>, u64)
|
||||
where
|
||||
F: Iterator<Item = (Pubkey, (u64, Account))>,
|
||||
{
|
||||
@ -167,11 +167,12 @@ impl Tower {
|
||||
.map(|lockout| (lockout.stake as f64 / total_staked as f64) > self.threshold_size)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn new_vote(
|
||||
local_vote_state: &VoteState,
|
||||
slot: u64,
|
||||
hash: Hash,
|
||||
last_bank_slot: Option<u64>,
|
||||
last_bank_slot: Option<Slot>,
|
||||
) -> Vote {
|
||||
let mut local_vote_state = local_vote_state.clone();
|
||||
let vote = Vote {
|
||||
@ -179,12 +180,12 @@ impl Tower {
|
||||
hash,
|
||||
};
|
||||
local_vote_state.process_vote_unchecked(&vote);
|
||||
let slots = if let Some(lbs) = last_bank_slot {
|
||||
let slots = if let Some(last_bank_slot) = last_bank_slot {
|
||||
local_vote_state
|
||||
.votes
|
||||
.iter()
|
||||
.map(|v| v.slot)
|
||||
.skip_while(|s| *s <= lbs)
|
||||
.skip_while(|s| *s <= last_bank_slot)
|
||||
.collect()
|
||||
} else {
|
||||
local_vote_state.votes.iter().map(|v| v.slot).collect()
|
||||
@ -197,7 +198,8 @@ impl Tower {
|
||||
);
|
||||
Vote { slots, hash }
|
||||
}
|
||||
fn last_bank_vote(bank: &Bank, vote_account_pubkey: &Pubkey) -> Option<u64> {
|
||||
|
||||
fn last_bank_vote(bank: &Bank, vote_account_pubkey: &Pubkey) -> Option<Slot> {
|
||||
let vote_account = bank.vote_accounts().get(vote_account_pubkey)?.1.clone();
|
||||
let bank_vote_state = VoteState::deserialize(&vote_account.data).ok()?;
|
||||
bank_vote_state.votes.iter().map(|v| v.slot).last()
|
||||
@ -207,7 +209,8 @@ impl Tower {
|
||||
let last_vote = Self::last_bank_vote(bank, vote_account_pubkey);
|
||||
Self::new_vote(&self.lockouts, bank.slot(), bank.hash(), last_vote)
|
||||
}
|
||||
pub fn record_bank_vote(&mut self, vote: Vote) -> Option<u64> {
|
||||
|
||||
pub fn record_bank_vote(&mut self, vote: Vote) -> Option<Slot> {
|
||||
let slot = *vote.slots.last().unwrap_or(&0);
|
||||
trace!("{} record_vote for {}", self.node_pubkey, slot);
|
||||
let root_slot = self.lockouts.root_slot;
|
||||
@ -225,7 +228,8 @@ impl Tower {
|
||||
None
|
||||
}
|
||||
}
|
||||
pub fn record_vote(&mut self, slot: u64, hash: Hash) -> Option<u64> {
|
||||
|
||||
pub fn record_vote(&mut self, slot: Slot, hash: Hash) -> Option<Slot> {
|
||||
let vote = Vote {
|
||||
slots: vec![slot],
|
||||
hash,
|
||||
@ -237,11 +241,11 @@ impl Tower {
|
||||
self.last_vote.clone()
|
||||
}
|
||||
|
||||
pub fn root(&self) -> Option<u64> {
|
||||
pub fn root(&self) -> Option<Slot> {
|
||||
self.lockouts.root_slot
|
||||
}
|
||||
|
||||
pub fn calculate_weight(&self, stake_lockouts: &HashMap<u64, StakeLockout>) -> u128 {
|
||||
pub fn calculate_weight(&self, stake_lockouts: &HashMap<Slot, StakeLockout>) -> u128 {
|
||||
let mut sum = 0u128;
|
||||
let root_slot = self.lockouts.root_slot.unwrap_or(0);
|
||||
for (slot, stake_lockout) in stake_lockouts {
|
||||
@ -272,7 +276,7 @@ impl Tower {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn is_locked_out(&self, slot: u64, ancestors: &HashMap<u64, HashSet<u64>>) -> bool {
|
||||
pub fn is_locked_out(&self, slot: Slot, ancestors: &HashMap<Slot, HashSet<Slot>>) -> bool {
|
||||
assert!(ancestors.contains_key(&slot));
|
||||
|
||||
if !self.is_recent(slot) {
|
||||
@ -290,11 +294,11 @@ impl Tower {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if let Some(root) = lockouts.root_slot {
|
||||
if let Some(root_slot) = lockouts.root_slot {
|
||||
// This case should never happen because bank forks purges all
|
||||
// non-descendants of the root every time root is set
|
||||
if slot != root {
|
||||
assert!(ancestors[&slot].contains(&root));
|
||||
if slot != root_slot {
|
||||
assert!(ancestors[&slot].contains(&root_slot));
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,9 +327,9 @@ impl Tower {
|
||||
|
||||
/// Update lockouts for all the ancestors
|
||||
fn update_ancestor_lockouts(
|
||||
stake_lockouts: &mut HashMap<u64, StakeLockout>,
|
||||
stake_lockouts: &mut HashMap<Slot, StakeLockout>,
|
||||
vote: &Lockout,
|
||||
ancestors: &HashMap<u64, HashSet<u64>>,
|
||||
ancestors: &HashMap<Slot, HashSet<Slot>>,
|
||||
) {
|
||||
// If there's no ancestors, that means this slot must be from before the current root,
|
||||
// in which case the lockouts won't be calculated in bank_weight anyways, so ignore
|
||||
@ -345,10 +349,10 @@ impl Tower {
|
||||
/// Update stake for all the ancestors.
|
||||
/// Note, stake is the same for all the ancestor.
|
||||
fn update_ancestor_stakes(
|
||||
stake_lockouts: &mut HashMap<u64, StakeLockout>,
|
||||
slot: u64,
|
||||
stake_lockouts: &mut HashMap<Slot, StakeLockout>,
|
||||
slot: Slot,
|
||||
lamports: u64,
|
||||
ancestors: &HashMap<u64, HashSet<u64>>,
|
||||
ancestors: &HashMap<Slot, HashSet<Slot>>,
|
||||
) {
|
||||
// If there's no ancestors, that means this slot must be from before the current root,
|
||||
// in which case the lockouts won't be calculated in bank_weight anyways, so ignore
|
||||
@ -365,7 +369,7 @@ impl Tower {
|
||||
}
|
||||
}
|
||||
|
||||
fn bank_weight(&self, bank: &Bank, ancestors: &HashMap<u64, HashSet<u64>>) -> u128 {
|
||||
fn bank_weight(&self, bank: &Bank, ancestors: &HashMap<Slot, HashSet<Slot>>) -> u128 {
|
||||
let (stake_lockouts, _) =
|
||||
self.collect_vote_lockouts(bank.slot(), bank.vote_accounts().into_iter(), ancestors);
|
||||
self.calculate_weight(&stake_lockouts)
|
||||
|
@ -1,28 +1,32 @@
|
||||
//! The `packet` module defines data structures and methods to pull data from the network.
|
||||
use crate::cuda_runtime::PinnedVec;
|
||||
use crate::recvmmsg::{recv_mmsg, NUM_RCVMMSGS};
|
||||
use crate::recycler::{Recycler, Reset};
|
||||
use crate::result::{Error, Result};
|
||||
use crate::{
|
||||
cuda_runtime::PinnedVec,
|
||||
recvmmsg::{recv_mmsg, NUM_RCVMMSGS},
|
||||
recycler::{Recycler, Reset},
|
||||
result::{Error, Result},
|
||||
};
|
||||
use bincode;
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use serde::Serialize;
|
||||
use solana_ledger::erasure::ErasureConfig;
|
||||
use solana_metrics::inc_new_counter_debug;
|
||||
pub use solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Signable;
|
||||
use solana_sdk::signature::Signature;
|
||||
use std::borrow::Cow;
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::io::Cursor;
|
||||
use std::mem;
|
||||
use std::mem::size_of;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::time::Instant;
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
pubkey::Pubkey,
|
||||
signature::{Signable, Signature},
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cmp, fmt, io,
|
||||
io::Cursor,
|
||||
mem,
|
||||
mem::size_of,
|
||||
net::{SocketAddr, UdpSocket},
|
||||
ops::{Deref, DerefMut},
|
||||
sync::{Arc, RwLock},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
pub type SharedBlob = Arc<RwLock<Blob>>;
|
||||
pub type SharedBlobs = Vec<SharedBlob>;
|
||||
@ -531,7 +535,13 @@ impl Signable for Blob {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn index_blobs(blobs: &[SharedBlob], id: &Pubkey, mut blob_index: u64, slot: u64, parent: u64) {
|
||||
pub fn index_blobs(
|
||||
blobs: &[SharedBlob],
|
||||
id: &Pubkey,
|
||||
mut blob_index: u64,
|
||||
slot: Slot,
|
||||
parent: Slot,
|
||||
) {
|
||||
// enumerate all the blobs, those are the indices
|
||||
for blob in blobs.iter() {
|
||||
let mut blob = blob.write().unwrap();
|
||||
|
@ -4,9 +4,11 @@ use crate::{
|
||||
cluster_info::ClusterInfo, cluster_info_repair_listener::ClusterInfoRepairListener,
|
||||
result::Result, service::Service,
|
||||
};
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_ledger::blocktree::{Blocktree, CompletedSlotsReceiver, SlotMeta};
|
||||
use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey};
|
||||
use solana_ledger::{
|
||||
bank_forks::BankForks,
|
||||
blocktree::{Blocktree, CompletedSlotsReceiver, SlotMeta},
|
||||
};
|
||||
use solana_sdk::{clock::Slot, epoch_schedule::EpochSchedule, pubkey::Pubkey};
|
||||
use std::{
|
||||
collections::BTreeSet,
|
||||
net::UdpSocket,
|
||||
@ -241,7 +243,7 @@ impl RepairService {
|
||||
|
||||
fn generate_repairs_for_slot(
|
||||
blocktree: &Blocktree,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
slot_meta: &SlotMeta,
|
||||
max_repairs: usize,
|
||||
) -> Vec<RepairType> {
|
||||
@ -272,7 +274,7 @@ impl RepairService {
|
||||
blocktree: &Blocktree,
|
||||
repairs: &mut Vec<RepairType>,
|
||||
max_repairs: usize,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
) {
|
||||
let mut pending_slots = vec![slot];
|
||||
while repairs.len() < max_repairs && !pending_slots.is_empty() {
|
||||
|
@ -9,30 +9,37 @@ use crate::poh_recorder::PohRecorder;
|
||||
use crate::result::{Error, Result};
|
||||
use crate::rpc_subscriptions::RpcSubscriptions;
|
||||
use crate::service::Service;
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_ledger::block_error::BlockError;
|
||||
use solana_ledger::blocktree::{Blocktree, BlocktreeError};
|
||||
use solana_ledger::blocktree_processor;
|
||||
use solana_ledger::entry::{Entry, EntrySlice};
|
||||
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
|
||||
use solana_ledger::snapshot_package::SnapshotPackageSender;
|
||||
use solana_ledger::{
|
||||
bank_forks::BankForks,
|
||||
block_error::BlockError,
|
||||
blocktree::{Blocktree, BlocktreeError},
|
||||
blocktree_processor,
|
||||
entry::{Entry, EntrySlice},
|
||||
leader_schedule_cache::LeaderScheduleCache,
|
||||
snapshot_package::SnapshotPackageSender,
|
||||
};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_metrics::{datapoint_warn, inc_new_counter_info};
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use solana_sdk::timing::{self, duration_as_ms};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
signature::KeypairUtil,
|
||||
timing::{self, duration_as_ms},
|
||||
transaction::Transaction,
|
||||
};
|
||||
use solana_vote_api::vote_instruction;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::thread::{self, Builder, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
collections::HashSet,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
thread::{self, Builder, JoinHandle},
|
||||
time::Duration,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
pub const MAX_ENTRY_RECV_PER_ITER: usize = 512;
|
||||
|
||||
@ -62,7 +69,7 @@ pub struct ReplayStage {
|
||||
|
||||
struct ReplaySlotStats {
|
||||
// Per-slot elapsed time
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
fetch_entries_elapsed: u64,
|
||||
fetch_entries_fail_elapsed: u64,
|
||||
entry_verification_elapsed: u64,
|
||||
@ -71,7 +78,7 @@ struct ReplaySlotStats {
|
||||
}
|
||||
|
||||
impl ReplaySlotStats {
|
||||
pub fn new(slot: u64) -> Self {
|
||||
pub fn new(slot: Slot) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
fetch_entries_elapsed: 0,
|
||||
@ -120,7 +127,7 @@ struct ForkProgress {
|
||||
}
|
||||
|
||||
impl ForkProgress {
|
||||
pub fn new(slot: u64, last_entry: Hash) -> Self {
|
||||
pub fn new(slot: Slot, last_entry: Hash) -> Self {
|
||||
Self {
|
||||
last_entry,
|
||||
num_shreds: 0,
|
||||
@ -300,7 +307,7 @@ impl ReplayStage {
|
||||
|
||||
fn log_leader_change(
|
||||
my_pubkey: &Pubkey,
|
||||
bank_slot: u64,
|
||||
bank_slot: Slot,
|
||||
current_leader: &mut Option<Pubkey>,
|
||||
new_leader: &Pubkey,
|
||||
) {
|
||||
@ -451,7 +458,11 @@ impl ReplayStage {
|
||||
(replay_result, tx_count)
|
||||
}
|
||||
|
||||
fn mark_dead_slot(slot: u64, blocktree: &Blocktree, progress: &mut HashMap<u64, ForkProgress>) {
|
||||
fn mark_dead_slot(
|
||||
slot: Slot,
|
||||
blocktree: &Blocktree,
|
||||
progress: &mut HashMap<u64, ForkProgress>,
|
||||
) {
|
||||
// Remove from progress map so we no longer try to replay this bank
|
||||
let mut progress_entry = progress
|
||||
.get_mut(&slot)
|
||||
|
@ -18,6 +18,7 @@ use solana_ledger::bank_forks::BankForks;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
clock::Slot,
|
||||
epoch_schedule::EpochSchedule,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::Hash,
|
||||
@ -215,7 +216,7 @@ impl JsonRpcRequestProcessor {
|
||||
Ok(self.bank().slots_per_segment())
|
||||
}
|
||||
|
||||
fn get_storage_pubkeys_for_slot(&self, slot: u64) -> Result<Vec<Pubkey>> {
|
||||
fn get_storage_pubkeys_for_slot(&self, slot: Slot) -> Result<Vec<Pubkey>> {
|
||||
Ok(self
|
||||
.storage_state
|
||||
.get_pubkeys_for_slot(slot, &self.bank_forks))
|
||||
@ -710,7 +711,11 @@ impl RpcSol for RpcSolImpl {
|
||||
.get_slots_per_segment()
|
||||
}
|
||||
|
||||
fn get_storage_pubkeys_for_slot(&self, meta: Self::Metadata, slot: u64) -> Result<Vec<Pubkey>> {
|
||||
fn get_storage_pubkeys_for_slot(
|
||||
&self,
|
||||
meta: Self::Metadata,
|
||||
slot: Slot,
|
||||
) -> Result<Vec<Pubkey>> {
|
||||
meta.request_processor
|
||||
.read()
|
||||
.unwrap()
|
||||
|
@ -2,15 +2,13 @@
|
||||
|
||||
use core::hash::Hash;
|
||||
use jsonrpc_core::futures::Future;
|
||||
use jsonrpc_pubsub::typed::Sink;
|
||||
use jsonrpc_pubsub::SubscriptionId;
|
||||
use jsonrpc_pubsub::{typed::Sink, SubscriptionId};
|
||||
use serde::Serialize;
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Signature;
|
||||
use solana_sdk::transaction;
|
||||
use solana_sdk::{
|
||||
account::Account, clock::Slot, pubkey::Pubkey, signature::Signature, transaction,
|
||||
};
|
||||
use solana_vote_api::vote_state::MAX_LOCKOUT_HISTORY;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
@ -74,7 +72,7 @@ where
|
||||
fn check_confirmations_and_notify<K, S, F, N, X>(
|
||||
subscriptions: &HashMap<K, HashMap<SubscriptionId, (Sink<S>, Confirmations)>>,
|
||||
hashmap_key: &K,
|
||||
current_slot: u64,
|
||||
current_slot: Slot,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
bank_method: F,
|
||||
notify: N,
|
||||
@ -169,7 +167,7 @@ impl RpcSubscriptions {
|
||||
pub fn check_account(
|
||||
&self,
|
||||
pubkey: &Pubkey,
|
||||
current_slot: u64,
|
||||
current_slot: Slot,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
) {
|
||||
let subscriptions = self.account_subscriptions.read().unwrap();
|
||||
@ -186,7 +184,7 @@ impl RpcSubscriptions {
|
||||
pub fn check_program(
|
||||
&self,
|
||||
program_id: &Pubkey,
|
||||
current_slot: u64,
|
||||
current_slot: Slot,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
) {
|
||||
let subscriptions = self.program_subscriptions.write().unwrap();
|
||||
@ -203,7 +201,7 @@ impl RpcSubscriptions {
|
||||
pub fn check_signature(
|
||||
&self,
|
||||
signature: &Signature,
|
||||
current_slot: u64,
|
||||
current_slot: Slot,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
) {
|
||||
let mut subscriptions = self.signature_subscriptions.write().unwrap();
|
||||
@ -268,7 +266,7 @@ impl RpcSubscriptions {
|
||||
|
||||
/// Notify subscribers of changes to any accounts or new signatures since
|
||||
/// the bank's last checkpoint.
|
||||
pub fn notify_subscribers(&self, current_slot: u64, bank_forks: &Arc<RwLock<BankForks>>) {
|
||||
pub fn notify_subscribers(&self, current_slot: Slot, bank_forks: &Arc<RwLock<BankForks>>) {
|
||||
let pubkeys: Vec<_> = {
|
||||
let subs = self.account_subscriptions.read().unwrap();
|
||||
subs.keys().cloned().collect()
|
||||
|
@ -2,38 +2,45 @@
|
||||
// for storage mining. Archivers submit storage proofs, validator then bundles them
|
||||
// to submit its proof for mining to be rewarded.
|
||||
|
||||
use crate::chacha_cuda::chacha_cbc_encrypt_file_many_keys;
|
||||
use crate::cluster_info::ClusterInfo;
|
||||
use crate::contact_info::ContactInfo;
|
||||
use crate::result::{Error, Result};
|
||||
use crate::service::Service;
|
||||
use crate::{
|
||||
chacha_cuda::chacha_cbc_encrypt_file_many_keys,
|
||||
cluster_info::ClusterInfo,
|
||||
contact_info::ContactInfo,
|
||||
result::{Error, Result},
|
||||
service::Service,
|
||||
};
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand_chacha::ChaChaRng;
|
||||
use solana_ledger::bank_forks::BankForks;
|
||||
use solana_ledger::blocktree::Blocktree;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_runtime::storage_utils::archiver_accounts;
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::account_utils::State;
|
||||
use solana_sdk::clock::get_segment_from_slot;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_sdk::message::Message;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_storage_api::storage_contract::{Proof, ProofStatus, StorageContract};
|
||||
use solana_storage_api::storage_instruction;
|
||||
use solana_storage_api::storage_instruction::proof_validation;
|
||||
use std::collections::HashMap;
|
||||
use std::mem::size_of;
|
||||
use std::net::UdpSocket;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::{self, sleep, Builder, JoinHandle};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{cmp, io};
|
||||
use solana_ledger::{bank_forks::BankForks, blocktree::Blocktree};
|
||||
use solana_runtime::{bank::Bank, storage_utils::archiver_accounts};
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
account_utils::State,
|
||||
clock::{get_segment_from_slot, Slot},
|
||||
hash::Hash,
|
||||
instruction::Instruction,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, KeypairUtil, Signature},
|
||||
transaction::Transaction,
|
||||
};
|
||||
use solana_storage_api::{
|
||||
storage_contract::{Proof, ProofStatus, StorageContract},
|
||||
storage_instruction,
|
||||
storage_instruction::proof_validation,
|
||||
};
|
||||
use std::{
|
||||
cmp,
|
||||
collections::HashMap,
|
||||
io,
|
||||
mem::size_of,
|
||||
net::UdpSocket,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
|
||||
sync::{Arc, RwLock},
|
||||
thread::{self, sleep, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
// Block of hash answers to validate against
|
||||
// Vec of [ledger blocks] x [keys]
|
||||
@ -47,7 +54,7 @@ pub struct StorageStateInner {
|
||||
pub storage_keys: StorageKeys,
|
||||
archiver_map: ArchiverMap,
|
||||
storage_blockhash: Hash,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
slots_per_turn: u64,
|
||||
}
|
||||
@ -133,7 +140,7 @@ impl StorageState {
|
||||
|
||||
pub fn get_pubkeys_for_slot(
|
||||
&self,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
) -> Vec<Pubkey> {
|
||||
// TODO: keep track of age?
|
||||
@ -364,7 +371,7 @@ impl StorageStage {
|
||||
state: &Arc<RwLock<StorageStateInner>>,
|
||||
_blocktree: &Arc<Blocktree>,
|
||||
blockhash: Hash,
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
instruction_sender: &InstructionSender,
|
||||
) -> Result<()> {
|
||||
@ -440,7 +447,7 @@ impl StorageStage {
|
||||
}
|
||||
|
||||
fn collect_proofs(
|
||||
slot: u64,
|
||||
slot: Slot,
|
||||
slots_per_segment: u64,
|
||||
account_id: Pubkey,
|
||||
account: Account,
|
||||
|
@ -295,6 +295,7 @@ mod test {
|
||||
shred::Shredder,
|
||||
};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
|
||||
hash::Hash,
|
||||
signature::{Keypair, KeypairUtil},
|
||||
@ -310,8 +311,8 @@ mod test {
|
||||
|
||||
fn local_entries_to_shred(
|
||||
entries: &[Entry],
|
||||
slot: u64,
|
||||
parent: u64,
|
||||
slot: Slot,
|
||||
parent: Slot,
|
||||
keypair: &Arc<Keypair>,
|
||||
) -> Vec<Shred> {
|
||||
let shredder = Shredder::new(slot, parent, 0.0, keypair.clone())
|
||||
|
@ -5,26 +5,36 @@ mod tests {
|
||||
use bincode::serialize_into;
|
||||
use fs_extra::dir::CopyOptions;
|
||||
use itertools::Itertools;
|
||||
use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo};
|
||||
use solana_core::service::Service;
|
||||
use solana_core::snapshot_packager_service::SnapshotPackagerService;
|
||||
use solana_ledger::bank_forks::{BankForks, SnapshotConfig};
|
||||
use solana_ledger::snapshot_utils;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_runtime::status_cache::SlotDelta;
|
||||
use solana_runtime::status_cache::MAX_CACHE_ENTRIES;
|
||||
use solana_sdk::hash::hashv;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_transaction;
|
||||
use solana_sdk::transaction::Result as TransactionResult;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::Arc;
|
||||
use solana_core::{
|
||||
genesis_utils::{create_genesis_block, GenesisBlockInfo},
|
||||
service::Service,
|
||||
snapshot_packager_service::SnapshotPackagerService,
|
||||
};
|
||||
use solana_ledger::{
|
||||
bank_forks::{BankForks, SnapshotConfig},
|
||||
snapshot_utils,
|
||||
};
|
||||
use solana_runtime::{
|
||||
bank::Bank,
|
||||
status_cache::{SlotDelta, MAX_CACHE_ENTRIES},
|
||||
};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
hash::hashv,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, KeypairUtil},
|
||||
system_transaction,
|
||||
transaction::Result as TransactionResult,
|
||||
};
|
||||
use std::{
|
||||
fs,
|
||||
fs::File,
|
||||
io::{BufWriter, Write},
|
||||
path::PathBuf,
|
||||
sync::atomic::AtomicBool,
|
||||
sync::mpsc::channel,
|
||||
sync::Arc,
|
||||
};
|
||||
use tempfile::TempDir;
|
||||
|
||||
struct SnapshotTestConfig {
|
||||
@ -100,7 +110,7 @@ mod tests {
|
||||
// also marks each bank as root and generates snapshots
|
||||
// finally tries to restore from the last bank's snapshot and compares the restored bank to the
|
||||
// `last_slot` bank
|
||||
fn run_bank_forks_snapshot_n<F>(last_slot: u64, f: F, set_root_interval: u64)
|
||||
fn run_bank_forks_snapshot_n<F>(last_slot: Slot, f: F, set_root_interval: u64)
|
||||
where
|
||||
F: Fn(&mut Bank, &Keypair),
|
||||
{
|
||||
|
Reference in New Issue
Block a user