Create solana-poh and move remaining rpc modules to solana-rpc (backport #17698) (#17745)

* Create solana-poh and move remaining rpc modules to solana-rpc (#17698)

* Create solana-poh crate

* Move BigTableUploadService to solana-ledger

* Add solana-rpc to workspace

* Move dependencies to solana-rpc

* Move remaining rpc modules to solana-rpc

* Single use statement solana-poh

* Single use statement solana-rpc

(cherry picked from commit 544b3c0d17)

# Conflicts:
#	Cargo.lock
#	banking-bench/Cargo.toml
#	core/Cargo.toml
#	core/benches/banking_stage.rs
#	local-cluster/Cargo.toml
#	rpc/Cargo.toml
#	stake-monitor/Cargo.toml
#	validator/Cargo.toml

* Fix conflicts & versions

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-06-04 18:19:08 +00:00
committed by GitHub
parent 67c07aa5d3
commit e247625025
41 changed files with 664 additions and 518 deletions

53
Cargo.lock generated
View File

@ -3939,6 +3939,7 @@ dependencies = [
"solana-logger 1.7.1", "solana-logger 1.7.1",
"solana-measure", "solana-measure",
"solana-perf", "solana-perf",
"solana-poh",
"solana-runtime", "solana-runtime",
"solana-sdk", "solana-sdk",
"solana-streamer", "solana-streamer",
@ -4277,7 +4278,6 @@ dependencies = [
"bv", "bv",
"byteorder", "byteorder",
"chrono", "chrono",
"core_affinity",
"crossbeam-channel 0.4.4", "crossbeam-channel 0.4.4",
"ed25519-dalek", "ed25519-dalek",
"flate2", "flate2",
@ -4286,8 +4286,6 @@ dependencies = [
"itertools", "itertools",
"jsonrpc-core", "jsonrpc-core",
"jsonrpc-core-client", "jsonrpc-core-client",
"jsonrpc-derive",
"jsonrpc-http-server",
"libc", "libc",
"log 0.4.11", "log 0.4.11",
"lru", "lru",
@ -4301,7 +4299,6 @@ dependencies = [
"rand_core 0.6.2", "rand_core 0.6.2",
"raptorq", "raptorq",
"rayon", "rayon",
"regex",
"reqwest", "reqwest",
"retain_mut", "retain_mut",
"rustc_version", "rustc_version",
@ -4314,7 +4311,6 @@ dependencies = [
"solana-banks-server", "solana-banks-server",
"solana-clap-utils", "solana-clap-utils",
"solana-client", "solana-client",
"solana-faucet",
"solana-frozen-abi 1.7.1", "solana-frozen-abi 1.7.1",
"solana-frozen-abi-macro 1.7.1", "solana-frozen-abi-macro 1.7.1",
"solana-gossip", "solana-gossip",
@ -4325,15 +4321,14 @@ dependencies = [
"solana-metrics", "solana-metrics",
"solana-net-utils", "solana-net-utils",
"solana-perf", "solana-perf",
"solana-poh",
"solana-program-test", "solana-program-test",
"solana-rayon-threadlimit", "solana-rayon-threadlimit",
"solana-rpc", "solana-rpc",
"solana-runtime", "solana-runtime",
"solana-sdk", "solana-sdk",
"solana-stake-program", "solana-stake-program",
"solana-storage-bigtable",
"solana-streamer", "solana-streamer",
"solana-sys-tuner",
"solana-transaction-status", "solana-transaction-status",
"solana-version", "solana-version",
"solana-vote-program", "solana-vote-program",
@ -4343,8 +4338,6 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"tokio 0.2.22", "tokio 0.2.22",
"tokio 1.1.1",
"tokio-util 0.3.1",
"trees", "trees",
] ]
@ -4752,6 +4745,7 @@ dependencies = [
"solana-ledger", "solana-ledger",
"solana-logger 1.7.1", "solana-logger 1.7.1",
"solana-rayon-threadlimit", "solana-rayon-threadlimit",
"solana-rpc",
"solana-runtime", "solana-runtime",
"solana-sdk", "solana-sdk",
"solana-stake-program", "solana-stake-program",
@ -4920,6 +4914,27 @@ dependencies = [
"solana-sdk", "solana-sdk",
] ]
[[package]]
name = "solana-poh"
version = "1.7.1"
dependencies = [
"bincode",
"core_affinity",
"crossbeam-channel 0.4.4",
"log 0.4.11",
"matches",
"rand 0.7.3",
"solana-ledger",
"solana-logger 1.7.1",
"solana-measure",
"solana-metrics",
"solana-perf",
"solana-runtime",
"solana-sdk",
"solana-sys-tuner",
"thiserror",
]
[[package]] [[package]]
name = "solana-poh-bench" name = "solana-poh-bench"
version = "1.7.1" version = "1.7.1"
@ -5061,29 +5076,47 @@ dependencies = [
name = "solana-rpc" name = "solana-rpc"
version = "1.7.1" version = "1.7.1"
dependencies = [ dependencies = [
"base64 0.12.3",
"bincode",
"bs58", "bs58",
"crossbeam-channel 0.4.4", "crossbeam-channel 0.4.4",
"itertools",
"jsonrpc-core", "jsonrpc-core",
"jsonrpc-core-client", "jsonrpc-core-client",
"jsonrpc-derive", "jsonrpc-derive",
"jsonrpc-http-server",
"jsonrpc-pubsub", "jsonrpc-pubsub",
"jsonrpc-ws-server", "jsonrpc-ws-server",
"libc",
"log 0.4.11", "log 0.4.11",
"regex",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"serial_test", "serial_test",
"solana-account-decoder", "solana-account-decoder",
"solana-client", "solana-client",
"solana-faucet",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.1",
"solana-measure", "solana-measure",
"solana-metrics", "solana-metrics",
"solana-net-utils",
"solana-perf",
"solana-poh",
"solana-runtime", "solana-runtime",
"solana-sdk", "solana-sdk",
"solana-stake-program", "solana-stake-program",
"solana-storage-bigtable",
"solana-transaction-status",
"solana-version",
"solana-vote-program", "solana-vote-program",
"spl-token", "spl-token",
"symlink",
"tokio 0.2.22",
"tokio 1.1.1", "tokio 1.1.1",
"tokio-util 0.3.1",
] ]
[[package]] [[package]]
@ -5262,6 +5295,7 @@ dependencies = [
"solana-local-cluster", "solana-local-cluster",
"solana-logger 1.7.1", "solana-logger 1.7.1",
"solana-metrics", "solana-metrics",
"solana-rpc",
"solana-sdk", "solana-sdk",
"solana-stake-program", "solana-stake-program",
"solana-transaction-status", "solana-transaction-status",
@ -5476,6 +5510,7 @@ dependencies = [
"solana-metrics", "solana-metrics",
"solana-net-utils", "solana-net-utils",
"solana-perf", "solana-perf",
"solana-poh",
"solana-rpc", "solana-rpc",
"solana-runtime", "solana-runtime",
"solana-sdk", "solana-sdk",

View File

@ -39,6 +39,7 @@ members = [
"metrics", "metrics",
"net-shaper", "net-shaper",
"notifier", "notifier",
"poh",
"poh-bench", "poh-bench",
"program-test", "program-test",
"programs/secp256k1", "programs/secp256k1",
@ -52,6 +53,7 @@ members = [
"programs/stake", "programs/stake",
"programs/vote", "programs/vote",
"remote-wallet", "remote-wallet",
"rpc",
"runtime", "runtime",
"runtime/store-tool", "runtime/store-tool",
"sdk", "sdk",

View File

@ -21,6 +21,7 @@ solana-ledger = { path = "../ledger", version = "=1.7.1" }
solana-logger = { path = "../logger", version = "=1.7.1" } solana-logger = { path = "../logger", version = "=1.7.1" }
solana-measure = { path = "../measure", version = "=1.7.1" } solana-measure = { path = "../measure", version = "=1.7.1" }
solana-perf = { path = "../perf", version = "=1.7.1" } solana-perf = { path = "../perf", version = "=1.7.1" }
solana-poh = { path = "../poh", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" } solana-runtime = { path = "../runtime", version = "=1.7.1" }
solana-streamer = { path = "../streamer", version = "=1.7.1" } solana-streamer = { path = "../streamer", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" } solana-sdk = { path = "../sdk", version = "=1.7.1" }

View File

@ -4,11 +4,7 @@ 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::{ use solana_core::banking_stage::BankingStage;
banking_stage::{create_test_recorder, BankingStage},
poh_recorder::PohRecorder,
poh_recorder::WorkingBankEntry,
};
use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node}; use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore::Blockstore,
@ -17,6 +13,7 @@ use solana_ledger::{
}; };
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_perf::packet::to_packets_chunked; use solana_perf::packet::to_packets_chunked;
use solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry};
use solana_runtime::{ use solana_runtime::{
accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks, accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks,
}; };

View File

@ -49,6 +49,10 @@ _ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
_ "$cargo" nightly bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \ _ "$cargo" nightly bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE" -- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run poh benches
_ "$cargo" nightly bench --manifest-path poh/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run core benches # Run core benches
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \ _ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE" -- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

View File

@ -22,17 +22,12 @@ bv = { version = "0.11.1", features = ["serde"] }
bs58 = "0.3.1" bs58 = "0.3.1"
byteorder = "1.3.4" byteorder = "1.3.4"
chrono = { version = "0.4.11", features = ["serde"] } chrono = { version = "0.4.11", features = ["serde"] }
core_affinity = "0.5.10"
crossbeam-channel = "0.4" crossbeam-channel = "0.4"
ed25519-dalek = "=1.0.1" ed25519-dalek = "=1.0.1"
fs_extra = "1.2.0" fs_extra = "1.2.0"
flate2 = "1.0" flate2 = "1.0"
indexmap = { version = "1.5", features = ["rayon"] } indexmap = { version = "1.5", features = ["rayon"] }
itertools = "0.9.0" itertools = "0.9.0"
jsonrpc-core = "17.0.0"
jsonrpc-core-client = { version = "17.0.0", features = ["ipc", "ws"] }
jsonrpc-derive = "17.0.0"
jsonrpc-http-server = "17.0.0"
libc = "0.2.81" libc = "0.2.81"
log = "0.4.11" log = "0.4.11"
lru = "0.6.1" lru = "0.6.1"
@ -44,17 +39,14 @@ rand_chacha = "0.2.2"
rand_core = "0.6.2" rand_core = "0.6.2"
raptorq = "1.4.2" raptorq = "1.4.2"
rayon = "1.5.0" rayon = "1.5.0"
regex = "1.3.9"
retain_mut = "0.1.2" retain_mut = "0.1.2"
serde = "1.0.122" serde = "1.0.122"
serde_bytes = "0.11" serde_bytes = "0.11"
serde_derive = "1.0.103" serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "=1.7.1" } solana-account-decoder = { path = "../account-decoder", version = "=1.7.1" }
solana-banks-server = { path = "../banks-server", version = "=1.7.1" } solana-banks-server = { path = "../banks-server", version = "=1.7.1" }
solana-clap-utils = { path = "../clap-utils", version = "=1.7.1" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.1" }
solana-client = { path = "../client", version = "=1.7.1" } solana-client = { path = "../client", version = "=1.7.1" }
solana-faucet = { path = "../faucet", version = "=1.7.1" }
solana-gossip = { path = "../gossip", version = "=1.7.1" } solana-gossip = { path = "../gossip", version = "=1.7.1" }
solana-ledger = { path = "../ledger", version = "=1.7.1" } solana-ledger = { path = "../ledger", version = "=1.7.1" }
solana-logger = { path = "../logger", version = "=1.7.1" } solana-logger = { path = "../logger", version = "=1.7.1" }
@ -63,6 +55,7 @@ solana-metrics = { path = "../metrics", version = "=1.7.1" }
solana-measure = { path = "../measure", version = "=1.7.1" } solana-measure = { path = "../measure", version = "=1.7.1" }
solana-net-utils = { path = "../net-utils", version = "=1.7.1" } solana-net-utils = { path = "../net-utils", version = "=1.7.1" }
solana-perf = { path = "../perf", version = "=1.7.1" } solana-perf = { path = "../perf", version = "=1.7.1" }
solana-poh = { path = "../poh", version = "=1.7.1" }
solana-program-test = { path = "../program-test", version = "=1.7.1" } solana-program-test = { path = "../program-test", version = "=1.7.1" }
solana-rpc = { path = "../rpc", version = "=1.7.1" } solana-rpc = { path = "../rpc", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" } solana-runtime = { path = "../runtime", version = "=1.7.1" }
@ -70,28 +63,28 @@ solana-sdk = { path = "../sdk", version = "=1.7.1" }
solana-frozen-abi = { path = "../frozen-abi", version = "=1.7.1" } solana-frozen-abi = { path = "../frozen-abi", version = "=1.7.1" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "=1.7.1" } solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "=1.7.1" }
solana-stake-program = { path = "../programs/stake", version = "=1.7.1" } solana-stake-program = { path = "../programs/stake", version = "=1.7.1" }
solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.7.1" }
solana-streamer = { path = "../streamer", version = "=1.7.1" } solana-streamer = { path = "../streamer", version = "=1.7.1" }
solana-sys-tuner = { path = "../sys-tuner", version = "=1.7.1" }
solana-transaction-status = { path = "../transaction-status", version = "=1.7.1" } solana-transaction-status = { path = "../transaction-status", version = "=1.7.1" }
solana-version = { path = "../version", version = "=1.7.1" } solana-version = { path = "../version", version = "=1.7.1" }
solana-vote-program = { path = "../programs/vote", version = "=1.7.1" } solana-vote-program = { path = "../programs/vote", version = "=1.7.1" }
spl-token-v2-0 = { package = "spl-token", version = "=3.1.0", features = ["no-entrypoint"] } spl-token-v2-0 = { package = "spl-token", version = "=3.1.0", features = ["no-entrypoint"] }
tempfile = "3.1.0" tempfile = "3.1.0"
thiserror = "1.0" thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
tokio_02 = { version = "0.2", package = "tokio", features = ["full"] }
tokio-util = { version = "0.3", features = ["codec"] } # This crate needs to stay in sync with tokio_02, until that dependency can be removed
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.7.1" } solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.7.1" }
trees = "0.2.1" trees = "0.2.1"
[dev-dependencies] [dev-dependencies]
jsonrpc-core = "17.0.0"
jsonrpc-core-client = { version = "17.0.0", features = ["ipc", "ws"] }
matches = "0.1.6" matches = "0.1.6"
num_cpus = "1.13.0" num_cpus = "1.13.0"
reqwest = { version = "0.11.2", default-features = false, features = ["blocking", "rustls-tls", "json"] } reqwest = { version = "0.11.2", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serde_json = "1.0.56"
serial_test = "0.4.0" serial_test = "0.4.0"
solana-version = { path = "../version", version = "=1.7.1" }
symlink = "0.1.0" symlink = "0.1.0"
systemstat = "0.1.5" systemstat = "0.1.5"
tokio_02 = { version = "0.2", package = "tokio", features = ["full"] }
[build-dependencies] [build-dependencies]
rustc_version = "0.2" rustc_version = "0.2"
@ -111,9 +104,6 @@ name = "gen_keys"
[[bench]] [[bench]]
name = "sigverify_stage" name = "sigverify_stage"
[[bench]]
name = "poh"
[[bench]] [[bench]]
name = "retransmit_stage" name = "retransmit_stage"

View File

@ -7,8 +7,7 @@ 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, BankingStageStats}; use solana_core::banking_stage::{BankingStage, BankingStageStats};
use solana_core::poh_recorder::WorkingBankEntry;
use solana_gossip::cluster_info::ClusterInfo; use solana_gossip::cluster_info::ClusterInfo;
use solana_gossip::cluster_info::Node; use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore_processor::process_entries; use solana_ledger::blockstore_processor::process_entries;
@ -17,6 +16,7 @@ use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_perf::packet::to_packets_chunked; use solana_perf::packet::to_packets_chunked;
use solana_perf::test_tx::test_tx; use solana_perf::test_tx::test_tx;
use solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry};
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::genesis_config::GenesisConfig; use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;

View File

@ -1,20 +1,13 @@
//! The `banking_stage` processes Transaction messages. It is intended to be used //! The `banking_stage` processes Transaction messages. It is intended to be used
//! 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::packet_hasher::PacketHasher;
packet_hasher::PacketHasher,
poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder, WorkingBankEntry},
poh_service::{self, PohService},
};
use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError}; use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools; use itertools::Itertools;
use lru::LruCache; use lru::LruCache;
use retain_mut::RetainMut; use retain_mut::RetainMut;
use solana_gossip::cluster_info::ClusterInfo; use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions};
blockstore::Blockstore, blockstore_processor::TransactionStatusSender,
entry::hash_transactions, leader_schedule_cache::LeaderScheduleCache,
};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info}; use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
use solana_perf::{ use solana_perf::{
@ -22,6 +15,7 @@ use solana_perf::{
packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH}, packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH},
perf_libs, perf_libs,
}; };
use solana_poh::poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder};
use solana_runtime::{ use solana_runtime::{
accounts_db::ErrorCounters, accounts_db::ErrorCounters,
bank::{ bank::{
@ -39,7 +33,6 @@ use solana_sdk::{
MAX_TRANSACTION_FORWARDING_DELAY_GPU, MAX_TRANSACTION_FORWARDING_DELAY_GPU,
}, },
message::Message, message::Message,
poh_config::PohConfig,
pubkey::Pubkey, pubkey::Pubkey,
short_vec::decode_shortu16_len, short_vec::decode_shortu16_len,
signature::Signature, signature::Signature,
@ -57,8 +50,7 @@ use std::{
mem::size_of, mem::size_of,
net::UdpSocket, net::UdpSocket,
ops::DerefMut, ops::DerefMut,
sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, sync::atomic::{AtomicU64, AtomicUsize, Ordering},
sync::mpsc::Receiver,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
thread::{self, Builder, JoinHandle}, thread::{self, Builder, JoinHandle},
time::Duration, time::Duration,
@ -1392,66 +1384,29 @@ fn next_leader_tpu_forwards(
} }
} }
pub fn create_test_recorder(
bank: &Arc<Bank>,
blockstore: &Arc<Blockstore>,
poh_config: Option<PohConfig>,
) -> (
Arc<AtomicBool>,
Arc<Mutex<PohRecorder>>,
PohService,
Receiver<WorkingBankEntry>,
) {
let exit = Arc::new(AtomicBool::new(false));
let poh_config = Arc::new(poh_config.unwrap_or_default());
let (mut poh_recorder, entry_receiver, record_receiver) = PohRecorder::new(
bank.tick_height(),
bank.last_blockhash(),
bank.slot(),
Some((4, 4)),
bank.ticks_per_slot(),
&Pubkey::default(),
blockstore,
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&poh_config,
exit.clone(),
);
poh_recorder.set_bank(&bank);
let poh_recorder = Arc::new(Mutex::new(poh_recorder));
let poh_service = PohService::new(
poh_recorder.clone(),
&poh_config,
&exit,
bank.ticks_per_slot(),
poh_service::DEFAULT_PINNED_CPU_CORE,
poh_service::DEFAULT_HASHES_PER_BATCH,
record_receiver,
);
(exit, poh_recorder, poh_service, entry_receiver)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{
poh_recorder::Record, poh_recorder::WorkingBank,
transaction_status_service::TransactionStatusService,
};
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use itertools::Itertools; use itertools::Itertools;
use solana_gossip::cluster_info::Node; use solana_gossip::cluster_info::Node;
use solana_ledger::{ use solana_ledger::{
blockstore::entries_to_test_shreds, blockstore::{entries_to_test_shreds, Blockstore},
entry::{next_entry, Entry, EntrySlice}, entry::{next_entry, Entry, EntrySlice},
genesis_utils::{create_genesis_config, GenesisConfigInfo}, genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path, get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache,
}; };
use solana_perf::packet::to_packets_chunked; use solana_perf::packet::to_packets_chunked;
use solana_poh::{
poh_recorder::{create_test_recorder, Record, WorkingBank, WorkingBankEntry},
poh_service::PohService,
};
use solana_rpc::transaction_status_service::TransactionStatusService;
use solana_sdk::{ use solana_sdk::{
hash::Hash, hash::Hash,
instruction::InstructionError, instruction::InstructionError,
poh_config::PohConfig,
signature::{Keypair, Signer}, signature::{Keypair, Signer},
system_instruction::SystemError, system_instruction::SystemError,
system_transaction, system_transaction,
@ -1461,7 +1416,10 @@ mod tests {
use std::{ use std::{
net::SocketAddr, net::SocketAddr,
path::Path, path::Path,
sync::atomic::{AtomicBool, Ordering}, sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
},
thread::sleep, thread::sleep,
}; };

View File

@ -5,10 +5,7 @@ use self::{
fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun, fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun,
standard_broadcast_run::StandardBroadcastRun, standard_broadcast_run::StandardBroadcastRun,
}; };
use crate::{ use crate::result::{Error, Result};
poh_recorder::WorkingBankEntry,
result::{Error, Result},
};
use crossbeam_channel::{ use crossbeam_channel::{
Receiver as CrossbeamReceiver, RecvTimeoutError as CrossbeamRecvTimeoutError, Receiver as CrossbeamReceiver, RecvTimeoutError as CrossbeamRecvTimeoutError,
Sender as CrossbeamSender, Sender as CrossbeamSender,
@ -22,6 +19,7 @@ use solana_gossip::{
use solana_ledger::{blockstore::Blockstore, shred::Shred}; use solana_ledger::{blockstore::Blockstore, shred::Shred};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_error, inc_new_counter_info}; use solana_metrics::{inc_new_counter_error, inc_new_counter_info};
use solana_poh::poh_recorder::WorkingBankEntry;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::timing::timestamp; use solana_sdk::timing::timestamp;
use solana_sdk::{clock::Slot, pubkey::Pubkey}; use solana_sdk::{clock::Slot, pubkey::Pubkey};

View File

@ -1,6 +1,6 @@
use crate::poh_recorder::WorkingBankEntry;
use crate::result::Result; use crate::result::Result;
use solana_ledger::{entry::Entry, shred::Shred}; use solana_ledger::{entry::Entry, shred::Shred};
use solana_poh::poh_recorder::WorkingBankEntry;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::clock::Slot; use solana_sdk::clock::Slot;
use std::{ use std::{

View File

@ -1,6 +1,5 @@
use crate::{ use crate::{
optimistic_confirmation_verifier::OptimisticConfirmationVerifier, optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
poh_recorder::PohRecorder,
replay_stage::DUPLICATE_THRESHOLD, replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result}, result::{Error, Result},
sigverify, sigverify,
@ -20,6 +19,7 @@ use solana_gossip::{
use solana_ledger::blockstore::Blockstore; use solana_ledger::blockstore::Blockstore;
use solana_metrics::inc_new_counter_debug; use solana_metrics::inc_new_counter_debug;
use solana_perf::packet::{self, Packets}; use solana_perf::packet::{self, Packets};
use solana_poh::poh_recorder::PohRecorder;
use solana_rpc::{ use solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,

View File

@ -1,11 +1,11 @@
//! The `fetch_stage` batches input from a UDP socket and sends it to a channel. //! The `fetch_stage` batches input from a UDP socket and sends it to a channel.
use crate::banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET; use crate::banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET;
use crate::poh_recorder::PohRecorder;
use crate::result::{Error, Result}; use crate::result::{Error, Result};
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info}; use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
use solana_perf::packet::PacketsRecycler; use solana_perf::packet::PacketsRecycler;
use solana_perf::recycler::Recycler; use solana_perf::recycler::Recycler;
use solana_poh::poh_recorder::PohRecorder;
use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT; use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT;
use solana_streamer::streamer::{self, PacketReceiver, PacketSender}; use solana_streamer::streamer::{self, PacketReceiver, PacketSender};
use std::net::UdpSocket; use std::net::UdpSocket;

View File

@ -9,7 +9,6 @@
pub mod accounts_hash_verifier; pub mod accounts_hash_verifier;
pub mod banking_stage; pub mod banking_stage;
pub mod bigtable_upload_service;
pub mod broadcast_stage; pub mod broadcast_stage;
pub mod cache_block_meta_service; pub mod cache_block_meta_service;
pub mod cluster_info_vote_listener; pub mod cluster_info_vote_listener;
@ -28,8 +27,6 @@ pub mod ledger_cleanup_service;
pub mod optimistic_confirmation_verifier; pub mod optimistic_confirmation_verifier;
pub mod outstanding_requests; pub mod outstanding_requests;
pub mod packet_hasher; pub mod packet_hasher;
pub mod poh_recorder;
pub mod poh_service;
pub mod progress_map; pub mod progress_map;
pub mod repair_response; pub mod repair_response;
pub mod repair_service; pub mod repair_service;
@ -40,11 +37,7 @@ pub mod request_response;
mod result; mod result;
pub mod retransmit_stage; pub mod retransmit_stage;
pub mod rewards_recorder_service; pub mod rewards_recorder_service;
pub mod rpc;
pub mod rpc_health;
pub mod rpc_service;
pub mod sample_performance_service; pub mod sample_performance_service;
pub mod send_transaction_service;
pub mod serve_repair; pub mod serve_repair;
pub mod serve_repair_service; pub mod serve_repair_service;
pub mod shred_fetch_stage; pub mod shred_fetch_stage;
@ -54,7 +47,6 @@ pub mod sigverify_stage;
pub mod snapshot_packager_service; pub mod snapshot_packager_service;
pub mod test_validator; pub mod test_validator;
pub mod tpu; pub mod tpu;
pub mod transaction_status_service;
pub mod tree_diff; pub mod tree_diff;
pub mod tvu; pub mod tvu;
pub mod unfrozen_gossip_verified_vote_hashes; pub mod unfrozen_gossip_verified_vote_hashes;
@ -69,10 +61,6 @@ extern crate log;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[cfg(test)]
#[macro_use]
extern crate serde_json;
#[macro_use] #[macro_use]
extern crate solana_metrics; extern crate solana_metrics;

View File

@ -15,7 +15,6 @@ use crate::{
fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
progress_map::{DuplicateStats, ForkProgress, ProgressMap, PropagatedStats}, progress_map::{DuplicateStats, ForkProgress, ProgressMap, PropagatedStats},
repair_service::DuplicateSlotsResetReceiver, repair_service::DuplicateSlotsResetReceiver,
result::Result, result::Result,
@ -34,6 +33,7 @@ use solana_ledger::{
}; };
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::inc_new_counter_info; use solana_metrics::inc_new_counter_info;
use solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS};
use solana_rpc::{ use solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,
@ -2470,22 +2470,21 @@ impl ReplayStage {
} }
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{
consensus::test::{initialize_state, VoteSimulator}, consensus::test::{initialize_state, VoteSimulator},
consensus::Tower, consensus::Tower,
progress_map::ValidatorStakeInfo, progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage, replay_stage::ReplayStage,
transaction_status_service::TransactionStatusService,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::{cluster_info::Node, crds::Cursor}; use solana_gossip::{cluster_info::Node, crds::Cursor};
use solana_ledger::{ use solana_ledger::{
blockstore::make_slot_entries, blockstore::make_slot_entries,
blockstore::{entries_to_test_shreds, BlockstoreError}, blockstore::{entries_to_test_shreds, BlockstoreError},
blockstore_processor, create_new_tmp_ledger, create_new_tmp_ledger,
entry::{self, next_entry, Entry}, entry::{self, Entry},
genesis_utils::{create_genesis_config, create_genesis_config_with_leader}, genesis_utils::{create_genesis_config, create_genesis_config_with_leader},
get_tmp_ledger_path, get_tmp_ledger_path,
shred::{ shred::{
@ -2493,7 +2492,10 @@ pub(crate) mod tests {
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD, SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
}, },
}; };
use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank; use solana_rpc::{
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::create_test_transactions_and_populate_blockstore,
};
use solana_runtime::{ use solana_runtime::{
accounts_background_service::AbsRequestSender, accounts_background_service::AbsRequestSender,
commitment::BlockCommitment, commitment::BlockCommitment,
@ -2506,7 +2508,7 @@ pub(crate) mod tests {
instruction::InstructionError, instruction::InstructionError,
packet::PACKET_DATA_SIZE, packet::PACKET_DATA_SIZE,
poh_config::PohConfig, poh_config::PohConfig,
signature::{Keypair, Signature, Signer}, signature::{Keypair, Signer},
system_transaction, system_transaction,
transaction::TransactionError, transaction::TransactionError,
}; };
@ -3297,68 +3299,6 @@ pub(crate) mod tests {
); );
} }
pub fn create_test_transactions_and_populate_blockstore(
keypairs: Vec<&Keypair>,
previous_slot: Slot,
bank: Arc<Bank>,
blockstore: Arc<Blockstore>,
max_complete_transaction_status_slot: Arc<AtomicU64>,
) -> Vec<Signature> {
let mint_keypair = keypairs[0];
let keypair1 = keypairs[1];
let keypair2 = keypairs[2];
let keypair3 = keypairs[3];
let slot = bank.slot();
let blockhash = bank.confirmed_last_blockhash().0;
// Generate transactions for processing
// Successful transaction
let success_tx =
system_transaction::transfer(&mint_keypair, &keypair1.pubkey(), 2, blockhash);
let success_signature = success_tx.signatures[0];
let entry_1 = next_entry(&blockhash, 1, vec![success_tx]);
// Failed transaction, InstructionError
let ix_error_tx =
system_transaction::transfer(&keypair2, &keypair3.pubkey(), 10, blockhash);
let ix_error_signature = ix_error_tx.signatures[0];
let entry_2 = next_entry(&entry_1.hash, 1, vec![ix_error_tx]);
// Failed transaction
let fail_tx =
system_transaction::transfer(&mint_keypair, &keypair2.pubkey(), 2, Hash::default());
let entry_3 = next_entry(&entry_2.hash, 1, vec![fail_tx]);
let mut entries = vec![entry_1, entry_2, entry_3];
let shreds = entries_to_test_shreds(entries.clone(), slot, previous_slot, true, 0);
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(&[slot]).unwrap();
let (transaction_status_sender, transaction_status_receiver) = unbounded();
let (replay_vote_sender, _replay_vote_receiver) = unbounded();
let transaction_status_service = TransactionStatusService::new(
transaction_status_receiver,
max_complete_transaction_status_slot,
blockstore,
&Arc::new(AtomicBool::new(false)),
);
// Check that process_entries successfully writes can_commit transactions statuses, and
// that they are matched properly by get_rooted_block
let _result = blockstore_processor::process_entries(
&bank,
&mut entries,
true,
Some(&TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
}),
Some(&replay_vote_sender),
);
transaction_status_service.join().unwrap();
vec![success_signature, ix_error_signature]
}
#[test] #[test]
fn test_write_persist_transaction_status() { fn test_write_persist_transaction_status() {
let GenesisConfigInfo { let GenesisConfigInfo {

View File

@ -1,12 +1,10 @@
use { use {
crate::{ crate::validator::{Validator, ValidatorConfig, ValidatorStartProgress},
rpc::JsonRpcConfig,
validator::{Validator, ValidatorConfig, ValidatorStartProgress},
},
solana_client::rpc_client::RpcClient, solana_client::rpc_client::RpcClient,
solana_gossip::{cluster_info::Node, gossip_service::discover_cluster, socketaddr}, solana_gossip::{cluster_info::Node, gossip_service::discover_cluster, socketaddr},
solana_ledger::{blockstore::create_new_ledger, create_new_tmp_ledger}, solana_ledger::{blockstore::create_new_ledger, create_new_tmp_ledger},
solana_net_utils::PortRange, solana_net_utils::PortRange,
solana_rpc::rpc::JsonRpcConfig,
solana_runtime::{ solana_runtime::{
bank_forks::{ArchiveFormat, SnapshotConfig, SnapshotVersion}, bank_forks::{ArchiveFormat, SnapshotConfig, SnapshotVersion},
genesis_utils::create_genesis_config_with_leader_ex, genesis_utils::create_genesis_config_with_leader_ex,

View File

@ -9,13 +9,13 @@ use crate::{
VerifiedVoteSender, VoteTracker, VerifiedVoteSender, VoteTracker,
}, },
fetch_stage::FetchStage, fetch_stage::FetchStage,
poh_recorder::{PohRecorder, WorkingBankEntry},
sigverify::TransactionSigVerifier, sigverify::TransactionSigVerifier,
sigverify_stage::SigVerifyStage, sigverify_stage::SigVerifyStage,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::ClusterInfo; use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender}; use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender};
use solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry};
use solana_rpc::{ use solana_rpc::{
optimistically_confirmed_bank_tracker::BankNotificationSender, optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,

View File

@ -13,7 +13,6 @@ use crate::{
completed_data_sets_service::CompletedDataSetsSender, completed_data_sets_service::CompletedDataSetsSender,
consensus::Tower, consensus::Tower,
ledger_cleanup_service::LedgerCleanupService, ledger_cleanup_service::LedgerCleanupService,
poh_recorder::PohRecorder,
replay_stage::{ReplayStage, ReplayStageConfig}, replay_stage::{ReplayStage, ReplayStageConfig},
retransmit_stage::RetransmitStage, retransmit_stage::RetransmitStage,
rewards_recorder_service::RewardsRecorderSender, rewards_recorder_service::RewardsRecorderSender,
@ -29,6 +28,7 @@ use solana_ledger::{
blockstore_processor::TransactionStatusSender, blockstore_processor::TransactionStatusSender,
leader_schedule_cache::LeaderScheduleCache, leader_schedule_cache::LeaderScheduleCache,
}; };
use solana_poh::poh_recorder::PohRecorder;
use solana_rpc::{ use solana_rpc::{
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender, max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,
@ -338,7 +338,6 @@ impl Tvu {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use crate::banking_stage::create_test_recorder;
use serial_test::serial; use serial_test::serial;
use solana_gossip::cluster_info::{ClusterInfo, Node}; use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{ use solana_ledger::{
@ -346,6 +345,7 @@ pub mod tests {
create_new_tmp_ledger, create_new_tmp_ledger,
genesis_utils::{create_genesis_config, GenesisConfigInfo}, genesis_utils::{create_genesis_config, GenesisConfigInfo},
}; };
use solana_poh::poh_recorder::create_test_recorder;
use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank; use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank;
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;

View File

@ -6,18 +6,13 @@ use crate::{
cluster_info_vote_listener::VoteTracker, cluster_info_vote_listener::VoteTracker,
completed_data_sets_service::CompletedDataSetsService, completed_data_sets_service::CompletedDataSetsService,
consensus::{reconcile_blockstore_roots_with_tower, Tower}, consensus::{reconcile_blockstore_roots_with_tower, Tower},
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{self, PohService},
rewards_recorder_service::{RewardsRecorderSender, RewardsRecorderService}, rewards_recorder_service::{RewardsRecorderSender, RewardsRecorderService},
rpc::JsonRpcConfig,
rpc_service::JsonRpcService,
sample_performance_service::SamplePerformanceService, sample_performance_service::SamplePerformanceService,
serve_repair::ServeRepair, serve_repair::ServeRepair,
serve_repair_service::ServeRepairService, serve_repair_service::ServeRepairService,
sigverify, sigverify,
snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService}, snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService},
tpu::{Tpu, DEFAULT_TPU_COALESCE_MS}, tpu::{Tpu, DEFAULT_TPU_COALESCE_MS},
transaction_status_service::TransactionStatusService,
tvu::{Sockets, Tvu, TvuConfig}, tvu::{Sockets, Tvu, TvuConfig},
}; };
use crossbeam_channel::{bounded, unbounded}; use crossbeam_channel::{bounded, unbounded};
@ -41,13 +36,20 @@ use solana_ledger::{
}; };
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::datapoint_info; use solana_metrics::datapoint_info;
use solana_poh::{
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{self, PohService},
};
use solana_rpc::{ use solana_rpc::{
max_slots::MaxSlots, max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::{ optimistically_confirmed_bank_tracker::{
OptimisticallyConfirmedBank, OptimisticallyConfirmedBankTracker, OptimisticallyConfirmedBank, OptimisticallyConfirmedBankTracker,
}, },
rpc::JsonRpcConfig,
rpc_pubsub_service::{PubSubConfig, PubSubService}, rpc_pubsub_service::{PubSubConfig, PubSubService},
rpc_service::JsonRpcService,
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,
transaction_status_service::TransactionStatusService,
}; };
use solana_runtime::{ use solana_runtime::{
accounts_index::AccountSecondaryIndexes, accounts_index::AccountSecondaryIndexes,
@ -68,7 +70,6 @@ use solana_sdk::{
timing::timestamp, timing::timestamp,
}; };
use solana_vote_program::vote_state::VoteState; use solana_vote_program::vote_state::VoteState;
use std::time::Instant;
use std::{ use std::{
collections::HashSet, collections::HashSet,
net::SocketAddr, net::SocketAddr,
@ -78,7 +79,7 @@ use std::{
sync::mpsc::Receiver, sync::mpsc::Receiver,
sync::{Arc, Mutex, RwLock}, sync::{Arc, Mutex, RwLock},
thread::{sleep, Builder}, thread::{sleep, Builder},
time::Duration, time::{Duration, Instant},
}; };
const MAX_COMPLETED_DATA_SETS_IN_CHANNEL: usize = 100_000; const MAX_COMPLETED_DATA_SETS_IN_CHANNEL: usize = 100_000;

View File

@ -1,11 +1,13 @@
use solana_ledger::blockstore::Blockstore; use {
use solana_runtime::commitment::BlockCommitmentCache; crate::{bigtable_upload, blockstore::Blockstore},
use std::{ solana_runtime::commitment::BlockCommitmentCache,
std::{
sync::atomic::{AtomicBool, Ordering}, sync::atomic::{AtomicBool, Ordering},
sync::{Arc, RwLock}, sync::{Arc, RwLock},
thread::{self, Builder, JoinHandle}, thread::{self, Builder, JoinHandle},
},
tokio::runtime::Runtime,
}; };
use tokio::runtime::Runtime;
// Delay uploading the largest confirmed root for this many slots. This is done in an attempt to // Delay uploading the largest confirmed root for this many slots. This is done in an attempt to
// ensure that the `CacheBlockMetaService` has had enough time to add the block time for the root // ensure that the `CacheBlockMetaService` has had enough time to add the block time for the root
@ -68,7 +70,7 @@ impl BigTableUploadService {
continue; continue;
} }
let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks( let result = runtime.block_on(bigtable_upload::upload_confirmed_blocks(
blockstore.clone(), blockstore.clone(),
bigtable_ledger_storage.clone(), bigtable_ledger_storage.clone(),
start_slot, start_slot,

View File

@ -5,6 +5,7 @@ extern crate solana_bpf_loader_program;
pub mod bank_forks_utils; pub mod bank_forks_utils;
pub mod bigtable_upload; pub mod bigtable_upload;
pub mod bigtable_upload_service;
pub mod block_error; pub mod block_error;
#[macro_use] #[macro_use]
pub mod blockstore; pub mod blockstore;

View File

@ -26,12 +26,13 @@ solana-faucet = { path = "../faucet", version = "=1.7.1" }
solana-gossip = { path = "../gossip", version = "=1.7.1" } solana-gossip = { path = "../gossip", version = "=1.7.1" }
solana-ledger = { path = "../ledger", version = "=1.7.1" } solana-ledger = { path = "../ledger", version = "=1.7.1" }
solana-logger = { path = "../logger", version = "=1.7.1" } solana-logger = { path = "../logger", version = "=1.7.1" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.7.1" }
solana-rpc = { path = "../rpc", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" } solana-runtime = { path = "../runtime", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" } solana-sdk = { path = "../sdk", version = "=1.7.1" }
solana-stake-program = { path = "../programs/stake", version = "=1.7.1" } solana-stake-program = { path = "../programs/stake", version = "=1.7.1" }
solana-vote-program = { path = "../programs/vote", version = "=1.7.1" } solana-vote-program = { path = "../programs/vote", version = "=1.7.1" }
tempfile = "3.1.0" tempfile = "3.1.0"
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.7.1" }
[dev-dependencies] [dev-dependencies]
assert_matches = "1.3.0" assert_matches = "1.3.0"

View File

@ -1,8 +1,8 @@
use log::*;
/// Cluster independent integration tests /// Cluster independent integration tests
/// ///
/// 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 log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_client::thin_client::create_client; use solana_client::thin_client::create_client;

2
poh/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target/
/farf/

39
poh/Cargo.toml Normal file
View File

@ -0,0 +1,39 @@
[package]
name = "solana-poh"
version = "1.7.1"
description = "Solana PoH"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-poh"
edition = "2018"
[dependencies]
core_affinity = "0.5.10"
crossbeam-channel = "0.4"
log = "0.4.11"
solana-ledger = { path = "../ledger", version = "=1.7.1" }
solana-measure = { path = "../measure", version = "=1.7.1" }
solana-metrics = { path = "../metrics", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" }
solana-sys-tuner = { path = "../sys-tuner", version = "=1.7.1" }
thiserror = "1.0"
[dev-dependencies]
bincode = "1.3.1"
matches = "0.1.6"
rand = "0.7.0"
solana-logger = { path = "../logger", version = "=1.7.1" }
solana-perf = { path = "../perf", version = "=1.7.1" }
[lib]
crate-type = ["lib"]
name = "solana_poh"
[[bench]]
name = "poh"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -3,12 +3,16 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
use solana_core::poh_service::DEFAULT_HASHES_PER_BATCH; use {
use solana_ledger::poh::Poh; solana_ledger::poh::Poh,
use solana_sdk::hash::Hash; solana_poh::poh_service::DEFAULT_HASHES_PER_BATCH,
use std::sync::atomic::{AtomicBool, Ordering}; solana_sdk::hash::Hash,
use std::sync::{Arc, Mutex}; std::sync::{
use test::Bencher; atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
test::Bencher,
};
const NUM_HASHES: u64 = 30_000; // Should require ~10ms on a 2017 MacBook Pro const NUM_HASHES: u64 = 30_000; // Should require ~10ms on a 2017 MacBook Pro

View File

@ -1,11 +1,15 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
use solana_ledger::entry::{next_entry_mut, Entry, EntrySlice}; use {
use solana_sdk::hash::{hash, Hash}; solana_ledger::entry::{next_entry_mut, Entry, EntrySlice},
use solana_sdk::signature::{Keypair, Signer}; solana_sdk::{
use solana_sdk::system_transaction; hash::{hash, Hash},
use test::Bencher; signature::{Keypair, Signer},
system_transaction,
},
test::Bencher,
};
const NUM_HASHES: u64 = 400; const NUM_HASHES: u64 = 400;
const NUM_ENTRIES: usize = 800; const NUM_ENTRIES: usize = 800;

10
poh/src/lib.rs Normal file
View File

@ -0,0 +1,10 @@
#![allow(clippy::integer_arithmetic)]
pub mod poh_recorder;
pub mod poh_service;
#[macro_use]
extern crate solana_metrics;
#[cfg(test)]
#[macro_use]
extern crate matches;

View File

@ -10,30 +10,32 @@
//! 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::poh_service::PohService;
use crossbeam_channel::{
unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Sender as CrossbeamSender,
};
use solana_ledger::blockstore::Blockstore;
use solana_ledger::entry::Entry;
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_ledger::poh::Poh;
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 {
use solana_sdk::hash::Hash; crate::poh_service::PohService,
use solana_sdk::poh_config::PohConfig; crossbeam_channel::{
use solana_sdk::pubkey::Pubkey; unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Sender as CrossbeamSender,
use solana_sdk::timing; },
use solana_sdk::transaction::Transaction; log::*,
use std::cmp; solana_ledger::{
use std::sync::{ blockstore::Blockstore, entry::Entry, leader_schedule_cache::LeaderScheduleCache, poh::Poh,
},
solana_runtime::bank::Bank,
solana_sdk::{
clock::NUM_CONSECUTIVE_LEADER_SLOTS, hash::Hash, poh_config::PohConfig, pubkey::Pubkey,
timing, transaction::Transaction,
},
std::{
cmp,
sync::{
atomic::{AtomicBool, Ordering}, atomic::{AtomicBool, Ordering},
mpsc::{channel, Receiver, SendError, Sender, SyncSender}, mpsc::{channel, Receiver, SendError, Sender, SyncSender},
{Arc, Mutex}, {Arc, Mutex},
},
time::{Duration, Instant},
},
thiserror::Error,
}; };
use std::time::{Duration, Instant};
use thiserror::Error;
pub const GRACE_TICKS_FACTOR: u64 = 2; pub const GRACE_TICKS_FACTOR: u64 = 2;
pub const MAX_GRACE_SLOTS: u64 = 2; pub const MAX_GRACE_SLOTS: u64 = 2;
@ -726,22 +728,67 @@ impl PohRecorder {
}) })
} }
#[cfg(test)] // Used in tests
pub fn schedule_dummy_max_height_reached_failure(&mut self) { pub fn schedule_dummy_max_height_reached_failure(&mut self) {
self.reset(Hash::default(), 1, None); self.reset(Hash::default(), 1, None);
} }
} }
pub fn create_test_recorder(
bank: &Arc<Bank>,
blockstore: &Arc<Blockstore>,
poh_config: Option<PohConfig>,
) -> (
Arc<AtomicBool>,
Arc<Mutex<PohRecorder>>,
PohService,
Receiver<WorkingBankEntry>,
) {
let exit = Arc::new(AtomicBool::new(false));
let poh_config = Arc::new(poh_config.unwrap_or_default());
let (mut poh_recorder, entry_receiver, record_receiver) = PohRecorder::new(
bank.tick_height(),
bank.last_blockhash(),
bank.slot(),
Some((4, 4)),
bank.ticks_per_slot(),
&Pubkey::default(),
blockstore,
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&poh_config,
exit.clone(),
);
poh_recorder.set_bank(&bank);
let poh_recorder = Arc::new(Mutex::new(poh_recorder));
let poh_service = PohService::new(
poh_recorder.clone(),
&poh_config,
&exit,
bank.ticks_per_slot(),
crate::poh_service::DEFAULT_PINNED_CPU_CORE,
crate::poh_service::DEFAULT_HASHES_PER_BATCH,
record_receiver,
);
(exit, poh_recorder, poh_service, entry_receiver)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use bincode::serialize; super::*,
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; bincode::serialize,
use solana_ledger::{blockstore::Blockstore, blockstore_meta::SlotMeta, get_tmp_ledger_path}; solana_ledger::{
use solana_perf::test_tx::test_tx; blockstore::Blockstore,
use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT; blockstore_meta::SlotMeta,
use solana_sdk::hash::hash; genesis_utils::{create_genesis_config, GenesisConfigInfo},
use std::sync::mpsc::sync_channel; get_tmp_ledger_path,
},
solana_perf::test_tx::test_tx,
solana_sdk::{clock::DEFAULT_TICKS_PER_SLOT, hash::hash},
std::sync::mpsc::sync_channel,
};
#[test] #[test]
fn test_poh_recorder_no_zero_tick() { fn test_poh_recorder_no_zero_tick() {

View File

@ -1,14 +1,21 @@
//! The `poh_service` module implements a service that records the passing of //! The `poh_service` module implements a service that records the passing of
//! "ticks", a measure of time in the PoH stream //! "ticks", a measure of time in the PoH stream
use crate::poh_recorder::{PohRecorder, Record}; use {
use crossbeam_channel::Receiver; crate::poh_recorder::{PohRecorder, Record},
use solana_ledger::poh::Poh; crossbeam_channel::Receiver,
use solana_measure::measure::Measure; log::*,
use solana_sdk::poh_config::PohConfig; solana_ledger::poh::Poh,
use std::sync::atomic::{AtomicBool, Ordering}; solana_measure::measure::Measure,
use std::sync::{Arc, Mutex}; solana_sdk::poh_config::PohConfig,
use std::thread::{self, sleep, Builder, JoinHandle}; std::{
use std::time::{Duration, Instant}; sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
};
pub struct PohService { pub struct PohService {
tick_producer: JoinHandle<()>, tick_producer: JoinHandle<()>,
@ -348,20 +355,22 @@ impl PohService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use crate::poh_recorder::WorkingBank; super::*,
use rand::{thread_rng, Rng}; crate::poh_recorder::WorkingBank,
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; rand::{thread_rng, Rng},
use solana_ledger::leader_schedule_cache::LeaderScheduleCache; solana_ledger::{
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; blockstore::Blockstore,
use solana_measure::measure::Measure; genesis_utils::{create_genesis_config, GenesisConfigInfo},
use solana_perf::test_tx::test_tx; get_tmp_ledger_path,
use solana_runtime::bank::Bank; leader_schedule_cache::LeaderScheduleCache,
use solana_sdk::clock; },
use solana_sdk::hash::hash; solana_measure::measure::Measure,
use solana_sdk::pubkey::Pubkey; solana_perf::test_tx::test_tx,
use solana_sdk::timing; solana_runtime::bank::Bank,
use std::time::Duration; solana_sdk::{clock, hash::hash, pubkey::Pubkey, timing},
std::time::Duration,
};
#[test] #[test]
#[ignore] #[ignore]

View File

@ -10,31 +10,49 @@ documentation = "https://docs.rs/solana-rpc"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
base64 = "0.12.3"
bincode = "1.3.1"
bs58 = "0.3.1" bs58 = "0.3.1"
crossbeam-channel = "0.4" crossbeam-channel = "0.4"
itertools = "0.9.0"
jsonrpc-core = "17.0.0" jsonrpc-core = "17.0.0"
jsonrpc-core-client = { version = "17.0.0", features = ["ipc", "ws"] } jsonrpc-core-client = { version = "17.0.0", features = ["ipc", "ws"] }
jsonrpc-derive = "17.0.0" jsonrpc-derive = "17.0.0"
jsonrpc-http-server = "17.0.0"
jsonrpc-pubsub = "17.0.0" jsonrpc-pubsub = "17.0.0"
jsonrpc-ws-server = "17.0.0" jsonrpc-ws-server = "17.0.0"
libc = "0.2.81"
log = "0.4.11" log = "0.4.11"
regex = "1.3.9"
serde = "1.0.122" serde = "1.0.122"
serde_derive = "1.0.103" serde_derive = "1.0.103"
serde_json = "1.0.56" serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "=1.7.1" } solana-account-decoder = { path = "../account-decoder", version = "=1.7.1" }
solana-client = { path = "../client", version = "=1.7.1" } solana-client = { path = "../client", version = "=1.7.1" }
solana-faucet = { path = "../faucet", version = "=1.7.1" }
solana-gossip = { path = "../gossip", version = "=1.7.1" }
solana-ledger = { path = "../ledger", version = "=1.7.1" } solana-ledger = { path = "../ledger", version = "=1.7.1" }
solana-measure = { path = "../measure", version = "=1.7.1" } solana-measure = { path = "../measure", version = "=1.7.1" }
solana-metrics = { path = "../metrics", version = "=1.7.1" } solana-metrics = { path = "../metrics", version = "=1.7.1" }
solana-perf = { path = "../perf", version = "=1.7.1" }
solana-poh = { path = "../poh", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" } solana-runtime = { path = "../runtime", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" } solana-sdk = { path = "../sdk", version = "=1.7.1" }
solana-stake-program = { path = "../programs/stake", version = "=1.7.1" }
solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.7.1" }
solana-transaction-status = { path = "../transaction-status", version = "=1.7.1" }
solana-version = { path = "../version", version = "=1.7.1" }
solana-vote-program = { path = "../programs/vote", version = "=1.7.1" } solana-vote-program = { path = "../programs/vote", version = "=1.7.1" }
spl-token-v2-0 = { package = "spl-token", version = "=3.1.0", features = ["no-entrypoint"] } spl-token-v2-0 = { package = "spl-token", version = "=3.1.0", features = ["no-entrypoint"] }
tokio = { version = "1", features = ["full"] }
tokio_02 = { version = "0.2", package = "tokio", features = ["full"] }
tokio-util = { version = "0.3", features = ["codec"] } # This crate needs to stay in sync with tokio_02, until that dependency can be removed
[dev-dependencies] [dev-dependencies]
serial_test = "0.4.0" serial_test = "0.4.0"
solana-stake-program = { path = "../programs/stake", version = "=1.7.1" } solana-logger = { path = "../logger", version = "=1.7.1" }
tokio = { version = "1", features = ["full"] } solana-net-utils = { path = "../net-utils", version = "=1.7.1" }
symlink = "0.1.0"
[lib] [lib]
crate-type = ["lib"] crate-type = ["lib"]

View File

@ -2,10 +2,15 @@
pub mod max_slots; pub mod max_slots;
pub mod optimistically_confirmed_bank_tracker; pub mod optimistically_confirmed_bank_tracker;
pub mod parsed_token_accounts; pub mod parsed_token_accounts;
pub mod rpc;
pub mod rpc_completed_slots_service; pub mod rpc_completed_slots_service;
pub mod rpc_health;
pub mod rpc_pubsub; pub mod rpc_pubsub;
pub mod rpc_pubsub_service; pub mod rpc_pubsub_service;
pub mod rpc_service;
pub mod rpc_subscriptions; pub mod rpc_subscriptions;
pub mod send_transaction_service;
pub mod transaction_status_service;
#[macro_use] #[macro_use]
extern crate log; extern crate log;

View File

@ -1,46 +1,46 @@
//! The `rpc` module implements the Solana RPC interface. //! The `rpc` module implements the Solana RPC interface.
use crate::{ use {
crate::{
max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
parsed_token_accounts::*,
rpc_health::*, rpc_health::*,
send_transaction_service::{SendTransactionService, TransactionInfo}, send_transaction_service::{SendTransactionService, TransactionInfo},
}; },
use bincode::{config::Options, serialize}; bincode::{config::Options, serialize},
use jsonrpc_core::{types::error, Error, Metadata, Result}; jsonrpc_core::{types::error, Error, Metadata, Result},
use jsonrpc_derive::rpc; jsonrpc_derive::rpc,
use serde::{Deserialize, Serialize}; serde::{Deserialize, Serialize},
use solana_account_decoder::{ solana_account_decoder::{
parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount}, parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount},
UiAccount, UiAccountEncoding, UiDataSliceConfig, UiAccount, UiAccountEncoding, UiDataSliceConfig,
}; },
use solana_client::{ solana_client::{
rpc_cache::LargestAccountsCache, rpc_cache::LargestAccountsCache,
rpc_config::*, rpc_config::*,
rpc_custom_error::RpcCustomError, rpc_custom_error::RpcCustomError,
rpc_deprecated_config::*, rpc_deprecated_config::*,
rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
rpc_request::{ rpc_request::{
TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE, MAX_GET_CONFIRMED_BLOCKS_RANGE, TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE,
MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT, MAX_GET_CONFIRMED_BLOCKS_RANGE, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT,
MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, MAX_GET_PROGRAM_ACCOUNT_FILTERS, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, MAX_GET_PROGRAM_ACCOUNT_FILTERS,
MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_GET_SLOT_LEADERS, MAX_MULTIPLE_ACCOUNTS, MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_GET_SLOT_LEADERS, MAX_MULTIPLE_ACCOUNTS,
NUM_LARGEST_ACCOUNTS, NUM_LARGEST_ACCOUNTS,
}, },
rpc_response::Response as RpcResponse, rpc_response::Response as RpcResponse,
rpc_response::*, rpc_response::*,
}; },
use solana_faucet::faucet::request_airdrop_transaction; solana_faucet::faucet::request_airdrop_transaction,
use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}; solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
use solana_ledger::{ solana_ledger::{
blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path, blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache, leader_schedule_cache::LeaderScheduleCache,
}; },
use solana_metrics::inc_new_counter_info; solana_metrics::inc_new_counter_info,
use solana_perf::packet::PACKET_DATA_SIZE; solana_perf::packet::PACKET_DATA_SIZE,
use solana_rpc::{ solana_runtime::{
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
parsed_token_accounts::*,
};
use solana_runtime::{
accounts::AccountAddressFilter, accounts::AccountAddressFilter,
accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey}, accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey},
bank::Bank, bank::Bank,
@ -49,8 +49,8 @@ use solana_runtime::{
inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
non_circulating_supply::calculate_non_circulating_supply, non_circulating_supply::calculate_non_circulating_supply,
snapshot_utils::get_highest_snapshot_archive_path, snapshot_utils::get_highest_snapshot_archive_path,
}; },
use solana_sdk::{ solana_sdk::{
account::{AccountSharedData, ReadableAccount}, account::{AccountSharedData, ReadableAccount},
account_utils::StateMut, account_utils::StateMut,
clock::{Slot, UnixTimestamp, MAX_RECENT_BLOCKHASHES}, clock::{Slot, UnixTimestamp, MAX_RECENT_BLOCKHASHES},
@ -61,23 +61,23 @@ use solana_sdk::{
hash::Hash, hash::Hash,
pubkey::Pubkey, pubkey::Pubkey,
sanitize::Sanitize, sanitize::Sanitize,
signature::Signature, signature::{Keypair, Signature, Signer},
stake_history::StakeHistory, stake_history::StakeHistory,
system_instruction, system_instruction,
sysvar::stake_history, sysvar::stake_history,
transaction::{self, Transaction}, transaction::{self, Transaction},
}; },
use solana_stake_program::stake_state::StakeState; solana_stake_program::stake_state::StakeState,
use solana_transaction_status::{ solana_transaction_status::{
EncodedConfirmedTransaction, Reward, RewardType, TransactionConfirmationStatus, EncodedConfirmedTransaction, Reward, RewardType, TransactionConfirmationStatus,
TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding,
}; },
use solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY}; solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY},
use spl_token_v2_0::{ spl_token_v2_0::{
solana_program::program_pack::Pack, solana_program::program_pack::Pack,
state::{Account as TokenAccount, Mint}, state::{Account as TokenAccount, Mint},
}; },
use std::{ std::{
cmp::{max, min}, cmp::{max, min},
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
net::SocketAddr, net::SocketAddr,
@ -88,8 +88,9 @@ use std::{
Arc, Mutex, RwLock, Arc, Mutex, RwLock,
}, },
time::Duration, time::Duration,
},
tokio::runtime::Runtime,
}; };
use tokio::runtime::Runtime;
pub const MAX_REQUEST_PAYLOAD_SIZE: usize = 50 * (1 << 10); // 50kB pub const MAX_REQUEST_PAYLOAD_SIZE: usize = 50 * (1 << 10); // 50kB
pub const PERFORMANCE_SAMPLES_LIMIT: usize = 720; pub const PERFORMANCE_SAMPLES_LIMIT: usize = 720;
@ -3779,31 +3780,107 @@ pub(crate) fn create_validator_exit(exit: &Arc<AtomicBool>) -> Arc<RwLock<Exit>>
Arc::new(RwLock::new(validator_exit)) Arc::new(RwLock::new(validator_exit))
} }
// Used for tests
pub fn create_test_transactions_and_populate_blockstore(
keypairs: Vec<&Keypair>,
previous_slot: Slot,
bank: Arc<Bank>,
blockstore: Arc<Blockstore>,
max_complete_transaction_status_slot: Arc<AtomicU64>,
) -> Vec<Signature> {
let mint_keypair = keypairs[0];
let keypair1 = keypairs[1];
let keypair2 = keypairs[2];
let keypair3 = keypairs[3];
let slot = bank.slot();
let blockhash = bank.confirmed_last_blockhash().0;
// Generate transactions for processing
// Successful transaction
let success_tx =
solana_sdk::system_transaction::transfer(&mint_keypair, &keypair1.pubkey(), 2, blockhash);
let success_signature = success_tx.signatures[0];
let entry_1 = solana_ledger::entry::next_entry(&blockhash, 1, vec![success_tx]);
// Failed transaction, InstructionError
let ix_error_tx =
solana_sdk::system_transaction::transfer(&keypair2, &keypair3.pubkey(), 10, blockhash);
let ix_error_signature = ix_error_tx.signatures[0];
let entry_2 = solana_ledger::entry::next_entry(&entry_1.hash, 1, vec![ix_error_tx]);
// Failed transaction
let fail_tx = solana_sdk::system_transaction::transfer(
&mint_keypair,
&keypair2.pubkey(),
2,
Hash::default(),
);
let entry_3 = solana_ledger::entry::next_entry(&entry_2.hash, 1, vec![fail_tx]);
let mut entries = vec![entry_1, entry_2, entry_3];
let shreds = solana_ledger::blockstore::entries_to_test_shreds(
entries.clone(),
slot,
previous_slot,
true,
0,
);
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(&[slot]).unwrap();
let (transaction_status_sender, transaction_status_receiver) = crossbeam_channel::unbounded();
let (replay_vote_sender, _replay_vote_receiver) = crossbeam_channel::unbounded();
let transaction_status_service =
crate::transaction_status_service::TransactionStatusService::new(
transaction_status_receiver,
max_complete_transaction_status_slot,
blockstore,
&Arc::new(AtomicBool::new(false)),
);
// Check that process_entries successfully writes can_commit transactions statuses, and
// that they are matched properly by get_rooted_block
let _result = solana_ledger::blockstore_processor::process_entries(
&bank,
&mut entries,
true,
Some(
&solana_ledger::blockstore_processor::TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
},
),
Some(&replay_vote_sender),
);
transaction_status_service.join().unwrap();
vec![success_signature, ix_error_signature]
}
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::{rpc_full::*, rpc_minimal::*, *}; use {
use crate::replay_stage::tests::create_test_transactions_and_populate_blockstore; super::{rpc_full::*, rpc_minimal::*, *},
use bincode::deserialize; crate::{
use jsonrpc_core::{futures, ErrorCode, MetaIoHandler, Output, Response, Value};
use jsonrpc_core_client::transports::local;
use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes};
use solana_gossip::{contact_info::ContactInfo, socketaddr};
use solana_ledger::{
blockstore_meta::PerfSample,
blockstore_processor::fill_blockstore_slot_with_ticks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
};
use solana_rpc::{
optimistically_confirmed_bank_tracker::{ optimistically_confirmed_bank_tracker::{
BankNotification, OptimisticallyConfirmedBankTracker, BankNotification, OptimisticallyConfirmedBankTracker,
}, },
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,
}; },
use solana_runtime::{ bincode::deserialize,
jsonrpc_core::{futures, ErrorCode, MetaIoHandler, Output, Response, Value},
jsonrpc_core_client::transports::local,
solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes},
solana_gossip::{contact_info::ContactInfo, socketaddr},
solana_ledger::{
blockstore_meta::PerfSample,
blockstore_processor::fill_blockstore_slot_with_ticks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
},
solana_runtime::{
accounts_background_service::AbsRequestSender, commitment::BlockCommitment, accounts_background_service::AbsRequestSender, commitment::BlockCommitment,
non_circulating_supply::non_circulating_accounts, non_circulating_supply::non_circulating_accounts,
}; },
use solana_sdk::{ solana_sdk::{
account::Account, account::Account,
clock::MAX_RECENT_BLOCKHASHES, clock::MAX_RECENT_BLOCKHASHES,
fee_calculator::DEFAULT_BURN_PERCENT, fee_calculator::DEFAULT_BURN_PERCENT,
@ -3815,21 +3892,22 @@ pub mod tests {
system_program, system_transaction, system_program, system_transaction,
timing::slot_duration_from_slots_per_year, timing::slot_duration_from_slots_per_year,
transaction::{self, TransactionError}, transaction::{self, TransactionError},
}; },
use solana_transaction_status::{ solana_transaction_status::{
EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta, EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta,
TransactionDetails, UiMessage, TransactionDetails, UiMessage,
}; },
use solana_vote_program::{ solana_vote_program::{
vote_instruction, vote_instruction,
vote_state::{BlockTimestamp, Vote, VoteInit, VoteStateVersions, MAX_LOCKOUT_HISTORY}, vote_state::{BlockTimestamp, Vote, VoteInit, VoteStateVersions, MAX_LOCKOUT_HISTORY},
}; },
use spl_token_v2_0::{ spl_token_v2_0::{
solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey}, solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey},
state::AccountState as TokenAccountState, state::AccountState as TokenAccountState,
state::Mint, state::Mint,
},
std::collections::HashMap,
}; };
use std::collections::HashMap;
const TEST_MINT_LAMPORTS: u64 = 1_000_000; const TEST_MINT_LAMPORTS: u64 = 1_000_000;
const TEST_SLOTS_PER_EPOCH: u64 = DELINQUENT_VALIDATOR_SLOT_DISTANCE + 1; const TEST_SLOTS_PER_EPOCH: u64 = DELINQUENT_VALIDATOR_SLOT_DISTANCE + 1;

View File

@ -1,44 +1,47 @@
//! The `rpc_service` module implements the Solana JSON RPC service. //! The `rpc_service` module implements the Solana JSON RPC service.
use crate::{ use {
bigtable_upload_service::BigTableUploadService, crate::{
poh_recorder::PohRecorder, max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *}, rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *},
rpc_health::*, rpc_health::*,
send_transaction_service::{LeaderInfo, SendTransactionService}, send_transaction_service::{LeaderInfo, SendTransactionService},
}; },
use jsonrpc_core::{futures::prelude::*, MetaIoHandler}; jsonrpc_core::{futures::prelude::*, MetaIoHandler},
use jsonrpc_http_server::{ jsonrpc_http_server::{
hyper, AccessControlAllowOrigin, CloseHandle, DomainsValidation, RequestMiddleware, hyper, AccessControlAllowOrigin, CloseHandle, DomainsValidation, RequestMiddleware,
RequestMiddlewareAction, ServerBuilder, RequestMiddlewareAction, ServerBuilder,
}; },
use regex::Regex; regex::Regex,
use solana_client::rpc_cache::LargestAccountsCache; solana_client::rpc_cache::LargestAccountsCache,
use solana_gossip::cluster_info::ClusterInfo; solana_gossip::cluster_info::ClusterInfo,
use solana_ledger::{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache}; solana_ledger::{
use solana_metrics::inc_new_counter_info; bigtable_upload_service::BigTableUploadService, blockstore::Blockstore,
use solana_rpc::{ leader_schedule_cache::LeaderScheduleCache,
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, },
}; solana_metrics::inc_new_counter_info,
use solana_runtime::{ solana_poh::poh_recorder::PohRecorder,
solana_runtime::{
bank_forks::{BankForks, SnapshotConfig}, bank_forks::{BankForks, SnapshotConfig},
commitment::BlockCommitmentCache, commitment::BlockCommitmentCache,
snapshot_utils, snapshot_utils,
}; },
use solana_sdk::{ solana_sdk::{
exit::Exit, genesis_config::DEFAULT_GENESIS_DOWNLOAD_PATH, hash::Hash, exit::Exit, genesis_config::DEFAULT_GENESIS_DOWNLOAD_PATH, hash::Hash,
native_token::lamports_to_sol, pubkey::Pubkey, native_token::lamports_to_sol, pubkey::Pubkey,
}; },
use std::{ std::{
collections::HashSet, collections::HashSet,
net::SocketAddr, net::SocketAddr,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::atomic::{AtomicBool, AtomicU64, Ordering}, sync::atomic::{AtomicBool, AtomicU64, Ordering},
sync::{mpsc::channel, Arc, Mutex, RwLock}, sync::{mpsc::channel, Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle}, thread::{self, Builder, JoinHandle},
},
tokio::runtime,
tokio_util::codec::{BytesCodec, FramedRead},
}; };
use tokio::runtime;
use tokio_util::codec::{BytesCodec, FramedRead};
const LARGEST_ACCOUNTS_CACHE_DURATION: u64 = 60 * 60 * 2; const LARGEST_ACCOUNTS_CACHE_DURATION: u64 = 60 * 60 * 2;
@ -477,23 +480,27 @@ impl JsonRpcService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use crate::rpc::create_validator_exit; super::*,
use solana_gossip::crds_value::{CrdsData, CrdsValue, SnapshotHash}; crate::rpc::create_validator_exit,
use solana_ledger::{ solana_gossip::crds_value::{CrdsData, CrdsValue, SnapshotHash},
solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo}, genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path, get_tmp_ledger_path,
}; },
use solana_runtime::{ solana_runtime::{
bank::Bank, bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion, bank::Bank, bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion,
snapshot_utils::DEFAULT_MAX_SNAPSHOTS_TO_RETAIN, snapshot_utils::DEFAULT_MAX_SNAPSHOTS_TO_RETAIN,
}; },
use solana_sdk::{ solana_sdk::{
genesis_config::{ClusterType, DEFAULT_GENESIS_ARCHIVE}, genesis_config::{ClusterType, DEFAULT_GENESIS_ARCHIVE},
signature::Signer, signature::Signer,
},
std::{
io::Write,
net::{IpAddr, Ipv4Addr},
},
}; };
use std::io::Write;
use std::net::{IpAddr, Ipv4Addr};
#[test] #[test]
fn test_rpc_new() { fn test_rpc_new() {

View File

@ -1,26 +1,27 @@
// TODO: Merge this implementation with the one at `banks-server/src/send_transaction_service.rs` // TODO: Merge this implementation with the one at `banks-server/src/send_transaction_service.rs`
use crate::poh_recorder::PohRecorder; use {
use log::*; log::*,
use solana_gossip::cluster_info::ClusterInfo; solana_gossip::cluster_info::ClusterInfo,
use solana_metrics::{datapoint_warn, inc_new_counter_info}; solana_metrics::{datapoint_warn, inc_new_counter_info},
use solana_runtime::{bank::Bank, bank_forks::BankForks}; solana_poh::poh_recorder::PohRecorder,
use solana_sdk::{ solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{
clock::{Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, clock::{Slot, NUM_CONSECUTIVE_LEADER_SLOTS},
hash::Hash, hash::Hash,
nonce_account, nonce_account,
pubkey::Pubkey, pubkey::Pubkey,
signature::Signature, signature::Signature,
}; },
use std::sync::Mutex; std::{
use std::{
collections::HashMap, collections::HashMap,
net::{SocketAddr, UdpSocket}, net::{SocketAddr, UdpSocket},
sync::{ sync::{
mpsc::{Receiver, RecvTimeoutError}, mpsc::{Receiver, RecvTimeoutError},
Arc, RwLock, Arc, Mutex, RwLock,
}, },
thread::{self, Builder, JoinHandle}, thread::{self, Builder, JoinHandle},
time::{Duration, Instant}, time::{Duration, Instant},
},
}; };
/// Maximum size of the transaction queue /// Maximum size of the transaction queue
@ -312,15 +313,16 @@ impl SendTransactionService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use solana_gossip::contact_info::ContactInfo; super::*,
use solana_ledger::{ solana_gossip::contact_info::ContactInfo,
solana_ledger::{
blockstore::Blockstore, get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache, blockstore::Blockstore, get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache,
}; },
use solana_runtime::genesis_utils::{ solana_runtime::genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs, create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
}; },
use solana_sdk::{ solana_sdk::{
account::AccountSharedData, account::AccountSharedData,
fee_calculator::FeeCalculator, fee_calculator::FeeCalculator,
genesis_config::create_genesis_config, genesis_config::create_genesis_config,
@ -330,8 +332,9 @@ mod test {
signature::{Keypair, Signer}, signature::{Keypair, Signer},
system_program, system_transaction, system_program, system_transaction,
timing::timestamp, timing::timestamp,
},
std::sync::{atomic::AtomicBool, mpsc::channel},
}; };
use std::sync::{atomic::AtomicBool, mpsc::channel};
#[test] #[test]
fn service_exit() { fn service_exit() {

View File

@ -1,20 +1,22 @@
use crossbeam_channel::{Receiver, RecvTimeoutError}; use {
use itertools::izip; crossbeam_channel::{Receiver, RecvTimeoutError},
use solana_ledger::{ itertools::izip,
solana_ledger::{
blockstore::Blockstore, blockstore::Blockstore,
blockstore_processor::{TransactionStatusBatch, TransactionStatusMessage}, blockstore_processor::{TransactionStatusBatch, TransactionStatusMessage},
}; },
use solana_runtime::bank::{ solana_runtime::bank::{
Bank, InnerInstructionsList, NonceRollbackInfo, TransactionLogMessages, Bank, InnerInstructionsList, NonceRollbackInfo, TransactionLogMessages,
}; },
use solana_transaction_status::{InnerInstructions, Reward, TransactionStatusMeta}; solana_transaction_status::{InnerInstructions, Reward, TransactionStatusMeta},
use std::{ std::{
sync::{ sync::{
atomic::{AtomicBool, AtomicU64, Ordering}, atomic::{AtomicBool, AtomicU64, Ordering},
Arc, Arc,
}, },
thread::{self, Builder, JoinHandle}, thread::{self, Builder, JoinHandle},
time::Duration, time::Duration,
},
}; };
pub struct TransactionStatusService { pub struct TransactionStatusService {

View File

@ -20,6 +20,7 @@ solana-cli-config = { path = "../cli-config", version = "=1.7.1" }
solana-client = { path = "../client", version = "=1.7.1" } solana-client = { path = "../client", version = "=1.7.1" }
solana-logger = { path = "../logger", version = "=1.7.1" } solana-logger = { path = "../logger", version = "=1.7.1" }
solana-metrics = { path = "../metrics", version = "=1.7.1" } solana-metrics = { path = "../metrics", version = "=1.7.1" }
solana-rpc = { path = "../rpc", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" } solana-sdk = { path = "../sdk", version = "=1.7.1" }
solana-stake-program = { path = "../programs/stake", version = "=1.7.1" } solana-stake-program = { path = "../programs/stake", version = "=1.7.1" }
solana-transaction-status = { path = "../transaction-status", version = "=1.7.1" } solana-transaction-status = { path = "../transaction-status", version = "=1.7.1" }

View File

@ -359,8 +359,9 @@ mod test {
use super::*; use super::*;
use serial_test::serial; use serial_test::serial;
use solana_client::rpc_config::RpcSendTransactionConfig; use solana_client::rpc_config::RpcSendTransactionConfig;
use solana_core::{rpc::JsonRpcConfig, validator::ValidatorConfig}; use solana_core::validator::ValidatorConfig;
use solana_local_cluster::local_cluster::{ClusterConfig, LocalCluster}; use solana_local_cluster::local_cluster::{ClusterConfig, LocalCluster};
use solana_rpc::rpc::JsonRpcConfig;
use solana_sdk::{ use solana_sdk::{
commitment_config::CommitmentConfig, commitment_config::CommitmentConfig,
genesis_config::ClusterType, genesis_config::ClusterType,

View File

@ -41,6 +41,7 @@ solana-logger = { path = "../logger", version = "=1.7.1" }
solana-metrics = { path = "../metrics", version = "=1.7.1" } solana-metrics = { path = "../metrics", version = "=1.7.1" }
solana-net-utils = { path = "../net-utils", version = "=1.7.1" } solana-net-utils = { path = "../net-utils", version = "=1.7.1" }
solana-perf = { path = "../perf", version = "=1.7.1" } solana-perf = { path = "../perf", version = "=1.7.1" }
solana-poh = { path = "../poh", version = "=1.7.1" }
solana-rpc = { path = "../rpc", version = "=1.7.1" } solana-rpc = { path = "../rpc", version = "=1.7.1" }
solana-runtime = { path = "../runtime", version = "=1.7.1" } solana-runtime = { path = "../runtime", version = "=1.7.1" }
solana-sdk = { path = "../sdk", version = "=1.7.1" } solana-sdk = { path = "../sdk", version = "=1.7.1" }

View File

@ -9,8 +9,8 @@ use {
}, },
}, },
solana_client::rpc_client::RpcClient, solana_client::rpc_client::RpcClient,
solana_core::rpc::JsonRpcConfig,
solana_faucet::faucet::{run_local_faucet_with_port, FAUCET_PORT}, solana_faucet::faucet::{run_local_faucet_with_port, FAUCET_PORT},
solana_rpc::rpc::JsonRpcConfig,
solana_sdk::{ solana_sdk::{
account::AccountSharedData, account::AccountSharedData,
clock::Slot, clock::Slot,

View File

@ -22,8 +22,6 @@ use {
}, },
solana_core::{ solana_core::{
ledger_cleanup_service::{DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS}, ledger_cleanup_service::{DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS},
poh_service,
rpc::JsonRpcConfig,
tpu::DEFAULT_TPU_COALESCE_MS, tpu::DEFAULT_TPU_COALESCE_MS,
validator::{ validator::{
is_snapshot_config_invalid, Validator, ValidatorConfig, ValidatorStartProgress, is_snapshot_config_invalid, Validator, ValidatorConfig, ValidatorStartProgress,
@ -38,7 +36,8 @@ use {
}, },
solana_ledger::blockstore_db::BlockstoreRecoveryMode, solana_ledger::blockstore_db::BlockstoreRecoveryMode,
solana_perf::recycler::enable_recycler_warming, solana_perf::recycler::enable_recycler_warming,
solana_rpc::rpc_pubsub_service::PubSubConfig, solana_poh::poh_service,
solana_rpc::{rpc::JsonRpcConfig, rpc_pubsub_service::PubSubConfig},
solana_runtime::{ solana_runtime::{
accounts_index::{ accounts_index::{
AccountIndex, AccountSecondaryIndexes, AccountSecondaryIndexesIncludeExclude, AccountIndex, AccountSecondaryIndexes, AccountSecondaryIndexesIncludeExclude,