Add solana-ledger crate (#6415)

automerge
This commit is contained in:
Greg Fitzgerald 2019-10-18 10:28:51 -06:00 committed by Grimes
parent 6f58bdfcb1
commit 5468be2ef9
74 changed files with 350 additions and 273 deletions

42
Cargo.lock generated
View File

@ -2993,6 +2993,7 @@ dependencies = [
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-core 0.20.0", "solana-core 0.20.0",
"solana-ledger 0.20.0",
"solana-logger 0.20.0", "solana-logger 0.20.0",
"solana-measure 0.20.0", "solana-measure 0.20.0",
"solana-runtime 0.20.0", "solana-runtime 0.20.0",
@ -3265,8 +3266,6 @@ dependencies = [
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"dir-diff 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dir-diff 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dlopen 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"dlopen_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3287,7 +3286,6 @@ dependencies = [
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3299,6 +3297,7 @@ dependencies = [
"solana-client 0.20.0", "solana-client 0.20.0",
"solana-drone 0.20.0", "solana-drone 0.20.0",
"solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-ledger 0.20.0",
"solana-logger 0.20.0", "solana-logger 0.20.0",
"solana-measure 0.20.0", "solana-measure 0.20.0",
"solana-merkle-tree 0.20.0", "solana-merkle-tree 0.20.0",
@ -3428,8 +3427,8 @@ dependencies = [
"serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-core 0.20.0",
"solana-genesis-programs 0.20.0", "solana-genesis-programs 0.20.0",
"solana-ledger 0.20.0",
"solana-sdk 0.20.0", "solana-sdk 0.20.0",
"solana-stake-api 0.20.0", "solana-stake-api 0.20.0",
"solana-storage-api 0.20.0", "solana-storage-api 0.20.0",
@ -3519,6 +3518,38 @@ dependencies = [
"tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "solana-ledger"
version = "0.20.0"
dependencies = [
"bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"dlopen 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"dlopen_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-budget-api 0.20.0",
"solana-logger 0.20.0",
"solana-merkle-tree 0.20.0",
"solana-metrics 0.20.0",
"solana-rayon-threadlimit 0.20.0",
"solana-reed-solomon-erasure 4.0.1-3 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-runtime 0.20.0",
"solana-sdk 0.20.0",
"solana-stake-api 0.20.0",
"solana-vote-api 0.20.0",
"sys-info 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "solana-ledger-tool" name = "solana-ledger-tool"
version = "0.20.0" version = "0.20.0"
@ -3531,6 +3562,7 @@ dependencies = [
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-core 0.20.0", "solana-core 0.20.0",
"solana-ledger 0.20.0",
"solana-logger 0.20.0", "solana-logger 0.20.0",
"solana-runtime 0.20.0", "solana-runtime 0.20.0",
"solana-sdk 0.20.0", "solana-sdk 0.20.0",
@ -3565,6 +3597,7 @@ dependencies = [
"solana-drone 0.20.0", "solana-drone 0.20.0",
"solana-exchange-api 0.20.0", "solana-exchange-api 0.20.0",
"solana-exchange-program 0.20.0", "solana-exchange-program 0.20.0",
"solana-ledger 0.20.0",
"solana-logger 0.20.0", "solana-logger 0.20.0",
"solana-move-loader-api 0.20.0", "solana-move-loader-api 0.20.0",
"solana-move-loader-program 0.20.0", "solana-move-loader-program 0.20.0",
@ -3886,6 +3919,7 @@ dependencies = [
"solana-client 0.20.0", "solana-client 0.20.0",
"solana-core 0.20.0", "solana-core 0.20.0",
"solana-drone 0.20.0", "solana-drone 0.20.0",
"solana-ledger 0.20.0",
"solana-logger 0.20.0", "solana-logger 0.20.0",
"solana-metrics 0.20.0", "solana-metrics 0.20.0",
"solana-netutil 0.20.0", "solana-netutil 0.20.0",

View File

@ -14,6 +14,7 @@ members = [
"gossip", "gossip",
"install", "install",
"keygen", "keygen",
"ledger",
"ledger-tool", "ledger-tool",
"local_cluster", "local_cluster",
"logger", "logger",

View File

@ -11,6 +11,7 @@ homepage = "https://solana.com/"
log = "0.4.6" log = "0.4.6"
rayon = "1.2.0" rayon = "1.2.0"
solana-core = { path = "../core", version = "0.20.0" } solana-core = { path = "../core", version = "0.20.0" }
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-logger = { path = "../logger", version = "0.20.0" } solana-logger = { path = "../logger", version = "0.20.0" }
solana-runtime = { path = "../runtime", version = "0.20.0" } solana-runtime = { path = "../runtime", version = "0.20.0" }
solana-measure = { path = "../measure", version = "0.20.0" } solana-measure = { path = "../measure", version = "0.20.0" }

View File

@ -1,5 +1,5 @@
#[macro_use] #[macro_use]
extern crate solana_core; extern crate solana_ledger;
extern crate crossbeam_channel; extern crate crossbeam_channel;
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
@ -8,7 +8,6 @@ use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_core::bank_forks::BankForks; use solana_core::bank_forks::BankForks;
use solana_core::banking_stage::{create_test_recorder, BankingStage}; use solana_core::banking_stage::{create_test_recorder, BankingStage};
use solana_core::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_core::cluster_info::ClusterInfo; use solana_core::cluster_info::ClusterInfo;
use solana_core::cluster_info::Node; use solana_core::cluster_info::Node;
use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo};
@ -16,6 +15,7 @@ use solana_core::packet::to_packets_chunked;
use solana_core::poh_recorder::PohRecorder; use solana_core::poh_recorder::PohRecorder;
use solana_core::poh_recorder::WorkingBankEntry; use solana_core::poh_recorder::WorkingBankEntry;
use solana_core::service::Service; use solana_core::service::Service;
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;

View File

@ -27,8 +27,6 @@ core_affinity = "0.5.9"
crc = { version = "1.8.1", optional = true } crc = { version = "1.8.1", optional = true }
crossbeam-channel = "0.3" crossbeam-channel = "0.3"
dir-diff = "0.3.2" dir-diff = "0.3.2"
dlopen = "0.1.8"
dlopen_derive = "0.1.4"
fs_extra = "1.1.0" fs_extra = "1.1.0"
indexmap = "1.1" indexmap = "1.1"
itertools = "0.8.0" itertools = "0.8.0"
@ -55,6 +53,7 @@ solana-chacha-sys = { path = "../chacha-sys", version = "0.20.0" }
solana-client = { path = "../client", version = "0.20.0" } solana-client = { path = "../client", version = "0.20.0" }
solana-drone = { path = "../drone", version = "0.20.0" } solana-drone = { path = "../drone", version = "0.20.0" }
solana-ed25519-dalek = "0.2.0" solana-ed25519-dalek = "0.2.0"
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-logger = { path = "../logger", version = "0.20.0" } solana-logger = { path = "../logger", version = "0.20.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "0.20.0" } solana-merkle-tree = { path = "../merkle-tree", version = "0.20.0" }
solana-metrics = { path = "../metrics", version = "0.20.0" } solana-metrics = { path = "../metrics", version = "0.20.0" }
@ -79,13 +78,6 @@ untrusted = "0.7.0"
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.20.0" } solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.20.0" }
reed-solomon-erasure = { package = "solana-reed-solomon-erasure", version = "4.0.1-3", features = ["simd-accel"] } reed-solomon-erasure = { package = "solana-reed-solomon-erasure", version = "4.0.1-3", features = ["simd-accel"] }
[dependencies.rocksdb]
# Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts
# when also using the bzip2 crate
version = "0.11.0"
default-features = false
features = ["lz4"]
[dev-dependencies] [dev-dependencies]
hex-literal = "0.2.1" hex-literal = "0.2.1"
matches = "0.1.6" matches = "0.1.6"

View File

@ -2,24 +2,23 @@
extern crate test; extern crate test;
#[macro_use] #[macro_use]
extern crate solana_core; extern crate solana_ledger;
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use log::*; use log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_core::banking_stage::{create_test_recorder, BankingStage}; use solana_core::banking_stage::{create_test_recorder, BankingStage};
use solana_core::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_core::blocktree_processor::process_entries; use solana_core::blocktree_processor::process_entries;
use solana_core::cluster_info::ClusterInfo; use solana_core::cluster_info::ClusterInfo;
use solana_core::cluster_info::Node; use solana_core::cluster_info::Node;
use solana_core::entry::next_hash;
use solana_core::entry::Entry;
use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use solana_core::packet::to_packets_chunked; use solana_core::packet::to_packets_chunked;
use solana_core::poh_recorder::WorkingBankEntry; use solana_core::poh_recorder::WorkingBankEntry;
use solana_core::service::Service; use solana_core::service::Service;
use solana_core::test_tx::test_tx; use solana_core::test_tx::test_tx;
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_ledger::entry::{next_hash, Entry};
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;

View File

@ -4,13 +4,11 @@ use rand;
extern crate test; extern crate test;
#[macro_use] #[macro_use]
extern crate solana_core; extern crate solana_ledger;
use rand::Rng; use rand::Rng;
use solana_core::{ use solana_ledger::blocktree::{entries_to_test_shreds, get_tmp_ledger_path, Blocktree};
blocktree::{entries_to_test_shreds, get_tmp_ledger_path, Blocktree}, use solana_ledger::entry::{create_ticks, Entry};
entry::{create_ticks, Entry},
};
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use std::path::Path; use std::path::Path;
use test::Bencher; use test::Bencher;

View File

@ -3,8 +3,8 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
use solana_core::poh::Poh;
use solana_core::poh_service::NUM_HASHES_PER_BATCH; use solana_core::poh_service::NUM_HASHES_PER_BATCH;
use solana_ledger::poh::Poh;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View File

@ -1,8 +1,7 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
use solana_core::entry::EntrySlice; use solana_ledger::entry::{next_entry_mut, Entry, EntrySlice};
use solana_core::entry::{next_entry_mut, Entry};
use solana_sdk::hash::{hash, Hash}; use solana_sdk::hash::{hash, Hash};
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction; use solana_sdk::system_transaction;

View File

@ -8,10 +8,10 @@ use solana_core::bank_forks::BankForks;
use solana_core::cluster_info::{ClusterInfo, Node}; use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo; use solana_core::contact_info::ContactInfo;
use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use solana_core::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use solana_core::leader_schedule_cache::LeaderScheduleCache;
use solana_core::packet::to_packets_chunked; use solana_core::packet::to_packets_chunked;
use solana_core::retransmit_stage::retransmitter; use solana_core::retransmit_stage::retransmitter;
use solana_core::test_tx::test_tx; use solana_core::test_tx::test_tx;
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -2,13 +2,12 @@
extern crate test; extern crate test;
use solana_core::entry::create_ticks; use solana_core::test_tx;
use solana_core::entry::Entry; use solana_ledger::entry::{create_ticks, Entry};
use solana_core::shred::{ use solana_ledger::shred::{
max_entries_per_n_shred, max_ticks_per_n_shreds, Shred, Shredder, RECOMMENDED_FEC_RATE, max_entries_per_n_shred, max_ticks_per_n_shreds, Shred, Shredder, RECOMMENDED_FEC_RATE,
SIZE_OF_SHRED_HEADER, SIZE_OF_SHRED_HEADER,
}; };
use solana_core::test_tx;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::packet::PACKET_DATA_SIZE; use solana_sdk::packet::PACKET_DATA_SIZE;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};

View File

@ -2,13 +2,9 @@
//! to contruct a software pipeline. The stage uses all available CPU cores and //! to contruct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU. //! can do its processing in parallel with signature verification on the GPU.
use crate::{ use crate::{
blocktree::Blocktree,
cluster_info::ClusterInfo, cluster_info::ClusterInfo,
entry::hash_transactions,
leader_schedule_cache::LeaderScheduleCache,
packet::PACKETS_PER_BATCH, packet::PACKETS_PER_BATCH,
packet::{Packet, Packets}, packet::{Packet, Packets},
perf_libs,
poh_recorder::{PohRecorder, PohRecorderError, WorkingBankEntry}, poh_recorder::{PohRecorder, PohRecorderError, WorkingBankEntry},
poh_service::PohService, poh_service::PohService,
result::{Error, Result}, result::{Error, Result},
@ -18,6 +14,10 @@ use crate::{
use bincode::deserialize; use bincode::deserialize;
use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError}; use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools; use itertools::Itertools;
use solana_ledger::{
blocktree::Blocktree, entry::hash_transactions, leader_schedule_cache::LeaderScheduleCache,
perf_libs,
};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info, inc_new_counter_warn}; use solana_metrics::{inc_new_counter_debug, inc_new_counter_info, inc_new_counter_warn};
use solana_runtime::{accounts_db::ErrorCounters, bank::Bank, transaction_batch::TransactionBatch}; use solana_runtime::{accounts_db::ErrorCounters, bank::Bank, transaction_batch::TransactionBatch};
@ -967,15 +967,14 @@ pub fn create_test_recorder(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::get_tmp_ledger_path;
use crate::cluster_info::Node; use crate::cluster_info::Node;
use crate::entry::{Entry, EntrySlice};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::packet::to_packets; use crate::packet::to_packets;
use crate::poh_recorder::WorkingBank; use crate::poh_recorder::WorkingBank;
use crate::{get_tmp_ledger_path, tmp_ledger_name};
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use itertools::Itertools; use itertools::Itertools;
use solana_ledger::blocktree::get_tmp_ledger_path;
use solana_ledger::entry::{Entry, EntrySlice};
use solana_sdk::instruction::InstructionError; use solana_sdk::instruction::InstructionError;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction; use solana_sdk::system_transaction;

View File

@ -2,11 +2,11 @@
//! local unix socket, to provide client services such as a block explorer with //! local unix socket, to provide client services such as a block explorer with
//! real-time access to entries. //! real-time access to entries.
use crate::entry::Entry;
use crate::result::Result; use crate::result::Result;
use bincode::serialize; use bincode::serialize;
use chrono::{SecondsFormat, Utc}; use chrono::{SecondsFormat, Utc};
use serde_json::json; use serde_json::json;
use solana_ledger::entry::Entry;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::cell::RefCell; use std::cell::RefCell;
@ -178,7 +178,6 @@ fn serialize_transactions(entry: &Entry) -> Vec<Vec<u8>> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::entry::Entry;
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use serde_json::Value; use serde_json::Value;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;

View File

@ -7,9 +7,9 @@ use crate::blockstream::BlockstreamEvents;
use crate::blockstream::MockBlockstream as Blockstream; use crate::blockstream::MockBlockstream as Blockstream;
#[cfg(not(test))] #[cfg(not(test))]
use crate::blockstream::SocketBlockstream as Blockstream; use crate::blockstream::SocketBlockstream as Blockstream;
use crate::blocktree::Blocktree;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use solana_ledger::blocktree::Blocktree;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::path::Path; use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -101,12 +101,12 @@ impl Service for BlockstreamService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::blocktree::create_new_tmp_ledger;
use crate::entry::{create_ticks, Entry};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use bincode::{deserialize, serialize}; use bincode::{deserialize, serialize};
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use serde_json::Value; use serde_json::Value;
use solana_ledger::blocktree::create_new_tmp_ledger;
use solana_ledger::entry::{create_ticks, Entry};
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction; use solana_sdk::system_transaction;

View File

@ -1,11 +1,11 @@
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blocktree::{Blocktree, SlotMeta};
use crate::entry::{Entry, EntrySlice};
use crate::leader_schedule_cache::LeaderScheduleCache;
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::thread_rng; use rand::thread_rng;
use rayon::prelude::*; use rayon::prelude::*;
use rayon::ThreadPool; use rayon::ThreadPool;
use solana_ledger::blocktree::{Blocktree, SlotMeta};
use solana_ledger::entry::{Entry, EntrySlice};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_metrics::{datapoint, datapoint_error, inc_new_counter_debug}; use solana_metrics::{datapoint, datapoint_error, inc_new_counter_debug};
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_runtime::transaction_batch::TransactionBatch; use solana_runtime::transaction_batch::TransactionBatch;
@ -450,12 +450,12 @@ fn process_pending_slots(
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use crate::{ use crate::genesis_utils::{
blocktree::create_new_tmp_ledger, create_genesis_block, create_genesis_block_with_leader, GenesisBlockInfo,
entry::{create_ticks, next_entry, next_entry_mut, Entry},
genesis_utils::{create_genesis_block, create_genesis_block_with_leader, GenesisBlockInfo},
}; };
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_ledger::blocktree::create_new_tmp_ledger;
use solana_ledger::entry::{create_ticks, next_entry, next_entry_mut, Entry};
use solana_sdk::{ use solana_sdk::{
epoch_schedule::EpochSchedule, epoch_schedule::EpochSchedule,
hash::Hash, hash::Hash,

View File

@ -2,12 +2,12 @@
use self::broadcast_fake_blobs_run::BroadcastFakeBlobsRun; use self::broadcast_fake_blobs_run::BroadcastFakeBlobsRun;
use self::fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun; use self::fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun;
use self::standard_broadcast_run::StandardBroadcastRun; use self::standard_broadcast_run::StandardBroadcastRun;
use crate::blocktree::Blocktree;
use crate::cluster_info::{ClusterInfo, ClusterInfoError}; use crate::cluster_info::{ClusterInfo, ClusterInfoError};
use crate::poh_recorder::WorkingBankEntry; use crate::poh_recorder::WorkingBankEntry;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use crate::staking_utils; use solana_ledger::blocktree::Blocktree;
use solana_ledger::staking_utils;
use solana_metrics::{inc_new_counter_error, inc_new_counter_info}; use solana_metrics::{inc_new_counter_error, inc_new_counter_info};
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -191,11 +191,11 @@ impl Service for BroadcastStage {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::blocktree::{get_tmp_ledger_path, Blocktree};
use crate::cluster_info::{ClusterInfo, Node}; use crate::cluster_info::{ClusterInfo, Node};
use crate::entry::create_ticks;
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::service::Service; use crate::service::Service;
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_ledger::entry::create_ticks;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -1,6 +1,6 @@
use super::*; use super::*;
use crate::entry::Entry; use solana_ledger::entry::Entry;
use crate::shred::{Shredder, RECOMMENDED_FEC_RATE}; use solana_ledger::shred::{Shredder, RECOMMENDED_FEC_RATE};
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
pub(super) struct BroadcastFakeBlobsRun { pub(super) struct BroadcastFakeBlobsRun {

View File

@ -1,6 +1,6 @@
use crate::entry::Entry;
use crate::poh_recorder::WorkingBankEntry; use crate::poh_recorder::WorkingBankEntry;
use crate::result::Result; use crate::result::Result;
use solana_ledger::entry::Entry;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use std::sync::mpsc::Receiver; use std::sync::mpsc::Receiver;
use std::sync::Arc; use std::sync::Arc;

View File

@ -1,5 +1,5 @@
use super::*; use super::*;
use crate::shred::{Shredder, RECOMMENDED_FEC_RATE}; use solana_ledger::shred::{Shredder, RECOMMENDED_FEC_RATE};
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
pub(super) struct FailEntryVerificationBroadcastRun {} pub(super) struct FailEntryVerificationBroadcastRun {}

View File

@ -1,8 +1,8 @@
use super::broadcast_utils::{self, ReceiveResults}; use super::broadcast_utils::{self, ReceiveResults};
use super::*; use super::*;
use crate::broadcast_stage::broadcast_utils::UnfinishedSlotInfo; use crate::broadcast_stage::broadcast_utils::UnfinishedSlotInfo;
use crate::entry::Entry; use solana_ledger::entry::Entry;
use crate::shred::{Shred, Shredder, RECOMMENDED_FEC_RATE}; use solana_ledger::shred::{Shred, Shredder, RECOMMENDED_FEC_RATE};
use solana_sdk::signature::Keypair; use solana_sdk::signature::Keypair;
use solana_sdk::timing::duration_as_us; use solana_sdk::timing::duration_as_us;
use std::time::Duration; use std::time::Duration;
@ -294,11 +294,11 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::blocktree::{get_tmp_ledger_path, Blocktree};
use crate::cluster_info::{ClusterInfo, Node}; use crate::cluster_info::{ClusterInfo, Node};
use crate::entry::create_ticks;
use crate::genesis_utils::create_genesis_block; use crate::genesis_utils::create_genesis_block;
use crate::shred::max_ticks_per_n_shreds; 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_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};

View File

@ -1,4 +1,4 @@
use crate::blocktree::Blocktree; use solana_ledger::blocktree::Blocktree;
use std::fs::File; use std::fs::File;
use std::io; use std::io;
use std::io::{BufWriter, Write}; use std::io::{BufWriter, Write};
@ -72,11 +72,11 @@ pub fn chacha_cbc_encrypt_ledger(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::blocktree::get_tmp_ledger_path;
use crate::blocktree::Blocktree;
use crate::chacha::chacha_cbc_encrypt_ledger; use crate::chacha::chacha_cbc_encrypt_ledger;
use crate::entry::Entry;
use crate::gen_keys::GenKeys; use crate::gen_keys::GenKeys;
use solana_ledger::blocktree::get_tmp_ledger_path;
use solana_ledger::blocktree::Blocktree;
use solana_ledger::entry::Entry;
use solana_sdk::hash::{hash, Hash, Hasher}; use solana_sdk::hash::{hash, Hash, Hasher};
use solana_sdk::signature::KeypairUtil; use solana_sdk::signature::KeypairUtil;
use solana_sdk::system_transaction; use solana_sdk::system_transaction;

View File

@ -1,8 +1,8 @@
// Module used by validators to approve storage mining proofs in parallel using the GPU // Module used by validators to approve storage mining proofs in parallel using the GPU
use crate::blocktree::Blocktree;
use crate::chacha::{CHACHA_BLOCK_SIZE, CHACHA_KEY_SIZE}; use crate::chacha::{CHACHA_BLOCK_SIZE, CHACHA_KEY_SIZE};
use crate::perf_libs; use solana_ledger::blocktree::Blocktree;
use solana_ledger::perf_libs;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use std::io; use std::io;
use std::mem::size_of; use std::mem::size_of;
@ -113,10 +113,10 @@ pub fn chacha_cbc_encrypt_file_many_keys(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::get_tmp_ledger_path;
use crate::chacha::chacha_cbc_encrypt_ledger; use crate::chacha::chacha_cbc_encrypt_ledger;
use crate::entry::create_ticks;
use crate::replicator::sample_file; use crate::replicator::sample_file;
use solana_ledger::blocktree::get_tmp_ledger_path;
use solana_ledger::entry::create_ticks;
use solana_sdk::clock::DEFAULT_SLOTS_PER_SEGMENT; use solana_sdk::clock::DEFAULT_SLOTS_PER_SEGMENT;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::fs::{remove_dir_all, remove_file}; use std::fs::{remove_dir_all, remove_file};

View File

@ -13,7 +13,6 @@
//! //!
//! Bank needs to provide an interface for us to query the stake weight //! Bank needs to provide an interface for us to query the stake weight
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blocktree::Blocktree;
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::crds_gossip::CrdsGossip; use crate::crds_gossip::CrdsGossip;
use crate::crds_gossip_error::CrdsGossipError; use crate::crds_gossip_error::CrdsGossipError;
@ -23,7 +22,6 @@ use crate::packet::{to_shared_blob, Blob, Packet, SharedBlob};
use crate::repair_service::RepairType; use crate::repair_service::RepairType;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::sendmmsg::{multicast, send_mmsg}; use crate::sendmmsg::{multicast, send_mmsg};
use crate::staking_utils;
use crate::streamer::{BlobReceiver, BlobSender}; use crate::streamer::{BlobReceiver, BlobSender};
use crate::weighted_shuffle::{weighted_best, weighted_shuffle}; use crate::weighted_shuffle::{weighted_best, weighted_shuffle};
use bincode::{deserialize, serialize, serialized_size}; use bincode::{deserialize, serialize, serialized_size};
@ -32,6 +30,8 @@ use itertools::Itertools;
use rand::SeedableRng; use rand::SeedableRng;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rand_chacha::ChaChaRng; use rand_chacha::ChaChaRng;
use solana_ledger::blocktree::Blocktree;
use solana_ledger::staking_utils;
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_error}; use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_error};
use solana_netutil::{ use solana_netutil::{
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range, bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
@ -1779,17 +1779,16 @@ fn report_time_spent(label: &str, time: &Duration, extra: &str) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::get_tmp_ledger_path;
use crate::blocktree::tests::make_many_slot_entries;
use crate::blocktree::Blocktree;
use crate::blocktree_processor::tests::fill_blocktree_slot_with_ticks; use crate::blocktree_processor::tests::fill_blocktree_slot_with_ticks;
use crate::crds_value::CrdsValueLabel; use crate::crds_value::CrdsValueLabel;
use crate::repair_service::RepairType; use crate::repair_service::RepairType;
use crate::result::Error; use crate::result::Error;
use crate::shred::max_ticks_per_n_shreds;
use crate::shred::{Shred, ShredHeader};
use crate::test_tx::test_tx; use crate::test_tx::test_tx;
use rayon::prelude::*; use rayon::prelude::*;
use solana_ledger::blocktree::get_tmp_ledger_path;
use solana_ledger::blocktree::make_many_slot_entries;
use solana_ledger::blocktree::Blocktree;
use solana_ledger::shred::{max_ticks_per_n_shreds, Shred, ShredHeader};
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::collections::HashSet; use std::collections::HashSet;

View File

@ -1,12 +1,13 @@
use crate::blocktree::Blocktree;
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::crds_value::EpochSlots; use crate::crds_value::EpochSlots;
use crate::result::Result; use crate::result::Result;
use crate::rooted_slot_iterator::RootedSlotIterator;
use crate::service::Service; use crate::service::Service;
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::SeedableRng; use rand::SeedableRng;
use rand_chacha::ChaChaRng; use rand_chacha::ChaChaRng;
use solana_ledger::blocktree::Blocktree;
use solana_metrics::datapoint; use solana_metrics::datapoint;
use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey}; use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey};
use std::{ use std::{
@ -264,7 +265,7 @@ impl ClusterInfoRepairListener {
num_slots_to_repair: usize, num_slots_to_repair: usize,
epoch_schedule: &EpochSchedule, epoch_schedule: &EpochSchedule,
) -> Result<()> { ) -> Result<()> {
let slot_iter = blocktree.rooted_slot_iterator(repairee_epoch_slots.root); let slot_iter = RootedSlotIterator::new(repairee_epoch_slots.root, &blocktree);
if slot_iter.is_err() { if slot_iter.is_err() {
info!( info!(
"Root for repairee is on different fork. My root: {}, repairee_root: {} repairee_pubkey: {:?}", "Root for repairee is on different fork. My root: {}, repairee_root: {} repairee_pubkey: {:?}",
@ -479,11 +480,11 @@ impl Service for ClusterInfoRepairListener {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::get_tmp_ledger_path;
use crate::blocktree::tests::make_many_slot_entries;
use crate::cluster_info::Node; use crate::cluster_info::Node;
use crate::packet::{Blob, SharedBlob}; use crate::packet::{Blob, SharedBlob};
use crate::streamer; use crate::streamer;
use solana_ledger::blocktree::get_tmp_ledger_path;
use solana_ledger::blocktree::make_many_slot_entries;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;

View File

@ -5,8 +5,8 @@
// copies from host memory to GPU memory unless the memory is page-pinned and // copies from host memory to GPU memory unless the memory is page-pinned and
// cannot be paged to disk. The cuda driver provides these interfaces to pin and unpin memory. // cannot be paged to disk. The cuda driver provides these interfaces to pin and unpin memory.
use crate::perf_libs;
use crate::recycler::Reset; use crate::recycler::Reset;
use solana_ledger::perf_libs;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
#[cfg(feature = "pin_gpu_memory")] #[cfg(feature = "pin_gpu_memory")]

View File

@ -1,14 +1 @@
pub use solana_runtime::genesis_utils::{ pub use solana_ledger::genesis_utils::*;
create_genesis_block_with_leader, GenesisBlockInfo, BOOTSTRAP_LEADER_LAMPORTS,
};
use solana_sdk::pubkey::Pubkey;
// same as genesis_block::create_genesis_block, but with bootstrap_leader staking logic
// for the core crate tests
pub fn create_genesis_block(mint_lamports: u64) -> GenesisBlockInfo {
create_genesis_block_with_leader(
mint_lamports,
&Pubkey::new_rand(),
BOOTSTRAP_LEADER_LAMPORTS,
)
}

View File

@ -1,13 +1,13 @@
//! The `gossip_service` module implements the network control plane. //! The `gossip_service` module implements the network control plane.
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blocktree::Blocktree;
use crate::cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE}; use crate::cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE};
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::service::Service; use crate::service::Service;
use crate::streamer; use crate::streamer;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_client::thin_client::{create_client, ThinClient}; use solana_client::thin_client::{create_client, ThinClient};
use solana_ledger::blocktree::Blocktree;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::net::{IpAddr, SocketAddr, UdpSocket}; use std::net::{IpAddr, SocketAddr, UdpSocket};

View File

@ -1,8 +1,8 @@
//! The `ledger_cleanup_service` drops older ledger data to limit disk space usage //! The `ledger_cleanup_service` drops older ledger data to limit disk space usage
use crate::blocktree::Blocktree;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use solana_ledger::blocktree::Blocktree;
use solana_sdk::clock::DEFAULT_SLOTS_PER_EPOCH; use solana_sdk::clock::DEFAULT_SLOTS_PER_EPOCH;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::string::ToString; use std::string::ToString;
@ -75,8 +75,8 @@ impl Service for LedgerCleanupService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::get_tmp_ledger_path; use solana_ledger::blocktree::get_tmp_ledger_path;
use crate::blocktree::tests::make_many_slot_entries; use solana_ledger::blocktree::make_many_slot_entries;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
#[test] #[test]

View File

@ -7,14 +7,11 @@
pub mod bank_forks; pub mod bank_forks;
pub mod banking_stage; pub mod banking_stage;
#[macro_use]
pub mod blocktree;
pub mod broadcast_stage; pub mod broadcast_stage;
pub mod chacha; pub mod chacha;
pub mod chacha_cuda; pub mod chacha_cuda;
pub mod cluster_info_vote_listener; pub mod cluster_info_vote_listener;
pub mod confidence; pub mod confidence;
pub mod perf_libs;
pub mod recycler; pub mod recycler;
pub mod shred_fetch_stage; pub mod shred_fetch_stage;
#[macro_use] #[macro_use]
@ -32,19 +29,13 @@ pub mod crds_gossip_pull;
pub mod crds_gossip_push; pub mod crds_gossip_push;
pub mod crds_value; pub mod crds_value;
pub mod cuda_runtime; pub mod cuda_runtime;
pub mod entry;
pub mod erasure;
pub mod fetch_stage; pub mod fetch_stage;
pub mod gen_keys; pub mod gen_keys;
pub mod genesis_utils; pub mod genesis_utils;
pub mod gossip_service; pub mod gossip_service;
pub mod leader_schedule;
pub mod leader_schedule_cache;
pub mod leader_schedule_utils;
pub mod ledger_cleanup_service; pub mod ledger_cleanup_service;
pub mod local_vote_signer_service; pub mod local_vote_signer_service;
pub mod packet; pub mod packet;
pub mod poh;
pub mod poh_recorder; pub mod poh_recorder;
pub mod poh_service; pub mod poh_service;
pub mod recvmmsg; pub mod recvmmsg;
@ -53,6 +44,7 @@ pub mod replay_stage;
pub mod replicator; pub mod replicator;
pub mod result; pub mod result;
pub mod retransmit_stage; pub mod retransmit_stage;
pub mod rooted_slot_iterator;
pub mod rpc; pub mod rpc;
pub mod rpc_pubsub; pub mod rpc_pubsub;
pub mod rpc_pubsub_service; pub mod rpc_pubsub_service;
@ -60,12 +52,10 @@ pub mod rpc_service;
pub mod rpc_subscriptions; pub mod rpc_subscriptions;
pub mod sendmmsg; pub mod sendmmsg;
pub mod service; pub mod service;
pub mod shred;
pub mod sigverify; pub mod sigverify;
pub mod sigverify_stage; pub mod sigverify_stage;
pub mod snapshot_package; pub mod snapshot_package;
pub mod snapshot_utils; pub mod snapshot_utils;
pub mod staking_utils;
pub mod storage_stage; pub mod storage_stage;
pub mod streamer; pub mod streamer;
pub mod test_tx; pub mod test_tx;
@ -76,9 +66,6 @@ pub(crate) mod version;
pub mod weighted_shuffle; pub mod weighted_shuffle;
pub mod window_service; pub mod window_service;
#[macro_use]
extern crate dlopen_derive;
#[macro_use] #[macro_use]
extern crate solana_budget_program; extern crate solana_budget_program;
@ -105,6 +92,9 @@ extern crate solana_metrics;
#[macro_use] #[macro_use]
extern crate matches; extern crate matches;
#[macro_use]
extern crate solana_ledger;
extern crate bzip2; extern crate bzip2;
extern crate crossbeam_channel; extern crate crossbeam_channel;
extern crate dir_diff; extern crate dir_diff;

View File

@ -1,12 +1,12 @@
//! The `packet` module defines data structures and methods to pull data from the network. //! The `packet` module defines data structures and methods to pull data from the network.
use crate::cuda_runtime::PinnedVec; use crate::cuda_runtime::PinnedVec;
use crate::erasure::ErasureConfig;
use crate::recvmmsg::{recv_mmsg, NUM_RCVMMSGS}; use crate::recvmmsg::{recv_mmsg, NUM_RCVMMSGS};
use crate::recycler::{Recycler, Reset}; use crate::recycler::{Recycler, Reset};
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use bincode; use bincode;
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use serde::Serialize; use serde::Serialize;
use solana_ledger::erasure::ErasureConfig;
use solana_metrics::inc_new_counter_debug; use solana_metrics::inc_new_counter_debug;
pub use solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE}; pub use solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -10,11 +10,11 @@
//! For Entries: //! For Entries:
//! * recorded entry must be >= WorkingBank::min_tick_height && entry must be < WorkingBank::max_tick_height //! * recorded entry must be >= WorkingBank::min_tick_height && entry must be < WorkingBank::max_tick_height
//! //!
use crate::blocktree::Blocktree;
use crate::entry::Entry;
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::poh::Poh;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use solana_ledger::blocktree::Blocktree;
use solana_ledger::entry::Entry;
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_ledger::poh::Poh;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
pub use solana_sdk::clock::Slot; pub use solana_sdk::clock::Slot;
use solana_sdk::clock::NUM_CONSECUTIVE_LEADER_SLOTS; use solana_sdk::clock::NUM_CONSECUTIVE_LEADER_SLOTS;
@ -459,9 +459,9 @@ impl PohRecorder {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::{get_tmp_ledger_path, Blocktree};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::test_tx::test_tx; use crate::test_tx::test_tx;
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT; use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT;
use solana_sdk::hash::hash; use solana_sdk::hash::hash;
use std::sync::mpsc::sync_channel; use std::sync::mpsc::sync_channel;

View File

@ -109,12 +109,12 @@ impl Service for PohService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::{get_tmp_ledger_path, Blocktree};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::poh_recorder::WorkingBank; use crate::poh_recorder::WorkingBank;
use crate::result::Result; use crate::result::Result;
use crate::test_tx::test_tx; use crate::test_tx::test_tx;
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::hash::hash; use solana_sdk::hash::hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -1,13 +1,10 @@
//! The `repair_service` module implements the tools necessary to generate a thread which //! The `repair_service` module implements the tools necessary to generate a thread which
//! regularly finds missing blobs in the ledger and sends repair requests for those blobs //! regularly finds missing blobs in the ledger and sends repair requests for those blobs
use crate::{ use crate::{
bank_forks::BankForks, bank_forks::BankForks, cluster_info::ClusterInfo,
blocktree::{Blocktree, CompletedSlotsReceiver, SlotMeta}, cluster_info_repair_listener::ClusterInfoRepairListener, result::Result, service::Service,
cluster_info::ClusterInfo,
cluster_info_repair_listener::ClusterInfoRepairListener,
result::Result,
service::Service,
}; };
use solana_ledger::blocktree::{Blocktree, CompletedSlotsReceiver, SlotMeta};
use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey}; use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey};
use std::{ use std::{
collections::BTreeSet, collections::BTreeSet,
@ -401,15 +398,15 @@ impl Service for RepairService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::blocktree::tests::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries,
};
use crate::blocktree::{get_tmp_ledger_path, Blocktree};
use crate::cluster_info::Node; use crate::cluster_info::Node;
use crate::shred::max_ticks_per_n_shreds;
use itertools::Itertools; use itertools::Itertools;
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_ledger::blocktree::{get_tmp_ledger_path, Blocktree};
use solana_ledger::blocktree::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries,
};
use solana_ledger::shred::max_ticks_per_n_shreds;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::thread::Builder; use std::thread::Builder;

View File

@ -1,21 +1,21 @@
//! The `replay_stage` replays transactions broadcast by the leader. //! The `replay_stage` replays transactions broadcast by the leader.
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blocktree::{Blocktree, BlocktreeError};
use crate::blocktree_processor; use crate::blocktree_processor;
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::confidence::{ use crate::confidence::{
AggregateConfidenceService, ConfidenceAggregationData, ForkConfidenceCache, AggregateConfidenceService, ConfidenceAggregationData, ForkConfidenceCache,
}; };
use crate::consensus::{StakeLockout, Tower}; use crate::consensus::{StakeLockout, Tower};
use crate::entry::{Entry, EntrySlice};
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::packet::BlobError; use crate::packet::BlobError;
use crate::poh_recorder::PohRecorder; use crate::poh_recorder::PohRecorder;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::rpc_subscriptions::RpcSubscriptions; use crate::rpc_subscriptions::RpcSubscriptions;
use crate::service::Service; use crate::service::Service;
use crate::snapshot_package::SnapshotPackageSender; use crate::snapshot_package::SnapshotPackageSender;
use solana_ledger::blocktree::{Blocktree, BlocktreeError};
use solana_ledger::entry::{Entry, EntrySlice};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_metrics::{datapoint_warn, inc_new_counter_info}; use solana_metrics::{datapoint_warn, inc_new_counter_info};
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
@ -868,13 +868,13 @@ impl Service for ReplayStage {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::blocktree::tests::make_slot_entries;
use crate::blocktree::{entries_to_test_shreds, get_tmp_ledger_path, BlocktreeError};
use crate::confidence::BankConfidence; use crate::confidence::BankConfidence;
use crate::entry;
use crate::genesis_utils::{create_genesis_block, create_genesis_block_with_leader}; use crate::genesis_utils::{create_genesis_block, create_genesis_block_with_leader};
use crate::replay_stage::ReplayStage; use crate::replay_stage::ReplayStage;
use crate::shred::{Shred, ShredHeader, DATA_COMPLETE_SHRED, SIZE_OF_SHRED_HEADER}; use solana_ledger::blocktree::make_slot_entries;
use solana_ledger::blocktree::{entries_to_test_shreds, get_tmp_ledger_path, BlocktreeError};
use solana_ledger::entry;
use solana_ledger::shred::{Shred, ShredHeader, DATA_COMPLETE_SHRED, SIZE_OF_SHRED_HEADER};
use solana_runtime::genesis_utils::GenesisBlockInfo; use solana_runtime::genesis_utils::GenesisBlockInfo;
use solana_sdk::hash::{hash, Hash}; use solana_sdk::hash::{hash, Hash};
use solana_sdk::packet::PACKET_DATA_SIZE; use solana_sdk::packet::PACKET_DATA_SIZE;

View File

@ -1,16 +1,13 @@
use crate::blocktree::Blocktree;
use crate::chacha::{chacha_cbc_encrypt_ledger, CHACHA_BLOCK_SIZE}; use crate::chacha::{chacha_cbc_encrypt_ledger, CHACHA_BLOCK_SIZE};
use crate::cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE}; use crate::cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE};
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::gossip_service::GossipService; use crate::gossip_service::GossipService;
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::packet::to_shared_blob; use crate::packet::to_shared_blob;
use crate::recycler::Recycler; use crate::recycler::Recycler;
use crate::repair_service; use crate::repair_service;
use crate::repair_service::{RepairService, RepairSlotRange, RepairStrategy}; use crate::repair_service::{RepairService, RepairSlotRange, RepairStrategy};
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use crate::shred::Shred;
use crate::shred_fetch_stage::ShredFetchStage; use crate::shred_fetch_stage::ShredFetchStage;
use crate::storage_stage::NUM_STORAGE_SAMPLES; use crate::storage_stage::NUM_STORAGE_SAMPLES;
use crate::streamer::{receiver, responder, PacketReceiver}; use crate::streamer::{receiver, responder, PacketReceiver};
@ -24,6 +21,9 @@ use solana_client::rpc_client::RpcClient;
use solana_client::rpc_request::RpcRequest; use solana_client::rpc_request::RpcRequest;
use solana_client::thin_client::ThinClient; use solana_client::thin_client::ThinClient;
use solana_ed25519_dalek as ed25519_dalek; 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_netutil::bind_in_range; use solana_netutil::bind_in_range;
use solana_sdk::account_utils::State; use solana_sdk::account_utils::State;
use solana_sdk::client::{AsyncClient, SyncClient}; use solana_sdk::client::{AsyncClient, SyncClient};

View File

@ -1,11 +1,11 @@
//! The `result` module exposes a Result type that propagates one of many different Error types. //! The `result` module exposes a Result type that propagates one of many different Error types.
use crate::blocktree;
use crate::cluster_info; use crate::cluster_info;
use crate::packet; use crate::packet;
use crate::poh_recorder; use crate::poh_recorder;
use bincode; use bincode;
use serde_json; use serde_json;
use solana_ledger::blocktree;
use solana_sdk::transaction; use solana_sdk::transaction;
use std; use std;
use std::any::Any; use std::any::Any;

View File

@ -2,18 +2,20 @@
use crate::{ use crate::{
bank_forks::BankForks, bank_forks::BankForks,
blocktree::{Blocktree, CompletedSlotsReceiver},
cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT}, cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT},
leader_schedule_cache::LeaderScheduleCache,
repair_service::RepairStrategy, repair_service::RepairStrategy,
result::{Error, Result}, result::{Error, Result},
service::Service, service::Service,
staking_utils,
streamer::PacketReceiver, streamer::PacketReceiver,
window_service::{should_retransmit_and_persist, WindowService}, window_service::{should_retransmit_and_persist, WindowService},
}; };
use rand::SeedableRng; use rand::SeedableRng;
use rand_chacha::ChaChaRng; use rand_chacha::ChaChaRng;
use solana_ledger::{
blocktree::{Blocktree, CompletedSlotsReceiver},
leader_schedule_cache::LeaderScheduleCache,
staking_utils,
};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::inc_new_counter_error; use solana_metrics::inc_new_counter_error;
use solana_sdk::epoch_schedule::EpochSchedule; use solana_sdk::epoch_schedule::EpochSchedule;
@ -260,11 +262,11 @@ impl Service for RetransmitStage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::create_new_tmp_ledger;
use crate::blocktree_processor::{process_blocktree, ProcessOptions}; use crate::blocktree_processor::{process_blocktree, ProcessOptions};
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::packet::{Meta, Packet, Packets}; use crate::packet::{Meta, Packet, Packets};
use solana_ledger::blocktree::create_new_tmp_ledger;
use solana_netutil::find_available_port_in_range; use solana_netutil::find_available_port_in_range;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -1,12 +1,12 @@
use super::*; use solana_ledger::blocktree::*;
pub struct RootedSlotIterator<'a> { pub struct RootedSlotIterator<'a> {
next_slots: Vec<u64>, next_slots: Vec<u64>,
blocktree: &'a super::Blocktree, blocktree: &'a Blocktree,
} }
impl<'a> RootedSlotIterator<'a> { impl<'a> RootedSlotIterator<'a> {
pub fn new(start_slot: u64, blocktree: &'a super::Blocktree) -> Result<Self> { pub fn new(start_slot: u64, blocktree: &'a Blocktree) -> Result<Self> {
if blocktree.is_root(start_slot) { if blocktree.is_root(start_slot) {
Ok(Self { Ok(Self {
next_slots: vec![start_slot], next_slots: vec![start_slot],
@ -18,7 +18,7 @@ impl<'a> RootedSlotIterator<'a> {
} }
} }
impl<'a> Iterator for RootedSlotIterator<'a> { impl<'a> Iterator for RootedSlotIterator<'a> {
type Item = (u64, super::SlotMeta); type Item = (u64, SlotMeta);
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
// Clone b/c passing the closure to the map below requires exclusive access to // Clone b/c passing the closure to the map below requires exclusive access to
@ -53,6 +53,7 @@ impl<'a> Iterator for RootedSlotIterator<'a> {
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree_processor::tests::fill_blocktree_slot_with_ticks; use crate::blocktree_processor::tests::fill_blocktree_slot_with_ticks;
use solana_sdk::hash::Hash;
#[test] #[test]
fn test_rooted_slot_iterator() { fn test_rooted_slot_iterator() {

View File

@ -505,7 +505,7 @@ impl RpcSol for RpcSolImpl {
fn get_leader_schedule(&self, meta: Self::Metadata) -> Result<Option<Vec<String>>> { fn get_leader_schedule(&self, meta: Self::Metadata) -> Result<Option<Vec<String>>> {
let bank = meta.request_processor.read().unwrap().bank(); let bank = meta.request_processor.read().unwrap().bank();
Ok( Ok(
crate::leader_schedule_utils::leader_schedule(bank.epoch(), &bank).map( solana_ledger::leader_schedule_utils::leader_schedule(bank.epoch(), &bank).map(
|leader_schedule| { |leader_schedule| {
leader_schedule leader_schedule
.get_slot_leaders() .get_slot_leaders()

View File

@ -6,11 +6,11 @@
use crate::cuda_runtime::PinnedVec; use crate::cuda_runtime::PinnedVec;
use crate::packet::{Packet, Packets}; use crate::packet::{Packet, Packets};
use crate::perf_libs;
use crate::recycler::Recycler; use crate::recycler::Recycler;
use crate::result::Result; use crate::result::Result;
use bincode::serialized_size; use bincode::serialized_size;
use rayon::ThreadPool; use rayon::ThreadPool;
use solana_ledger::perf_libs;
use solana_metrics::inc_new_counter_debug; use solana_metrics::inc_new_counter_debug;
use solana_sdk::message::MessageHeader; use solana_sdk::message::MessageHeader;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;

View File

@ -7,7 +7,6 @@
use crate::cuda_runtime::PinnedVec; use crate::cuda_runtime::PinnedVec;
use crate::packet::Packets; use crate::packet::Packets;
use crate::perf_libs;
use crate::recycler::Recycler; use crate::recycler::Recycler;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
@ -15,6 +14,7 @@ use crate::sigverify;
use crate::sigverify::TxOffset; use crate::sigverify::TxOffset;
use crate::streamer::{self, PacketReceiver}; use crate::streamer::{self, PacketReceiver};
use crossbeam_channel::Sender as CrossbeamSender; use crossbeam_channel::Sender as CrossbeamSender;
use solana_ledger::perf_libs;
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::{datapoint_debug, inc_new_counter_info}; use solana_metrics::{datapoint_debug, inc_new_counter_info};
use solana_sdk::timing; use solana_sdk::timing;

View File

@ -3,13 +3,13 @@
// to submit its proof for mining to be rewarded. // to submit its proof for mining to be rewarded.
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blocktree::Blocktree;
use crate::chacha_cuda::chacha_cbc_encrypt_file_many_keys; use crate::chacha_cuda::chacha_cbc_encrypt_file_many_keys;
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand_chacha::ChaChaRng; use rand_chacha::ChaChaRng;
use solana_ledger::blocktree::Blocktree;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_runtime::storage_utils::replicator_accounts; use solana_runtime::storage_utils::replicator_accounts;
use solana_sdk::account::Account; use solana_sdk::account::Account;
@ -411,7 +411,7 @@ impl StorageStage {
// TODO: cuda required to generate the reference values // TODO: cuda required to generate the reference values
// but if it is missing, then we need to take care not to // but if it is missing, then we need to take care not to
// process storage mining results. // process storage mining results.
if crate::perf_libs::api().is_some() { if solana_ledger::perf_libs::api().is_some() {
// Lock the keys, since this is the IV memory, // Lock the keys, since this is the IV memory,
// it will be updated in-place by the encryption. // it will be updated in-place by the encryption.
// Should be overwritten by the proof signatures which replace the // Should be overwritten by the proof signatures which replace the
@ -629,13 +629,14 @@ impl Service for StorageStage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::{create_new_tmp_ledger, Blocktree}; use crate::blocktree_processor;
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::service::Service; use crate::service::Service;
use crate::{blocktree_processor, entry};
use rayon::prelude::*; use rayon::prelude::*;
use solana_ledger::blocktree::{create_new_tmp_ledger, Blocktree};
use solana_ledger::entry;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT; use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT;
use solana_sdk::hash::{Hash, Hasher}; use solana_sdk::hash::{Hash, Hasher};
@ -750,7 +751,7 @@ mod tests {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
bank_sender.send(rooted_banks).unwrap(); bank_sender.send(rooted_banks).unwrap();
if crate::perf_libs::api().is_some() { if solana_ledger::perf_libs::api().is_some() {
for _ in 0..5 { for _ in 0..5 {
result = storage_state.get_mining_result(&signature); result = storage_state.get_mining_result(&signature);
if result != Hash::default() { if result != Hash::default() {
@ -766,7 +767,7 @@ mod tests {
exit.store(true, Ordering::Relaxed); exit.store(true, Ordering::Relaxed);
storage_stage.join().unwrap(); storage_stage.join().unwrap();
if crate::perf_libs::api().is_some() { if solana_ledger::perf_libs::api().is_some() {
assert_ne!(result, Hash::default()); assert_ne!(result, Hash::default());
} else { } else {
assert_eq!(result, Hash::default()); assert_eq!(result, Hash::default());

View File

@ -2,7 +2,6 @@
//! multi-stage transaction processing pipeline in software. //! multi-stage transaction processing pipeline in software.
use crate::banking_stage::BankingStage; use crate::banking_stage::BankingStage;
use crate::blocktree::Blocktree;
use crate::broadcast_stage::{BroadcastStage, BroadcastStageType}; use crate::broadcast_stage::{BroadcastStage, BroadcastStageType};
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::cluster_info_vote_listener::ClusterInfoVoteListener; use crate::cluster_info_vote_listener::ClusterInfoVoteListener;
@ -11,6 +10,7 @@ use crate::poh_recorder::{PohRecorder, WorkingBankEntry};
use crate::service::Service; use crate::service::Service;
use crate::sigverify_stage::SigVerifyStage; use crate::sigverify_stage::SigVerifyStage;
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_ledger::blocktree::Blocktree;
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::mpsc::{channel, Receiver}; use std::sync::mpsc::{channel, Receiver};

View File

@ -14,10 +14,8 @@
use crate::bank_forks::BankForks; use crate::bank_forks::BankForks;
use crate::blockstream_service::BlockstreamService; use crate::blockstream_service::BlockstreamService;
use crate::blocktree::{Blocktree, CompletedSlotsReceiver};
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::confidence::ForkConfidenceCache; use crate::confidence::ForkConfidenceCache;
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::ledger_cleanup_service::LedgerCleanupService; use crate::ledger_cleanup_service::LedgerCleanupService;
use crate::poh_recorder::PohRecorder; use crate::poh_recorder::PohRecorder;
use crate::replay_stage::ReplayStage; use crate::replay_stage::ReplayStage;
@ -27,6 +25,8 @@ use crate::service::Service;
use crate::shred_fetch_stage::ShredFetchStage; use crate::shred_fetch_stage::ShredFetchStage;
use crate::snapshot_package::SnapshotPackagerService; use crate::snapshot_package::SnapshotPackagerService;
use crate::storage_stage::{StorageStage, StorageState}; use crate::storage_stage::{StorageStage, StorageState};
use solana_ledger::blocktree::{Blocktree, CompletedSlotsReceiver};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::net::UdpSocket; use std::net::UdpSocket;
@ -226,9 +226,9 @@ impl Service for Tvu {
pub mod tests { pub mod tests {
use super::*; use super::*;
use crate::banking_stage::create_test_recorder; use crate::banking_stage::create_test_recorder;
use crate::blocktree::create_new_tmp_ledger;
use crate::cluster_info::{ClusterInfo, Node}; use crate::cluster_info::{ClusterInfo, Node};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use solana_ledger::blocktree::create_new_tmp_ledger;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;

View File

@ -1,14 +1,12 @@
//! The `validator` module hosts all the validator microservices. //! The `validator` module hosts all the validator microservices.
use crate::bank_forks::{BankForks, SnapshotConfig}; use crate::bank_forks::{BankForks, SnapshotConfig};
use crate::blocktree::{Blocktree, CompletedSlotsReceiver};
use crate::blocktree_processor::{self, BankForksInfo}; use crate::blocktree_processor::{self, BankForksInfo};
use crate::broadcast_stage::BroadcastStageType; use crate::broadcast_stage::BroadcastStageType;
use crate::cluster_info::{ClusterInfo, Node}; use crate::cluster_info::{ClusterInfo, Node};
use crate::confidence::ForkConfidenceCache; use crate::confidence::ForkConfidenceCache;
use crate::contact_info::ContactInfo; use crate::contact_info::ContactInfo;
use crate::gossip_service::{discover_cluster, GossipService}; use crate::gossip_service::{discover_cluster, GossipService};
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::poh_recorder::PohRecorder; use crate::poh_recorder::PohRecorder;
use crate::poh_service::PohService; use crate::poh_service::PohService;
use crate::rpc::JsonRpcConfig; use crate::rpc::JsonRpcConfig;
@ -21,6 +19,8 @@ use crate::snapshot_utils;
use crate::storage_stage::StorageState; use crate::storage_stage::StorageState;
use crate::tpu::Tpu; use crate::tpu::Tpu;
use crate::tvu::{Sockets, Tvu}; use crate::tvu::{Sockets, Tvu};
use solana_ledger::blocktree::{Blocktree, CompletedSlotsReceiver};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_metrics::datapoint_info; use solana_metrics::datapoint_info;
use solana_sdk::clock::{Slot, DEFAULT_SLOTS_PER_TURN}; use solana_sdk::clock::{Slot, DEFAULT_SLOTS_PER_TURN};
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
@ -120,7 +120,7 @@ impl Validator {
warn!("vote pubkey: {:?}", vote_account); warn!("vote pubkey: {:?}", vote_account);
warn!( warn!(
"CUDA is {}abled", "CUDA is {}abled",
if crate::perf_libs::api().is_some() { if solana_ledger::perf_libs::api().is_some() {
"en" "en"
} else { } else {
"dis" "dis"
@ -575,8 +575,8 @@ impl Service for Validator {
} }
pub fn new_validator_for_tests() -> (Validator, ContactInfo, Keypair, PathBuf) { pub fn new_validator_for_tests() -> (Validator, ContactInfo, Keypair, PathBuf) {
use crate::blocktree::create_new_tmp_ledger;
use crate::genesis_utils::{create_genesis_block_with_leader, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block_with_leader, GenesisBlockInfo};
use solana_ledger::blocktree::create_new_tmp_ledger;
let node_keypair = Arc::new(Keypair::new()); let node_keypair = Arc::new(Keypair::new());
let node = Node::new_localhost_with_pubkey(&node_keypair.pubkey()); let node = Node::new_localhost_with_pubkey(&node_keypair.pubkey());
@ -616,8 +616,8 @@ pub fn new_validator_for_tests() -> (Validator, ContactInfo, Keypair, PathBuf) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::blocktree::create_new_tmp_ledger;
use crate::genesis_utils::create_genesis_block_with_leader; use crate::genesis_utils::create_genesis_block_with_leader;
use solana_ledger::blocktree::create_new_tmp_ledger;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
#[test] #[test]

View File

@ -1,16 +1,16 @@
//! `window_service` handles the data plane incoming blobs, storing them in //! `window_service` handles the data plane incoming blobs, storing them in
//! blocktree and retransmitting where required //! blocktree and retransmitting where required
//! //!
use crate::blocktree::{self, Blocktree};
use crate::cluster_info::ClusterInfo; use crate::cluster_info::ClusterInfo;
use crate::leader_schedule_cache::LeaderScheduleCache;
use crate::repair_service::{RepairService, RepairStrategy}; use crate::repair_service::{RepairService, RepairStrategy};
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use crate::service::Service; use crate::service::Service;
use crate::shred::Shred;
use crate::streamer::{PacketReceiver, PacketSender}; use crate::streamer::{PacketReceiver, PacketSender};
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
use rayon::ThreadPool; use rayon::ThreadPool;
use solana_ledger::blocktree::{self, Blocktree};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_ledger::shred::Shred;
use solana_metrics::{inc_new_counter_debug, inc_new_counter_error}; use solana_metrics::{inc_new_counter_debug, inc_new_counter_error};
use solana_rayon_threadlimit::get_thread_count; use solana_rayon_threadlimit::get_thread_count;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
@ -267,19 +267,19 @@ impl Service for WindowService {
mod test { mod test {
use super::*; use super::*;
use crate::{ use crate::{
blocktree::tests::make_many_slot_entries,
blocktree::{get_tmp_ledger_path, Blocktree},
cluster_info::ClusterInfo, cluster_info::ClusterInfo,
contact_info::ContactInfo, contact_info::ContactInfo,
entry::{create_ticks, Entry},
genesis_utils::create_genesis_block_with_leader, genesis_utils::create_genesis_block_with_leader,
packet::{Packet, Packets}, packet::{Packet, Packets},
repair_service::RepairSlotRange, repair_service::RepairSlotRange,
service::Service, service::Service,
shred::Shredder,
shred::SIZE_OF_SHRED_TYPE,
}; };
use rand::{seq::SliceRandom, thread_rng}; use rand::{seq::SliceRandom, thread_rng};
use solana_ledger::{
blocktree::{get_tmp_ledger_path, make_many_slot_entries, Blocktree},
entry::{create_ticks, Entry},
shred::{Shredder, SIZE_OF_SHRED_TYPE},
};
use solana_sdk::{ use solana_sdk::{
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
hash::Hash, hash::Hash,

View File

@ -15,8 +15,8 @@ serde = "1.0.101"
serde_derive = "1.0.101" serde_derive = "1.0.101"
serde_json = "1.0.41" serde_json = "1.0.41"
serde_yaml = "0.8.11" serde_yaml = "0.8.11"
solana-core = { path = "../core", version = "0.20.0" }
solana-genesis-programs = { path = "../genesis_programs", version = "0.20.0" } solana-genesis-programs = { path = "../genesis_programs", version = "0.20.0" }
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-sdk = { path = "../sdk", version = "0.20.0" } solana-sdk = { path = "../sdk", version = "0.20.0" }
solana-stake-api = { path = "../programs/stake_api", version = "0.20.0" } solana-stake-api = { path = "../programs/stake_api", version = "0.20.0" }
solana-storage-api = { path = "../programs/storage_api", version = "0.20.0" } solana-storage-api = { path = "../programs/storage_api", version = "0.20.0" }

View File

@ -1,9 +1,9 @@
//! A command-line executable for generating the chain's genesis block. //! A command-line executable for generating the chain's genesis block.
use clap::{crate_description, crate_name, crate_version, value_t_or_exit, App, Arg}; use clap::{crate_description, crate_name, crate_version, value_t_or_exit, App, Arg};
use solana_core::blocktree::create_new_ledger;
use solana_core::poh::compute_hashes_per_tick;
use solana_genesis::Base64Account; use solana_genesis::Base64Account;
use solana_ledger::blocktree::create_new_ledger;
use solana_ledger::poh::compute_hashes_per_tick;
use solana_sdk::{ use solana_sdk::{
account::Account, account::Account,
clock, clock,

View File

@ -16,6 +16,7 @@ serde_derive = "1.0.101"
serde_json = "1.0.41" serde_json = "1.0.41"
serde_yaml = "0.8.11" serde_yaml = "0.8.11"
solana-core = { path = "../core", version = "0.20.0" } solana-core = { path = "../core", version = "0.20.0" }
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-logger = { path = "../logger", version = "0.20.0" } solana-logger = { path = "../logger", version = "0.20.0" }
solana-runtime = { path = "../runtime", version = "0.20.0" } solana-runtime = { path = "../runtime", version = "0.20.0" }
solana-sdk = { path = "../sdk", version = "0.20.0" } solana-sdk = { path = "../sdk", version = "0.20.0" }

View File

@ -1,6 +1,7 @@
use clap::{crate_description, crate_name, crate_version, value_t_or_exit, App, Arg, SubCommand}; use clap::{crate_description, crate_name, crate_version, value_t_or_exit, App, Arg, SubCommand};
use solana_core::blocktree::Blocktree;
use solana_core::blocktree_processor::{process_blocktree, ProcessOptions}; use solana_core::blocktree_processor::{process_blocktree, ProcessOptions};
use solana_core::rooted_slot_iterator::RootedSlotIterator;
use solana_ledger::blocktree::Blocktree;
use solana_sdk::clock::Slot; use solana_sdk::clock::Slot;
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -36,9 +37,8 @@ fn output_slot(blocktree: &Blocktree, slot: u64, method: &LedgerOutputMethod) {
} }
fn output_ledger(blocktree: Blocktree, starting_slot: u64, method: LedgerOutputMethod) { fn output_ledger(blocktree: Blocktree, starting_slot: u64, method: LedgerOutputMethod) {
let rooted_slot_iterator = blocktree let rooted_slot_iterator =
.rooted_slot_iterator(starting_slot) RootedSlotIterator::new(starting_slot, &blocktree).unwrap_or_else(|err| {
.unwrap_or_else(|err| {
eprintln!( eprintln!(
"Failed to load entries starting from slot {}: {:?}", "Failed to load entries starting from slot {}: {:?}",
starting_slot, err starting_slot, err
@ -188,9 +188,8 @@ fn main() {
let slot_hashes: BTreeMap<u64, String> = let slot_hashes: BTreeMap<u64, String> =
serde_yaml::from_reader(prune_file).unwrap(); serde_yaml::from_reader(prune_file).unwrap();
let iter = blocktree let iter =
.rooted_slot_iterator(0) RootedSlotIterator::new(0, &blocktree).expect("Failed to get rooted slot");
.expect("Failed to get rooted slot");
let potential_hashes: Vec<_> = iter let potential_hashes: Vec<_> = iter
.filter_map(|(slot, meta)| { .filter_map(|(slot, meta)| {
@ -231,9 +230,7 @@ fn main() {
usize::from_str(DEFAULT_ROOT_COUNT).unwrap() usize::from_str(DEFAULT_ROOT_COUNT).unwrap()
}; };
let iter = blocktree let iter = RootedSlotIterator::new(0, &blocktree).expect("Failed to get rooted slot");
.rooted_slot_iterator(0)
.expect("Failed to get rooted slot");
let slot_hash: Vec<_> = iter let slot_hash: Vec<_> = iter
.filter_map(|(slot, meta)| { .filter_map(|(slot, meta)| {

View File

@ -1,9 +1,9 @@
#[macro_use] #[macro_use]
extern crate solana_core; extern crate solana_ledger;
use assert_cmd::prelude::*; use assert_cmd::prelude::*;
use solana_core::blocktree::create_new_tmp_ledger;
use solana_core::genesis_utils::create_genesis_block; use solana_core::genesis_utils::create_genesis_block;
use solana_ledger::blocktree::create_new_tmp_ledger;
use std::process::Command; use std::process::Command;
use std::process::Output; use std::process::Output;

49
ledger/Cargo.toml Normal file
View File

@ -0,0 +1,49 @@
[package]
name = "solana-ledger"
version = "0.20.0"
description = "Solana ledger"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
bincode = "1.2.0"
byteorder = "1.3.2"
chrono = { version = "0.4.9", features = ["serde"] }
dlopen = "0.1.8"
dlopen_derive = "0.1.4"
itertools = "0.8.0"
lazy_static = "1.4.0"
log = { version = "0.4.8" }
rand = "0.6.5"
rand_chacha = "0.1.1"
rayon = "1.2.0"
reed-solomon-erasure = { package = "solana-reed-solomon-erasure", version = "4.0.1-3", features = ["simd-accel"] }
serde = "1.0.101"
serde_derive = "1.0.101"
solana-logger = { path = "../logger", version = "0.20.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "0.20.0" }
solana-metrics = { path = "../metrics", version = "0.20.0" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.20.0" }
solana-runtime = { path = "../runtime", version = "0.20.0" }
solana-sdk = { path = "../sdk", version = "0.20.0" }
solana-stake-api = { path = "../programs/stake_api", version = "0.20.0" }
solana-vote-api = { path = "../programs/vote_api", version = "0.20.0" }
sys-info = "0.5.8"
[dependencies.rocksdb]
# Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts
# when also using the bzip2 crate
version = "0.11.0"
default-features = false
features = ["lz4"]
[dev-dependencies]
matches = "0.1.6"
solana-budget-api = { path = "../programs/budget_api", version = "0.20.0" }
[lib]
crate-type = ["lib"]
name = "solana_ledger"

View File

@ -1,7 +1,7 @@
//! The `block_tree` module provides functions for parallel verification of the //! The `blocktree` module provides functions for parallel verification of the
//! Proof of History ledger as well as iterative read, append write, and random //! Proof of History ledger as well as iterative read, append write, and random
//! access read to a persistent file-based ledger. //! access read to a persistent file-based ledger.
use crate::entry::Entry; use crate::entry::{create_ticks, Entry};
use crate::erasure::ErasureConfig; use crate::erasure::ErasureConfig;
use crate::shred::{Shred, Shredder}; use crate::shred::{Shred, Shredder};
@ -9,7 +9,7 @@ use bincode::deserialize;
use std::collections::HashMap; use std::collections::HashMap;
use rocksdb; use log::*;
use solana_metrics::{datapoint_debug, datapoint_error}; use solana_metrics::{datapoint_debug, datapoint_error};
@ -28,13 +28,11 @@ use std::sync::{Arc, RwLock};
use std::time::Instant; use std::time::Instant;
pub use self::meta::*; pub use self::meta::*;
pub use self::rooted_slot_iterator::*;
use crate::leader_schedule_cache::LeaderScheduleCache; use crate::leader_schedule_cache::LeaderScheduleCache;
use solana_sdk::clock::Slot; use solana_sdk::clock::Slot;
mod db; mod db;
mod meta; mod meta;
mod rooted_slot_iterator;
pub use db::columns; pub use db::columns;
use db::{columns as cf, Column, IteratorDirection, IteratorMode}; use db::{columns as cf, Column, IteratorDirection, IteratorMode};
@ -291,10 +289,6 @@ impl Blocktree {
self.orphans_cf.get(slot) self.orphans_cf.get(slot)
} }
pub fn rooted_slot_iterator(&self, slot: u64) -> Result<RootedSlotIterator> {
RootedSlotIterator::new(slot, self)
}
pub fn slot_meta_iterator(&self, slot: u64) -> Result<impl Iterator<Item = (u64, SlotMeta)>> { pub fn slot_meta_iterator(&self, slot: u64) -> Result<impl Iterator<Item = (u64, SlotMeta)>> {
let meta_iter = self let meta_iter = self
.db .db
@ -1687,10 +1681,59 @@ pub fn entries_to_test_shreds(
shredder.entries_to_shreds(&entries, is_full_slot, 0).0 shredder.entries_to_shreds(&entries, is_full_slot, 0).0
} }
pub fn make_slot_entries(
slot: u64,
parent_slot: u64,
num_entries: u64,
) -> (Vec<Shred>, Vec<Entry>) {
let entries = create_ticks(num_entries, Hash::default());
let shreds = entries_to_test_shreds(entries.clone(), slot, parent_slot, true);
(shreds, entries)
}
pub fn make_many_slot_entries(
start_slot: u64,
num_slots: u64,
entries_per_slot: u64,
) -> (Vec<Shred>, Vec<Entry>) {
let mut shreds = vec![];
let mut entries = vec![];
for slot in start_slot..start_slot + num_slots {
let parent_slot = if slot == 0 { 0 } else { slot - 1 };
let (slot_shreds, slot_entries) = make_slot_entries(slot, parent_slot, entries_per_slot);
shreds.extend(slot_shreds);
entries.extend(slot_entries);
}
(shreds, entries)
}
// Create shreds for slots that have a parent-child relationship defined by the input `chain`
pub fn make_chaining_slot_entries(
chain: &[u64],
entries_per_slot: u64,
) -> Vec<(Vec<Shred>, Vec<Entry>)> {
let mut slots_shreds_and_entries = vec![];
for (i, slot) in chain.iter().enumerate() {
let parent_slot = {
if *slot == 0 || i == 0 {
0
} else {
chain[i - 1]
}
};
let result = make_slot_entries(*slot, parent_slot, entries_per_slot);
slots_shreds_and_entries.push(result);
}
slots_shreds_and_entries
}
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use crate::entry::{create_ticks, Entry};
use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo}; use crate::genesis_utils::{create_genesis_block, GenesisBlockInfo};
use crate::shred::max_ticks_per_n_shreds; use crate::shred::max_ticks_per_n_shreds;
use itertools::Itertools; use itertools::Itertools;
@ -3507,55 +3550,4 @@ pub mod tests {
drop(blocktree); drop(blocktree);
Blocktree::destroy(&blocktree_path).expect("Expected successful database destruction"); Blocktree::destroy(&blocktree_path).expect("Expected successful database destruction");
} }
pub fn make_slot_entries(
slot: u64,
parent_slot: u64,
num_entries: u64,
) -> (Vec<Shred>, Vec<Entry>) {
let entries = create_ticks(num_entries, Hash::default());
let shreds = entries_to_test_shreds(entries.clone(), slot, parent_slot, true);
(shreds, entries)
}
pub fn make_many_slot_entries(
start_slot: u64,
num_slots: u64,
entries_per_slot: u64,
) -> (Vec<Shred>, Vec<Entry>) {
let mut shreds = vec![];
let mut entries = vec![];
for slot in start_slot..start_slot + num_slots {
let parent_slot = if slot == 0 { 0 } else { slot - 1 };
let (slot_shreds, slot_entries) =
make_slot_entries(slot, parent_slot, entries_per_slot);
shreds.extend(slot_shreds);
entries.extend(slot_entries);
}
(shreds, entries)
}
// Create shreds for slots that have a parent-child relationship defined by the input `chain`
pub fn make_chaining_slot_entries(
chain: &[u64],
entries_per_slot: u64,
) -> Vec<(Vec<Shred>, Vec<Entry>)> {
let mut slots_shreds_and_entries = vec![];
for (i, slot) in chain.iter().enumerate() {
let parent_slot = {
if *slot == 0 || i == 0 {
0
} else {
chain[i - 1]
}
};
let result = make_slot_entries(*slot, parent_slot, entries_per_slot);
slots_shreds_and_entries.push(result);
}
slots_shreds_and_entries
}
} }

View File

@ -2,6 +2,7 @@ use crate::blocktree::{BlocktreeError, Result};
use bincode::{deserialize, serialize}; use bincode::{deserialize, serialize};
use byteorder::{BigEndian, ByteOrder}; use byteorder::{BigEndian, ByteOrder};
use log::*;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use serde::Serialize; use serde::Serialize;

View File

@ -1,4 +1,5 @@
use crate::erasure::ErasureConfig; use crate::erasure::ErasureConfig;
use serde::{Deserialize, Serialize};
use solana_metrics::datapoint; use solana_metrics::datapoint;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::{collections::BTreeSet, ops::Range, ops::RangeBounds}; use std::{collections::BTreeSet, ops::Range, ops::RangeBounds};

View File

@ -4,10 +4,12 @@
//! represents an approximate amount of time since the last Entry was created. //! represents an approximate amount of time since the last Entry was created.
use crate::perf_libs; use crate::perf_libs;
use crate::poh::Poh; use crate::poh::Poh;
use log::*;
use rayon::prelude::*; use rayon::prelude::*;
use rayon::ThreadPool; use rayon::ThreadPool;
use serde::{Deserialize, Serialize};
use solana_merkle_tree::MerkleTree; use solana_merkle_tree::MerkleTree;
use solana_metrics::inc_new_counter_warn; use solana_metrics::*;
use solana_rayon_threadlimit::get_thread_count; use solana_rayon_threadlimit::get_thread_count;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::timing; use solana_sdk::timing;
@ -317,7 +319,6 @@ pub fn create_ticks(num_ticks: u64, mut hash: Hash) -> Vec<Entry> {
ticks ticks
} }
#[cfg(test)]
/// Creates the next Tick or Transaction Entry `num_hashes` after `start_hash`. /// Creates the next Tick or Transaction Entry `num_hashes` after `start_hash`.
pub fn next_entry(prev_hash: &Hash, num_hashes: u64, transactions: Vec<Transaction>) -> Entry { pub fn next_entry(prev_hash: &Hash, num_hashes: u64, transactions: Vec<Transaction>) -> Entry {
assert!(num_hashes > 0 || transactions.is_empty()); assert!(num_hashes > 0 || transactions.is_empty());

View File

@ -43,6 +43,7 @@
use reed_solomon_erasure::galois_8::Field; use reed_solomon_erasure::galois_8::Field;
use reed_solomon_erasure::ReedSolomon; use reed_solomon_erasure::ReedSolomon;
use serde::{Deserialize, Serialize};
//TODO(sakridge) pick these values //TODO(sakridge) pick these values
/// Number of data blobs /// Number of data blobs
@ -130,6 +131,7 @@ impl Default for Session {
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use super::*; use super::*;
use log::*;
/// Specifies the contents of a 16-data-blob and 4-coding-blob erasure set /// Specifies the contents of a 16-data-blob and 4-coding-blob erasure set
/// Exists to be passed to `generate_blocktree_with_coding` /// Exists to be passed to `generate_blocktree_with_coding`

View File

@ -0,0 +1,14 @@
pub use solana_runtime::genesis_utils::{
create_genesis_block_with_leader, GenesisBlockInfo, BOOTSTRAP_LEADER_LAMPORTS,
};
use solana_sdk::pubkey::Pubkey;
// same as genesis_block::create_genesis_block, but with bootstrap_leader staking logic
// for the core crate tests
pub fn create_genesis_block(mint_lamports: u64) -> GenesisBlockInfo {
create_genesis_block_with_leader(
mint_lamports,
&Pubkey::new_rand(),
BOOTSTRAP_LEADER_LAMPORTS,
)
}

View File

@ -30,7 +30,7 @@ impl LeaderSchedule {
Self { slot_leaders } Self { slot_leaders }
} }
pub(crate) fn get_slot_leaders(&self) -> &[Pubkey] { pub fn get_slot_leaders(&self) -> &[Pubkey] {
&self.slot_leaders &self.slot_leaders
} }
} }

View File

@ -1,4 +1,5 @@
use crate::{blocktree::Blocktree, leader_schedule::LeaderSchedule, leader_schedule_utils}; use crate::{blocktree::Blocktree, leader_schedule::LeaderSchedule, leader_schedule_utils};
use log::*;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey}; use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey};
use std::{ use std::{
@ -230,7 +231,7 @@ impl LeaderScheduleCache {
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{
blocktree::{get_tmp_ledger_path, tests::make_slot_entries}, blocktree::{get_tmp_ledger_path, make_slot_entries},
genesis_utils::{ genesis_utils::{
create_genesis_block, create_genesis_block_with_leader, GenesisBlockInfo, create_genesis_block, create_genesis_block_with_leader, GenesisBlockInfo,
BOOTSTRAP_LEADER_LAMPORTS, BOOTSTRAP_LEADER_LAMPORTS,

View File

@ -52,7 +52,6 @@ fn sort_stakes(stakes: &mut Vec<(Pubkey, u64)>) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::staking_utils;
use solana_runtime::genesis_utils::{ use solana_runtime::genesis_utils::{
create_genesis_block_with_leader, BOOTSTRAP_LEADER_LAMPORTS, create_genesis_block_with_leader, BOOTSTRAP_LEADER_LAMPORTS,
}; };

12
ledger/src/lib.rs Normal file
View File

@ -0,0 +1,12 @@
#[macro_use]
pub mod blocktree;
pub mod entry;
pub mod erasure;
pub mod genesis_utils;
pub mod leader_schedule;
pub mod leader_schedule_cache;
pub mod leader_schedule_utils;
pub mod perf_libs;
pub mod poh;
pub mod shred;
pub mod staking_utils;

View File

@ -1,5 +1,7 @@
use core::ffi::c_void; use core::ffi::c_void;
use dlopen::symbor::{Container, SymBorApi, Symbol}; use dlopen::symbor::{Container, SymBorApi, Symbol};
use dlopen_derive::SymBorApi;
use log::*;
use solana_sdk::packet::Packet; use solana_sdk::packet::Packet;
use std::env; use std::env;
use std::ffi::OsStr; use std::ffi::OsStr;

View File

@ -1,4 +1,5 @@
//! The `Poh` module provides an object for generating a Proof of History. //! The `Poh` module provides an object for generating a Proof of History.
use log::*;
use solana_sdk::hash::{hash, hashv, Hash}; use solana_sdk::hash::{hash, hashv, Hash};
use std::thread::{Builder, JoinHandle}; use std::thread::{Builder, JoinHandle};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -116,6 +117,7 @@ pub fn compute_hashes_per_tick(duration: Duration, hashes_sample_size: u64) -> u
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::poh::{Poh, PohEntry}; use crate::poh::{Poh, PohEntry};
use matches::assert_matches;
use solana_sdk::hash::{hash, hashv, Hash}; use solana_sdk::hash::{hash, hashv, Hash};
fn verify(initial_hash: Hash, entries: &[(PohEntry, Option<Hash>)]) -> bool { fn verify(initial_hash: Hash, entries: &[(PohEntry, Option<Hash>)]) -> bool {

View File

@ -1,6 +1,5 @@
//! The `shred` module defines data structures and methods to pull MTU sized data frames from the network. //! The `shred` module defines data structures and methods to pull MTU sized data frames from the network.
use crate::entry::create_ticks; use crate::entry::{create_ticks, Entry};
use crate::entry::Entry;
use crate::erasure::Session; use crate::erasure::Session;
use bincode::serialized_size; use bincode::serialized_size;
use core::cell::RefCell; use core::cell::RefCell;
@ -9,6 +8,7 @@ use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelI
use rayon::slice::ParallelSlice; use rayon::slice::ParallelSlice;
use rayon::ThreadPool; use rayon::ThreadPool;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use solana_metrics::datapoint_debug;
use solana_rayon_threadlimit::get_thread_count; use solana_rayon_threadlimit::get_thread_count;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::packet::PACKET_DATA_SIZE; use solana_sdk::packet::PACKET_DATA_SIZE;
@ -695,6 +695,7 @@ pub fn max_entries_per_n_shred(entry: &Entry, num_shreds: u64) -> u64 {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use matches::assert_matches;
use solana_sdk::system_transaction; use solana_sdk::system_transaction;
use std::collections::HashSet; use std::collections::HashSet;
use std::convert::TryInto; use std::convert::TryInto;

View File

@ -18,6 +18,7 @@ solana-client = { path = "../client", version = "0.20.0" }
solana-drone = { path = "../drone", version = "0.20.0" } solana-drone = { path = "../drone", version = "0.20.0" }
solana-exchange-api = { path = "../programs/exchange_api", version = "0.20.0" } solana-exchange-api = { path = "../programs/exchange_api", version = "0.20.0" }
solana-exchange-program = { path = "../programs/exchange_program", version = "0.20.0" } solana-exchange-program = { path = "../programs/exchange_program", version = "0.20.0" }
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-logger = { path = "../logger", version = "0.20.0" } solana-logger = { path = "../logger", version = "0.20.0" }
solana-move-loader-api = { path = "../programs/move_loader_api", version = "0.20.0", optional = true } solana-move-loader-api = { path = "../programs/move_loader_api", version = "0.20.0", optional = true }
solana-move-loader-program = { path = "../programs/move_loader_program", version = "0.20.0", optional = true } solana-move-loader-program = { path = "../programs/move_loader_program", version = "0.20.0", optional = true }

View File

@ -5,13 +5,13 @@ use solana_client::thin_client::create_client;
/// All tests must start from an entry point and a funding keypair and /// All tests must start from an entry point and a funding keypair and
/// discover the rest of the network. /// discover the rest of the network.
use solana_core::{ use solana_core::{
blocktree::Blocktree, cluster_info::VALIDATOR_PORT_RANGE, consensus::VOTE_THRESHOLD_DEPTH, contact_info::ContactInfo,
cluster_info::VALIDATOR_PORT_RANGE,
consensus::VOTE_THRESHOLD_DEPTH,
contact_info::ContactInfo,
entry::{Entry, EntrySlice},
gossip_service::discover_cluster, gossip_service::discover_cluster,
}; };
use solana_ledger::{
blocktree::Blocktree,
entry::{Entry, EntrySlice},
};
use solana_sdk::{ use solana_sdk::{
client::SyncClient, client::SyncClient,
clock::{DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT, NUM_CONSECUTIVE_LEADER_SLOTS}, clock::{DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT, NUM_CONSECUTIVE_LEADER_SLOTS},

View File

@ -19,7 +19,7 @@ extern crate solana_bench_tps;
#[macro_use] #[macro_use]
#[cfg(test)] #[cfg(test)]
extern crate solana_core; extern crate solana_ledger;
#[cfg(test)] #[cfg(test)]
extern crate solana_drone; extern crate solana_drone;

View File

@ -1,7 +1,6 @@
use crate::cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo}; use crate::cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo};
use solana_client::thin_client::{create_client, ThinClient}; use solana_client::thin_client::{create_client, ThinClient};
use solana_core::{ use solana_core::{
blocktree::create_new_tmp_ledger,
cluster_info::{Node, VALIDATOR_PORT_RANGE}, cluster_info::{Node, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo, contact_info::ContactInfo,
genesis_utils::{create_genesis_block_with_leader, GenesisBlockInfo}, genesis_utils::{create_genesis_block_with_leader, GenesisBlockInfo},
@ -10,6 +9,7 @@ use solana_core::{
service::Service, service::Service,
validator::{Validator, ValidatorConfig}, validator::{Validator, ValidatorConfig},
}; };
use solana_ledger::blocktree::create_new_tmp_ledger;
use solana_sdk::{ use solana_sdk::{
client::SyncClient, client::SyncClient,
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_SLOTS_PER_SEGMENT, DEFAULT_TICKS_PER_SLOT}, clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_SLOTS_PER_SEGMENT, DEFAULT_TICKS_PER_SLOT},

View File

@ -6,9 +6,10 @@ use crate::{
use log::*; use log::*;
use serial_test_derive::serial; use serial_test_derive::serial;
use solana_core::{ use solana_core::{
bank_forks::SnapshotConfig, blocktree::Blocktree, broadcast_stage::BroadcastStageType, bank_forks::SnapshotConfig, broadcast_stage::BroadcastStageType,
gossip_service::discover_cluster, snapshot_utils, validator::ValidatorConfig, gossip_service::discover_cluster, snapshot_utils, validator::ValidatorConfig,
}; };
use solana_ledger::blocktree::Blocktree;
use solana_runtime::accounts_db::AccountsDB; use solana_runtime::accounts_db::AccountsDB;
use solana_sdk::{ use solana_sdk::{
client::SyncClient, client::SyncClient,

View File

@ -1,13 +1,13 @@
use crate::local_cluster::{ClusterConfig, LocalCluster}; use crate::local_cluster::{ClusterConfig, LocalCluster};
use serial_test_derive::serial; use serial_test_derive::serial;
use solana_client::thin_client::create_client; use solana_client::thin_client::create_client;
use solana_core::blocktree::{create_new_tmp_ledger, get_tmp_ledger_path, Blocktree};
use solana_core::cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE}; use solana_core::cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE};
use solana_core::contact_info::ContactInfo; use solana_core::contact_info::ContactInfo;
use solana_core::gossip_service::discover_cluster; use solana_core::gossip_service::discover_cluster;
use solana_core::replicator::Replicator; use solana_core::replicator::Replicator;
use solana_core::storage_stage::SLOTS_PER_TURN_TEST; use solana_core::storage_stage::SLOTS_PER_TURN_TEST;
use solana_core::validator::ValidatorConfig; use solana_core::validator::ValidatorConfig;
use solana_ledger::blocktree::{create_new_tmp_ledger, get_tmp_ledger_path, Blocktree};
use solana_sdk::genesis_block::create_genesis_block; use solana_sdk::genesis_block::create_genesis_block;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::fs::remove_dir_all; use std::fs::remove_dir_all;

View File

@ -19,6 +19,7 @@ serde_json = "1.0.41"
solana-client = { path = "../client", version = "0.20.0" } solana-client = { path = "../client", version = "0.20.0" }
solana-core = { path = "../core", version = "0.20.0" } solana-core = { path = "../core", version = "0.20.0" }
solana-drone = { path = "../drone", version = "0.20.0" } solana-drone = { path = "../drone", version = "0.20.0" }
solana-ledger = { path = "../ledger", version = "0.20.0" }
solana-logger = { path = "../logger", version = "0.20.0" } solana-logger = { path = "../logger", version = "0.20.0" }
solana-metrics = { path = "../metrics", version = "0.20.0" } solana-metrics = { path = "../metrics", version = "0.20.0" }
solana-netutil = { path = "../netutil", version = "0.20.0" } solana-netutil = { path = "../netutil", version = "0.20.0" }

View File

@ -414,7 +414,7 @@ pub fn main() {
.get_matches(); .get_matches();
if matches.is_present("cuda") { if matches.is_present("cuda") {
solana_core::perf_libs::init_cuda(); solana_ledger::perf_libs::init_cuda();
} }
let mut validator_config = ValidatorConfig::default(); let mut validator_config = ValidatorConfig::default();