diff --git a/Cargo.lock b/Cargo.lock index 50042ccc311f2e..6755758427954f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7749,20 +7749,26 @@ dependencies = [ "rand_chacha 0.3.1", "rayon", "serde", + "solana-clock", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-hash", + "solana-keypair", "solana-logger", + "solana-message", "solana-metrics", "solana-packet", "solana-perf", - "solana-program", "solana-pubkey", "solana-rayon-threadlimit", - "solana-sdk", + "solana-sdk-ids", "solana-short-vec", "solana-signature", + "solana-signer", + "solana-system-interface", + "solana-system-transaction", "solana-time-utils", + "solana-transaction", "solana-vote-program", "test-case", ] @@ -7995,16 +8001,31 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-logger", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "test-case", @@ -8306,12 +8327,29 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "solana-account", "solana-account-decoder", "solana-account-decoder-client-types", + "solana-clock", + "solana-commitment-config", + "solana-epoch-info", + "solana-epoch-schedule", + "solana-feature-gate-interface", + "solana-hash", + "solana-instruction", + "solana-keypair", + "solana-message", + "solana-program", + "solana-pubkey", "solana-rpc-client-api", - "solana-sdk", + "solana-signature", + "solana-signer", + "solana-system-transaction", + "solana-transaction", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-version", + "static_assertions", "tokio", ] @@ -9252,7 +9290,7 @@ version = "2.2.0" dependencies = [ "eager", "enum-iterator", - "solana-sdk", + "solana-pubkey", ] [[package]] diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index d24355c90a217a..c82e789e54a6be 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -19,12 +19,14 @@ use { hash::Hash, instruction::{AccountMeta, Instruction}, message::Message, + program_pack::Pack, pubkey::Pubkey, signature::{read_keypair_file, Keypair, Signer}, system_instruction, system_program, transaction::Transaction, }, solana_streamer::socket::SocketAddrSpace, + spl_token::state::Account, std::{ cmp::min, process::exit, @@ -139,7 +141,11 @@ fn make_create_message( maybe_space: Option, mint: Option, ) -> Message { - let space = maybe_space.unwrap_or_else(|| thread_rng().gen_range(0..1000)); + let space = if mint.is_some() { + Account::get_packed_len() as u64 + } else { + maybe_space.unwrap_or_else(|| thread_rng().gen_range(0..1000)) + }; let instructions: Vec<_> = (0..num_instructions) .flat_map(|_| { @@ -170,6 +176,17 @@ fn make_create_message( ) .unwrap(), ); + instructions.push( + spl_token::instruction::approve( + &spl_token::id(), + &to_pubkey, + &base_keypair.pubkey(), + &base_keypair.pubkey(), + &[&base_keypair.pubkey()], + 1, + ) + .unwrap(), + ); } instructions @@ -238,6 +255,7 @@ pub enum RpcBench { ProgramAccounts, TokenAccountsByOwner, FirstAvailableBlock, + TokenAccountsByDelegate, } #[derive(Debug)] @@ -253,6 +271,7 @@ impl FromStr for RpcBench { "first-available-block" => Ok(RpcBench::FirstAvailableBlock), "slot" => Ok(RpcBench::Slot), "multiple-accounts" => Ok(RpcBench::MultipleAccounts), + "token-accounts-by-delegate" => Ok(RpcBench::TokenAccountsByDelegate), "token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner), "version" => Ok(RpcBench::Version), _ => Err(RpcParseError::InvalidOption), @@ -337,8 +356,37 @@ fn run_rpc_bench_loop( let mut iters = 0; let mut last_error = Instant::now(); let mut last_print = Instant::now(); + fn flush_stats( + iters: &i32, + last_print: &mut Instant, + rpc_bench: &RpcBench, + stats: &mut RpcBenchStats, + thread: &usize, + ) { + info!( + "t({}) rpc({:?}) iters: {} success: {} errors: {}", + thread, rpc_bench, iters, stats.success, stats.errors + ); + if stats.success > 0 { + info!( + " t({}) rpc({:?} average success_time: {} us", + thread, + rpc_bench, + stats.total_success_time_us / stats.success + ); + } + if stats.errors > 0 { + info!( + " rpc average average errors time: {} us", + stats.total_errors_time_us / stats.errors + ); + } + *last_print = Instant::now(); + *stats = RpcBenchStats::default(); + } loop { if exit.load(Ordering::Relaxed) { + flush_stats(&iters, &mut last_print, &rpc_bench, &mut stats, &thread); break; } match rpc_bench { @@ -413,10 +461,30 @@ fn run_rpc_bench_loop( } } } + RpcBench::TokenAccountsByDelegate => { + let mut rpc_time = Measure::start("rpc-get-token-accounts-by-delegate"); + let filter = TokenAccountsFilter::Mint(*mint.as_ref().unwrap()); + match client.get_token_accounts_by_delegate(base_keypair_pubkey, filter) { + Ok(_accounts) => { + rpc_time.stop(); + stats.success += 1; + stats.total_success_time_us += rpc_time.as_us(); + } + Err(e) => { + rpc_time.stop(); + stats.errors += 1; + stats.total_errors_time_us += rpc_time.as_us(); + if last_error.elapsed().as_secs() > 2 { + info!("get-token-accounts-by-delegate error: {:?}", e); + last_error = Instant::now(); + } + } + } + } RpcBench::TokenAccountsByOwner => { let mut rpc_time = Measure::start("rpc-get-token-accounts-by-owner"); let filter = TokenAccountsFilter::Mint(*mint.as_ref().unwrap()); - match client.get_token_accounts_by_owner(program_id, filter) { + match client.get_token_accounts_by_owner(base_keypair_pubkey, filter) { Ok(_accounts) => { rpc_time.stop(); stats.success += 1; @@ -427,7 +495,7 @@ fn run_rpc_bench_loop( stats.errors += 1; stats.total_errors_time_us += rpc_time.as_us(); if last_error.elapsed().as_secs() > 2 { - info!("get-token-accounts error: {:?}", e); + info!("get-token-accounts-by-owner error: {:?}", e); last_error = Instant::now(); } } @@ -451,26 +519,7 @@ fn run_rpc_bench_loop( } if last_print.elapsed().as_secs() > 3 { - info!( - "t({}) rpc({:?}) iters: {} success: {} errors: {}", - thread, rpc_bench, iters, stats.success, stats.errors - ); - if stats.success > 0 { - info!( - " t({}) rpc({:?} average success_time: {} us", - thread, - rpc_bench, - stats.total_success_time_us / stats.success - ); - } - if stats.errors > 0 { - info!( - " rpc average average errors time: {} us", - stats.total_errors_time_us / stats.errors - ); - } - last_print = Instant::now(); - stats = RpcBenchStats::default(); + flush_stats(&iters, &mut last_print, &rpc_bench, &mut stats, &thread); } iters += 1; @@ -871,6 +920,7 @@ fn main() { .long("space") .takes_value(true) .value_name("BYTES") + .conflicts_with("mint") .help("Size of accounts to create"), ) .arg( @@ -960,6 +1010,9 @@ fn main() { .takes_value(true) .value_name("RPC_BENCH_TYPE(S)") .multiple(true) + .requires_ifs(&[ + ("token-accounts-by-owner", "mint"), + ]) .help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"), ) .get_matches(); diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index 01ee8c879d22d8..ef03192576f6a1 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -44,6 +44,7 @@ use { solana_svm_transaction::svm_message::SVMMessage, solana_timings::ExecuteTimings, std::{ + num::Saturating, sync::{atomic::Ordering, Arc}, time::Instant, }, @@ -792,10 +793,11 @@ impl Consumer { (0, 0), |(units, times), program_timings| { ( - units - .saturating_add(program_timings.accumulated_units) - .saturating_add(program_timings.total_errored_units), - times.saturating_add(program_timings.accumulated_us), + (Saturating(units) + + program_timings.accumulated_units + + program_timings.total_errored_units) + .0, + (Saturating(times) + program_timings.accumulated_us).0, ) }, ) @@ -2522,11 +2524,11 @@ mod tests { execute_timings.details.per_program_timings.insert( Pubkey::new_unique(), ProgramTiming { - accumulated_us: n * 100, - accumulated_units: n * 1000, - count: n as u32, + accumulated_us: Saturating(n * 100), + accumulated_units: Saturating(n * 1000), + count: Saturating(n as u32), errored_txs_compute_consumed: vec![], - total_errored_units: 0, + total_errored_units: Saturating(0), }, ); expected_us += n * 100; diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 6d259b2e73a571..77a7193135f226 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1775,6 +1775,15 @@ impl Blockstore { &shred, duplicate_shreds, ) { + // This indicates there is an alternate version of this block. + // Similar to the last index case above, we might never get all the + // shreds for our current version, never replay this slot, and make no + // progress. We cannot determine if we have the version that will eventually + // be complete, so we take the conservative approach and mark the slot as dead + // so that replay can dump and repair the correct version. + self.dead_slots_cf + .put_in_batch(write_batch, slot, &true) + .unwrap(); return Err(InsertDataShredError::InvalidShred); } } @@ -5981,21 +5990,6 @@ pub mod tests { .insert_shreds(shreds, None, false) .expect("Expected successful write of shreds"); - let mut shreds1 = entries_to_test_shreds( - &entries[4..], - 1, - 0, - false, - 0, - false, // merkle_variant - ); - for (i, b) in shreds1.iter_mut().enumerate() { - b.set_index(8 + i as u32); - } - blockstore - .insert_shreds(shreds1, None, false) - .expect("Expected successful write of shreds"); - assert_eq!( blockstore.get_slot_entries(1, 0).unwrap()[2..4], entries[2..4], @@ -7827,12 +7821,13 @@ pub mod tests { ) .is_err()); let ShredInsertionTracker { - ref merkle_root_metas, - ref duplicate_shreds, + merkle_root_metas, + duplicate_shreds, + write_batch, .. } = shred_insertion_tracker; - // No insert, notify duplicate + // No insert, notify duplicate, and block is dead assert_eq!(duplicate_shreds.len(), 1); assert_matches!( duplicate_shreds[0], @@ -7858,6 +7853,11 @@ pub mod tests { index ); + // Block is now dead + blockstore.db.write(write_batch).unwrap(); + assert!(blockstore.is_dead(slot)); + blockstore.remove_dead_slot(slot).unwrap(); + // Blockstore should also have the merkle root meta of the original shred assert_eq!( blockstore @@ -7889,6 +7889,8 @@ pub mod tests { fec_set_index + 30, ); + let mut shred_insertion_tracker = + ShredInsertionTracker::new(data_shreds.len(), blockstore.db.batch().unwrap()); blockstore .check_insert_data_shred( new_data_shred.clone(), @@ -7899,25 +7901,29 @@ pub mod tests { ) .unwrap(); let ShredInsertionTracker { - merkle_root_metas, .. + merkle_root_metas, + write_batch, + .. } = shred_insertion_tracker; + blockstore.db.write(write_batch).unwrap(); // Verify that we still have the merkle root meta for the original shred // and the new shred - assert_eq!(merkle_root_metas.len(), 2); assert_eq!( - merkle_root_metas - .get(&data_shred.erasure_set()) + blockstore + .merkle_root_meta(data_shred.erasure_set()) .unwrap() .as_ref() + .unwrap() .merkle_root(), data_shred.merkle_root().ok() ); assert_eq!( - merkle_root_metas - .get(&data_shred.erasure_set()) + blockstore + .merkle_root_meta(data_shred.erasure_set()) .unwrap() .as_ref() + .unwrap() .first_received_shred_index(), index ); diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 14608974d4c16b..0aa1f70c0c999c 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -1446,10 +1446,10 @@ impl ReplaySlotStats { (0, 0, 0, 0, 0), |(sum_us, sum_units, sum_count, sum_errored_units, sum_errored_count), a| { ( - sum_us + a.1.accumulated_us, - sum_units + a.1.accumulated_units, - sum_count + a.1.count, - sum_errored_units + a.1.total_errored_units, + sum_us + a.1.accumulated_us.0, + sum_units + a.1.accumulated_units.0, + sum_count + a.1.count.0, + sum_errored_units + a.1.total_errored_units.0, sum_errored_count + a.1.errored_txs_compute_consumed.len(), ) }, @@ -1460,10 +1460,10 @@ impl ReplaySlotStats { "per_program_timings", ("slot", slot as i64, i64), ("pubkey", pubkey.to_string(), String), - ("execute_us", time.accumulated_us, i64), - ("accumulated_units", time.accumulated_units, i64), - ("errored_units", time.total_errored_units, i64), - ("count", time.count, i64), + ("execute_us", time.accumulated_us.0, i64), + ("accumulated_units", time.accumulated_units.0, i64), + ("errored_units", time.total_errored_units.0, i64), + ("count", time.count.0, i64), ( "errored_count", time.errored_txs_compute_consumed.len(), diff --git a/perf/Cargo.toml b/perf/Cargo.toml index 4af056343ba218..bf41c12bb99507 100644 --- a/perf/Cargo.toml +++ b/perf/Cargo.toml @@ -21,6 +21,7 @@ log = { workspace = true } rand = { workspace = true } rayon = { workspace = true } serde = { workspace = true } +solana-clock = { workspace = true, optional = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", ] } @@ -28,15 +29,20 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } solana-hash = { workspace = true } +solana-keypair = { workspace = true, optional = true } +solana-message = { workspace = true } solana-metrics = { workspace = true } solana-packet = { workspace = true, features = ["bincode"] } -solana-program = { workspace = true, default-features = false } solana-pubkey = { workspace = true, default-features = false } solana-rayon-threadlimit = { workspace = true } -solana-sdk = { workspace = true, optional = true } +solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true } solana-signature = { workspace = true, features = ["verify"] } +solana-signer = { workspace = true, optional = true } +solana-system-interface = { workspace = true, optional = true } +solana-system-transaction = { workspace = true, optional = true } solana-time-utils = { workspace = true } +solana-transaction = { workspace = true, optional = true } solana-vote-program = { workspace = true, optional = true } [target."cfg(target_os = \"linux\")".dependencies] @@ -55,13 +61,20 @@ solana-perf = { path = ".", features = ["dev-context-only-utils"] } test-case = { workspace = true } [features] -dev-context-only-utils = ["dep:solana-vote-program", "dep:solana-sdk"] +dev-context-only-utils = [ + "dep:solana-clock", + "dep:solana-keypair", + "dep:solana-signer", + "dep:solana-system-interface", + "dep:solana-system-transaction", + "dep:solana-transaction", + "dep:solana-vote-program", +] frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", - "solana-sdk/frozen-abi", "solana-short-vec/frozen-abi", - "solana-vote-program/frozen-abi" + "solana-vote-program/frozen-abi", ] [[bench]] diff --git a/perf/src/packet.rs b/perf/src/packet.rs index 73c29bc53788a9..650fb4cb8c5198 100644 --- a/perf/src/packet.rs +++ b/perf/src/packet.rs @@ -248,19 +248,15 @@ where #[cfg(test)] mod tests { use { - super::*, - solana_hash::Hash, - solana_sdk::{ - signature::{Keypair, Signer}, - system_transaction, - }, + super::*, solana_hash::Hash, solana_keypair::Keypair, solana_signer::Signer, + solana_system_transaction::transfer, }; #[test] fn test_to_packet_batches() { let keypair = Keypair::new(); let hash = Hash::new_from_array([1; 32]); - let tx = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, hash); + let tx = transfer(&keypair, &keypair.pubkey(), 1, hash); let rv = to_packet_batches_for_tests(&[tx.clone(); 1]); assert_eq!(rv.len(), 1); assert_eq!(rv[0].len(), 1); diff --git a/perf/src/sigverify.rs b/perf/src/sigverify.rs index eff58d2cdf7b2d..5394d0462b263f 100644 --- a/perf/src/sigverify.rs +++ b/perf/src/sigverify.rs @@ -12,7 +12,7 @@ use { }, rayon::{prelude::*, ThreadPool}, solana_hash::Hash, - solana_program::message::{MESSAGE_HEADER_LENGTH, MESSAGE_VERSION_PREFIX}, + solana_message::{MESSAGE_HEADER_LENGTH, MESSAGE_VERSION_PREFIX}, solana_pubkey::Pubkey, solana_rayon_threadlimit::get_thread_count, solana_short_vec::decode_shortu16_len, @@ -415,7 +415,7 @@ fn check_for_simple_vote_transaction( if packet .data(instruction_program_id_start..instruction_program_id_end) .ok_or(PacketError::InvalidLen)? - == solana_program::vote::program::id().as_ref() + == solana_sdk_ids::vote::id().as_ref() { packet.meta_mut().flags |= PacketFlags::SIMPLE_VOTE_TX; } @@ -675,15 +675,11 @@ mod tests { bincode::{deserialize, serialize}, curve25519_dalek::{edwards::CompressedEdwardsY, scalar::Scalar}, rand::{thread_rng, Rng}, - solana_program::{ - instruction::CompiledInstruction, - message::{Message, MessageHeader}, - }, - solana_sdk::{ - signature::{Keypair, Signer}, - transaction::Transaction, - }, + solana_keypair::Keypair, + solana_message::{compiled_instruction::CompiledInstruction, Message, MessageHeader}, solana_signature::Signature, + solana_signer::Signer, + solana_transaction::Transaction, std::{ iter::repeat_with, sync::atomic::{AtomicU64, Ordering}, diff --git a/perf/src/test_tx.rs b/perf/src/test_tx.rs index 118f8de15b4217..e6979fee8263b1 100644 --- a/perf/src/test_tx.rs +++ b/perf/src/test_tx.rs @@ -1,15 +1,13 @@ use { rand::{CryptoRng, Rng, RngCore}, - solana_sdk::{ - clock::Slot, - hash::Hash, - instruction::CompiledInstruction, - signature::{Keypair, Signer}, - stake, - system_instruction::SystemInstruction, - system_program, system_transaction, - transaction::Transaction, - }, + solana_clock::Slot, + solana_hash::Hash, + solana_keypair::Keypair, + solana_message::compiled_instruction::CompiledInstruction, + solana_sdk_ids::{stake, system_program}, + solana_signer::Signer, + solana_system_interface::instruction::SystemInstruction, + solana_transaction::Transaction, solana_vote_program::{vote_state::TowerSync, vote_transaction}, }; @@ -17,7 +15,7 @@ pub fn test_tx() -> Transaction { let keypair1 = Keypair::new(); let pubkey1 = keypair1.pubkey(); let zero = Hash::default(); - system_transaction::transfer(&keypair1, &pubkey1, 42, zero) + solana_system_transaction::transfer(&keypair1, &pubkey1, 42, zero) } pub fn test_invalid_tx() -> Transaction { @@ -35,7 +33,7 @@ pub fn test_multisig_tx() -> Transaction { let transfer_instruction = SystemInstruction::Transfer { lamports }; - let program_ids = vec![system_program::id(), stake::program::id()]; + let program_ids = vec![system_program::id(), stake::id()]; let instructions = vec![CompiledInstruction::new( 0, diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml index b3a6228cee1be7..0cb6a7207b6af8 100644 --- a/program-runtime/Cargo.toml +++ b/program-runtime/Cargo.toml @@ -21,7 +21,11 @@ num-traits = { workspace = true } percentage = { workspace = true } rand = { workspace = true } serde = { workspace = true } +solana-account = { workspace = true, features = ["bincode"] } +solana-clock = { workspace = true } solana-compute-budget = { workspace = true } +solana-epoch-rewards = { workspace = true } +solana-epoch-schedule = { workspace = true } solana-feature-set = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", @@ -29,19 +33,34 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } +solana-hash = { workspace = true } +solana-instruction = { workspace = true } +solana-last-restart-slot = { workspace = true } solana-log-collector = { workspace = true } solana-measure = { workspace = true } solana-metrics = { workspace = true } -solana-sdk = { workspace = true } +solana-precompiles = { workspace = true } +solana-pubkey = { workspace = true } +solana-rent = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-slot-hashes = { workspace = true } +solana-stable-layout = { workspace = true } +solana-sysvar = { workspace = true } +solana-sysvar-id = { workspace = true } solana-timings = { workspace = true } +solana-transaction-context = { workspace = true } solana-type-overrides = { workspace = true } solana_rbpf = { workspace = true } thiserror = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } +solana-instruction = { workspace = true, features = ["bincode"] } solana-logger = { workspace = true } -solana-sdk = { workspace = true, features = ["dev-context-only-utils"] } +solana-pubkey = { workspace = true, features = ["rand"] } +solana-transaction-context = { workspace = true, features = [ + "dev-context-only-utils", +] } test-case = { workspace = true } [lib] @@ -56,9 +75,11 @@ frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "solana-compute-budget/frozen-abi", - "solana-sdk/frozen-abi", ] -shuttle-test = ["solana-type-overrides/shuttle-test", "solana_rbpf/shuttle-test"] +shuttle-test = [ + "solana-type-overrides/shuttle-test", + "solana_rbpf/shuttle-test", +] [lints] workspace = true diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index f6e0e4630a8d3f..db6486a6194dd6 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -7,13 +7,20 @@ use { stable_log, sysvar_cache::SysvarCache, }, + solana_account::{create_account_shared_data_for_test, AccountSharedData}, + solana_clock::Slot, solana_compute_budget::compute_budget::ComputeBudget, + solana_epoch_schedule::EpochSchedule, solana_feature_set::{ lift_cpi_caller_restriction, move_precompile_verification_to_svm, remove_accounts_executable_flag_checks, FeatureSet, }, + solana_hash::Hash, + solana_instruction::{error::InstructionError, AccountMeta}, solana_log_collector::{ic_msg, LogCollector}, solana_measure::measure::Measure, + solana_precompiles::Precompile, + solana_pubkey::Pubkey, solana_rbpf::{ ebpf::MM_HEAP_START, error::{EbpfError, ProgramResult}, @@ -21,24 +28,12 @@ use { program::{BuiltinFunction, SBPFVersion}, vm::{Config, ContextObject, EbpfVm}, }, - solana_sdk::{ - account::{create_account_shared_data_for_test, AccountSharedData}, - bpf_loader_deprecated, - clock::Slot, - epoch_schedule::EpochSchedule, - hash::Hash, - instruction::{AccountMeta, InstructionError}, - native_loader, - precompiles::Precompile, - pubkey::Pubkey, - saturating_add_assign, - stable_layout::stable_instruction::StableInstruction, - sysvar, - transaction_context::{ - IndexOfAccount, InstructionAccount, TransactionAccount, TransactionContext, - }, - }, + solana_sdk_ids::{bpf_loader_deprecated, native_loader, sysvar}, + solana_stable_layout::stable_instruction::StableInstruction, solana_timings::{ExecuteDetailsTimings, ExecuteTimings}, + solana_transaction_context::{ + IndexOfAccount, InstructionAccount, TransactionAccount, TransactionContext, + }, solana_type_overrides::sync::{atomic::Ordering, Arc}, std::{ alloc::Layout, @@ -67,7 +62,7 @@ macro_rules! declare_process_instruction { ) -> std::result::Result> { fn process_instruction_inner( $invoke_context: &mut $crate::invoke_context::InvokeContext, - ) -> std::result::Result<(), solana_sdk::instruction::InstructionError> + ) -> std::result::Result<(), $crate::__private::InstructionError> $inner let consumption_result = if $cu_to_consume > 0 @@ -300,7 +295,7 @@ impl<'a> InvokeContext<'a> { } /// Current height of the invocation stack, top level instructions are height - /// `solana_sdk::instruction::TRANSACTION_LEVEL_STACK_HEIGHT` + /// `solana_instruction::TRANSACTION_LEVEL_STACK_HEIGHT` pub fn get_stack_height(&self) -> usize { self.transaction_context .get_instruction_context_stack_height() @@ -601,13 +596,10 @@ impl<'a> InvokeContext<'a> { return Err(InstructionError::BuiltinProgramsMustConsumeComputeUnits); } - saturating_add_assign!( - timings - .execute_accessories - .process_instructions - .process_executable_chain_us, - process_executable_chain_time.end_as_us() - ); + timings + .execute_accessories + .process_instructions + .process_executable_chain_us += process_executable_chain_time.end_as_us(); result } @@ -727,12 +719,9 @@ macro_rules! with_mock_invoke_context { solana_compute_budget::compute_budget::ComputeBudget, solana_feature_set::FeatureSet, solana_log_collector::LogCollector, - solana_sdk::{ - account::ReadableAccount, hash::Hash, sysvar::rent::Rent, - transaction_context::TransactionContext, - }, solana_type_overrides::sync::Arc, $crate::{ + __private::{Hash, ReadableAccount, Rent, TransactionContext}, invoke_context::{EnvironmentConfig, InvokeContext}, loaded_programs::ProgramCacheForTxBatch, sysvar_cache::SysvarCache, @@ -864,8 +853,10 @@ mod tests { use { super::*, serde::{Deserialize, Serialize}, + solana_account::WritableAccount, solana_compute_budget::compute_budget_limits, - solana_sdk::{account::WritableAccount, instruction::Instruction, rent::Rent}, + solana_instruction::Instruction, + solana_rent::Rent, }; #[derive(Debug, Serialize, Deserialize)] @@ -997,9 +988,9 @@ mod tests { let mut transaction_accounts = vec![]; let mut instruction_accounts = vec![]; for index in 0..one_more_than_max_depth { - invoke_stack.push(solana_sdk::pubkey::new_rand()); + invoke_stack.push(solana_pubkey::new_rand()); transaction_accounts.push(( - solana_sdk::pubkey::new_rand(), + solana_pubkey::new_rand(), AccountSharedData::new(index as u64, 1, invoke_stack.get(index).unwrap()), )); instruction_accounts.push(InstructionAccount { @@ -1013,7 +1004,7 @@ mod tests { for (index, program_id) in invoke_stack.iter().enumerate() { transaction_accounts.push(( *program_id, - AccountSharedData::new(1, 1, &solana_sdk::pubkey::Pubkey::default()), + AccountSharedData::new(1, 1, &solana_pubkey::Pubkey::default()), )); instruction_accounts.push(InstructionAccount { index_in_transaction: index as IndexOfAccount, @@ -1063,19 +1054,19 @@ mod tests { #[test] fn test_process_instruction() { - let callee_program_id = solana_sdk::pubkey::new_rand(); + let callee_program_id = solana_pubkey::new_rand(); let owned_account = AccountSharedData::new(42, 1, &callee_program_id); - let not_owned_account = AccountSharedData::new(84, 1, &solana_sdk::pubkey::new_rand()); - let readonly_account = AccountSharedData::new(168, 1, &solana_sdk::pubkey::new_rand()); + let not_owned_account = AccountSharedData::new(84, 1, &solana_pubkey::new_rand()); + let readonly_account = AccountSharedData::new(168, 1, &solana_pubkey::new_rand()); let loader_account = AccountSharedData::new(0, 1, &native_loader::id()); let mut program_account = AccountSharedData::new(1, 1, &native_loader::id()); program_account.set_executable(true); let transaction_accounts = vec![ - (solana_sdk::pubkey::new_rand(), owned_account), - (solana_sdk::pubkey::new_rand(), not_owned_account), - (solana_sdk::pubkey::new_rand(), readonly_account), + (solana_pubkey::new_rand(), owned_account), + (solana_pubkey::new_rand(), not_owned_account), + (solana_pubkey::new_rand(), readonly_account), (callee_program_id, program_account), - (solana_sdk::pubkey::new_rand(), loader_account), + (solana_pubkey::new_rand(), loader_account), ]; let metas = vec![ AccountMeta::new(transaction_accounts.first().unwrap().0, false), @@ -1187,8 +1178,7 @@ mod tests { #[test] fn test_invoke_context_compute_budget() { - let transaction_accounts = - vec![(solana_sdk::pubkey::new_rand(), AccountSharedData::default())]; + let transaction_accounts = vec![(solana_pubkey::new_rand(), AccountSharedData::default())]; with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts); invoke_context.compute_budget = ComputeBudget::new( diff --git a/program-runtime/src/lib.rs b/program-runtime/src/lib.rs index 3a690d1d0824e9..974ecee64f94d4 100644 --- a/program-runtime/src/lib.rs +++ b/program-runtime/src/lib.rs @@ -11,3 +11,11 @@ pub mod loaded_programs; pub mod mem_pool; pub mod stable_log; pub mod sysvar_cache; +// re-exports for macros +pub mod __private { + pub use { + solana_account::ReadableAccount, solana_hash::Hash, + solana_instruction::error::InstructionError, solana_rent::Rent, + solana_transaction_context::TransactionContext, + }; +} diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index f8a0f2534b472f..9e11477ea897bb 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -2,19 +2,17 @@ use { crate::invoke_context::{BuiltinFunctionWithContext, InvokeContext}, log::{debug, error, log_enabled, trace}, percentage::PercentageInteger, + solana_clock::{Epoch, Slot}, solana_measure::measure::Measure, + solana_pubkey::Pubkey, solana_rbpf::{ elf::Executable, program::{BuiltinProgram, FunctionRegistry}, verifier::RequisiteVerifier, vm::Config, }, - solana_sdk::{ - bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, - clock::{Epoch, Slot}, - loader_v4, native_loader, - pubkey::Pubkey, - saturating_add_assign, + solana_sdk_ids::{ + bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, loader_v4, native_loader, }, solana_timings::ExecuteDetailsTimings, solana_type_overrides::{ @@ -289,13 +287,10 @@ pub struct LoadProgramMetrics { impl LoadProgramMetrics { pub fn submit_datapoint(&self, timings: &mut ExecuteDetailsTimings) { - saturating_add_assign!( - timings.create_executor_register_syscalls_us, - self.register_syscalls_us - ); - saturating_add_assign!(timings.create_executor_load_elf_us, self.load_elf_us); - saturating_add_assign!(timings.create_executor_verify_code_us, self.verify_code_us); - saturating_add_assign!(timings.create_executor_jit_compile_us, self.jit_compile_us); + timings.create_executor_register_syscalls_us += self.register_syscalls_us; + timings.create_executor_load_elf_us += self.load_elf_us; + timings.create_executor_verify_code_us += self.verify_code_us; + timings.create_executor_jit_compile_us += self.jit_compile_us; datapoint_trace!( "create_executor_trace", ("program_id", self.program_id, String), @@ -1314,7 +1309,7 @@ impl ProgramCache { self.stats .evictions .entry(*program) - .and_modify(|c| saturating_add_assign!(*c, 1)) + .and_modify(|c| *c = c.saturating_add(1)) .or_insert(1); *candidate = Arc::new(unloaded); } @@ -1373,8 +1368,9 @@ mod tests { }, assert_matches::assert_matches, percentage::Percentage, + solana_clock::Slot, + solana_pubkey::Pubkey, solana_rbpf::{elf::Executable, program::BuiltinProgram}, - solana_sdk::{clock::Slot, pubkey::Pubkey}, std::{ fs::File, io::Read, diff --git a/program-runtime/src/stable_log.rs b/program-runtime/src/stable_log.rs index 134c7f4f883f59..777247f29e3db0 100644 --- a/program-runtime/src/stable_log.rs +++ b/program-runtime/src/stable_log.rs @@ -6,7 +6,7 @@ use { base64::{prelude::BASE64_STANDARD, Engine}, itertools::Itertools, solana_log_collector::{ic_logger_msg, LogCollector}, - solana_sdk::pubkey::Pubkey, + solana_pubkey::Pubkey, std::{cell::RefCell, rc::Rc}, }; diff --git a/program-runtime/src/sysvar_cache.rs b/program-runtime/src/sysvar_cache.rs index 76496ce9ed69b4..da8746088d0f16 100644 --- a/program-runtime/src/sysvar_cache.rs +++ b/program-runtime/src/sysvar_cache.rs @@ -1,18 +1,20 @@ #[allow(deprecated)] -use solana_sdk::sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes}; +use solana_sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes}; use { crate::invoke_context::InvokeContext, serde::de::DeserializeOwned, - solana_sdk::{ - instruction::InstructionError, - pubkey::Pubkey, - sysvar::{ - self, clock::Clock, epoch_rewards::EpochRewards, epoch_schedule::EpochSchedule, - last_restart_slot::LastRestartSlot, rent::Rent, slot_hashes::SlotHashes, - stake_history::StakeHistory, Sysvar, SysvarId, - }, - transaction_context::{IndexOfAccount, InstructionContext, TransactionContext}, - }, + solana_clock::Clock, + solana_epoch_rewards::EpochRewards, + solana_epoch_schedule::EpochSchedule, + solana_instruction::error::InstructionError, + solana_last_restart_slot::LastRestartSlot, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_sdk_ids::sysvar, + solana_slot_hashes::SlotHashes, + solana_sysvar::{stake_history::StakeHistory, Sysvar}, + solana_sysvar_id::SysvarId, + solana_transaction_context::{IndexOfAccount, InstructionContext, TransactionContext}, solana_type_overrides::sync::Arc, }; diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index da9ca7887ae7bf..7dbc8cdb3e1ec9 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -43,7 +43,6 @@ use { loader_v4, native_loader, program_utils::limited_deserialize, pubkey::Pubkey, - saturating_add_assign, system_instruction::{self, MAX_PERMITTED_DATA_LENGTH}, transaction_context::{IndexOfAccount, InstructionContext, TransactionContext}, }, @@ -469,10 +468,7 @@ pub fn process_instruction_inner( })?; drop(program_account); get_or_create_executor_time.stop(); - saturating_add_assign!( - invoke_context.timings.get_or_create_executor_us, - get_or_create_executor_time.as_us() - ); + invoke_context.timings.get_or_create_executor_us += get_or_create_executor_time.as_us(); executor.ix_usage_counter.fetch_add(1, Ordering::Relaxed); match &executor.program { @@ -1452,7 +1448,7 @@ pub fn execute<'a, 'b: 'a>( drop(vm); if let Some(execute_time) = invoke_context.execute_time.as_mut() { execute_time.stop(); - saturating_add_assign!(invoke_context.timings.execute_us, execute_time.as_us()); + invoke_context.timings.execute_us += execute_time.as_us(); } ic_logger_msg!( @@ -1567,12 +1563,9 @@ pub fn execute<'a, 'b: 'a>( deserialize_time.stop(); // Update the timings - saturating_add_assign!(invoke_context.timings.serialize_us, serialize_time.as_us()); - saturating_add_assign!(invoke_context.timings.create_vm_us, create_vm_time.as_us()); - saturating_add_assign!( - invoke_context.timings.deserialize_us, - deserialize_time.as_us() - ); + invoke_context.timings.serialize_us += serialize_time.as_us(); + invoke_context.timings.create_vm_us += create_vm_time.as_us(); + invoke_context.timings.deserialize_us += deserialize_time.as_us(); execute_or_deserialize_result } diff --git a/programs/bpf_loader/src/syscalls/cpi.rs b/programs/bpf_loader/src/syscalls/cpi.rs index 6886723afe97e4..bb0179da75d14c 100644 --- a/programs/bpf_loader/src/syscalls/cpi.rs +++ b/programs/bpf_loader/src/syscalls/cpi.rs @@ -10,7 +10,6 @@ use { memory_region::{MemoryRegion, MemoryState}, }, solana_sdk::{ - saturating_add_assign, stable_layout::stable_instruction::StableInstruction, syscalls::{ MAX_CPI_ACCOUNT_INFOS, MAX_CPI_INSTRUCTION_ACCOUNTS, MAX_CPI_INSTRUCTION_DATA_LEN, @@ -1087,7 +1086,7 @@ fn cpi_common( )?; if let Some(execute_time) = invoke_context.execute_time.as_mut() { execute_time.stop(); - saturating_add_assign!(invoke_context.timings.execute_us, execute_time.as_us()); + invoke_context.timings.execute_us += execute_time.as_us(); } let instruction = S::translate_instruction(instruction_addr, memory_mapping, invoke_context)?; diff --git a/programs/loader-v4/src/lib.rs b/programs/loader-v4/src/lib.rs index 417e1b1539866d..78033323e2a1e7 100644 --- a/programs/loader-v4/src/lib.rs +++ b/programs/loader-v4/src/lib.rs @@ -13,7 +13,6 @@ use { loader_v4_instruction::LoaderV4Instruction, program_utils::limited_deserialize, pubkey::Pubkey, - saturating_add_assign, transaction_context::{BorrowedAccount, InstructionContext}, }, solana_type_overrides::sync::{atomic::Ordering, Arc}, @@ -456,10 +455,7 @@ pub fn process_instruction_inner( InstructionError::UnsupportedProgramId })?; get_or_create_executor_time.stop(); - saturating_add_assign!( - invoke_context.timings.get_or_create_executor_us, - get_or_create_executor_time.as_us() - ); + invoke_context.timings.get_or_create_executor_us += get_or_create_executor_time.as_us(); drop(program); loaded_program .ix_usage_counter diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index e33cf437905ca9..872079f4dd9245 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -6100,11 +6100,12 @@ dependencies = [ "rayon", "serde", "solana-hash", + "solana-message", "solana-metrics", "solana-packet", - "solana-program", "solana-pubkey", "solana-rayon-threadlimit", + "solana-sdk-ids", "solana-short-vec", "solana-signature", "solana-time-utils", @@ -6302,13 +6303,28 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "thiserror 2.0.4", @@ -6573,9 +6589,21 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "solana-account", "solana-account-decoder-client-types", + "solana-clock", + "solana-commitment-config", + "solana-epoch-info", + "solana-epoch-schedule", + "solana-feature-gate-interface", + "solana-hash", + "solana-instruction", + "solana-message", + "solana-pubkey", "solana-rpc-client-api", - "solana-sdk", + "solana-signature", + "solana-transaction", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-version", "tokio", @@ -7811,7 +7839,7 @@ version = "2.2.0" dependencies = [ "eager", "enum-iterator", - "solana-sdk", + "solana-pubkey", ] [[package]] diff --git a/rpc-client-nonce-utils/Cargo.toml b/rpc-client-nonce-utils/Cargo.toml index 0c861a54bdd92b..e3ebdfea412735 100644 --- a/rpc-client-nonce-utils/Cargo.toml +++ b/rpc-client-nonce-utils/Cargo.toml @@ -11,12 +11,12 @@ edition = { workspace = true } [dependencies] clap = { version = "2.33.0", optional = true } -solana-account = { workspace = true } +solana-account = { workspace = true, features = ["bincode"] } solana-clap-utils = { workspace = true, optional = true } solana-commitment-config = { workspace = true } solana-hash = { workspace = true } solana-message = { workspace = true } -solana-nonce = { workspace = true } +solana-nonce = { workspace = true, features = ["serde"] } solana-pubkey = { workspace = true } solana-rpc-client = { workspace = true } solana-sdk-ids = { workspace = true } diff --git a/rpc-client/Cargo.toml b/rpc-client/Cargo.toml index bb5adfef1d36c2..e26ca3b539eaa9 100644 --- a/rpc-client/Cargo.toml +++ b/rpc-client/Cargo.toml @@ -22,9 +22,21 @@ semver = { workspace = true } serde = { workspace = true } serde_derive = { workspace = true } serde_json = { workspace = true } +solana-account = { workspace = true } solana-account-decoder-client-types = { workspace = true, features = ["zstd"] } +solana-clock = { workspace = true } +solana-commitment-config = { workspace = true } +solana-epoch-info = { workspace = true, features = ["serde"] } +solana-epoch-schedule = { workspace = true, features = ["serde"] } +solana-feature-gate-interface = { workspace = true, features = ["serde"] } +solana-hash = { workspace = true } +solana-instruction = { workspace = true } +solana-message = { workspace = true } +solana-pubkey = { workspace = true } solana-rpc-client-api = { workspace = true } -solana-sdk = { workspace = true } +solana-signature = { workspace = true } +solana-transaction = { workspace = true, features = ["bincode"] } +solana-transaction-error = { workspace = true } solana-transaction-status-client-types = { workspace = true } solana-version = { workspace = true } tokio = { workspace = true, features = ["full"] } @@ -36,6 +48,11 @@ futures = { workspace = true } jsonrpc-core = { workspace = true } jsonrpc-http-server = { workspace = true } solana-account-decoder = { workspace = true } +solana-keypair = { workspace = true } +solana-program = { workspace = true, default-features = false } +solana-signer = { workspace = true } +solana-system-transaction = { workspace = true } +static_assertions = { workspace = true } [features] default = ["spinner"] diff --git a/rpc-client/src/mock_sender.rs b/rpc-client/src/mock_sender.rs index 92e384ecc89a94..c81a6afe042bc8 100644 --- a/rpc-client/src/mock_sender.rs +++ b/rpc-client/src/mock_sender.rs @@ -6,6 +6,12 @@ use { base64::{prelude::BASE64_STANDARD, Engine}, serde_json::{json, Number, Value}, solana_account_decoder_client_types::{UiAccount, UiAccountData, UiAccountEncoding}, + solana_clock::{Slot, UnixTimestamp}, + solana_epoch_info::EpochInfo, + solana_epoch_schedule::EpochSchedule, + solana_instruction::error::InstructionError, + solana_message::MessageHeader, + solana_pubkey::Pubkey, solana_rpc_client_api::{ client_error::Result, config::RpcBlockProductionConfig, @@ -19,16 +25,9 @@ use { RpcVoteAccountStatus, }, }, - solana_sdk::{ - clock::{Slot, UnixTimestamp}, - epoch_info::EpochInfo, - instruction::InstructionError, - message::MessageHeader, - pubkey::Pubkey, - signature::Signature, - sysvar::epoch_schedule::EpochSchedule, - transaction::{self, Transaction, TransactionError, TransactionVersion}, - }, + solana_signature::Signature, + solana_transaction::{versioned::TransactionVersion, Transaction}, + solana_transaction_error::{TransactionError, TransactionResult}, solana_transaction_status_client_types::{ option_serializer::OptionSerializer, EncodedConfirmedBlock, EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction, @@ -124,7 +123,7 @@ impl RpcSender for MockSender { transaction_count: Some(123), })?, "getSignatureStatuses" => { - let status: transaction::Result<()> = if self.url == "account_in_use" { + let status: TransactionResult<()> = if self.url == "account_in_use" { Err(TransactionError::AccountInUse) } else if self.url == "instruction_error" { Err(TransactionError::InstructionError( @@ -455,7 +454,7 @@ pub(crate) fn mock_encoded_account(pubkey: &Pubkey) -> UiAccount { #[cfg(test)] mod tests { - use {super::*, solana_account_decoder::encode_ui_account, solana_sdk::account::Account}; + use {super::*, solana_account::Account, solana_account_decoder::encode_ui_account}; #[test] fn test_mock_encoded_account() { diff --git a/rpc-client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs index 33bf1c119bd2f5..7d509fc80f7bb3 100644 --- a/rpc-client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -8,7 +8,7 @@ pub use crate::mock_sender::Mocks; #[cfg(feature = "spinner")] -use {crate::spinner, solana_sdk::clock::MAX_HASH_AGE_IN_SECONDS, std::cmp::min}; +use {crate::spinner, solana_clock::MAX_HASH_AGE_IN_SECONDS, std::cmp::min}; use { crate::{ http_sender::HttpSender, @@ -23,10 +23,17 @@ use { bincode::serialize, log::*, serde_json::{json, Value}, + solana_account::Account, solana_account_decoder_client_types::{ token::{TokenAccountType, UiTokenAccount, UiTokenAmount}, UiAccount, UiAccountData, UiAccountEncoding, }, + solana_clock::{Epoch, Slot, UnixTimestamp, DEFAULT_MS_PER_SLOT}, + solana_commitment_config::CommitmentConfig, + solana_epoch_info::EpochInfo, + solana_epoch_schedule::EpochSchedule, + solana_hash::Hash, + solana_pubkey::Pubkey, solana_rpc_client_api::{ client_error::{ Error as ClientError, ErrorKind as ClientErrorKind, Result as ClientResult, @@ -35,18 +42,8 @@ use { request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, response::*, }, - solana_sdk::{ - account::Account, - clock::{Epoch, Slot, UnixTimestamp, DEFAULT_MS_PER_SLOT}, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - epoch_schedule::EpochSchedule, - hash::Hash, - pubkey::Pubkey, - signature::Signature, - transaction, - vote::state::MAX_LOCKOUT_HISTORY, - }, + solana_signature::Signature, + solana_transaction_error::TransactionResult, solana_transaction_status_client_types::{ EncodedConfirmedBlock, EncodedConfirmedTransactionWithStatusMeta, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, @@ -58,6 +55,13 @@ use { }, tokio::time::sleep, }; +// inlined to avoid a solana_program dep +const MAX_LOCKOUT_HISTORY: usize = 31; +#[cfg(test)] +static_assertions::const_assert_eq!( + MAX_LOCKOUT_HISTORY, + solana_program::vote::state::MAX_LOCKOUT_HISTORY +); /// A client of a remote Solana node. /// @@ -115,14 +119,15 @@ use { /// field, so it is common for the value to be accessed with `?.value`, as in /// /// ``` -/// # use solana_sdk::system_transaction; +/// # use solana_hash::Hash; +/// # use solana_system_transaction as system_transaction; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; -/// # use solana_sdk::signature::{Keypair, Signer}; -/// # use solana_sdk::hash::Hash; +/// # use solana_keypair::Keypair; +/// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let key = Keypair::new(); -/// # let to = solana_sdk::pubkey::new_rand(); +/// # let to = solana_pubkey::new_rand(); /// # let lamports = 50; /// # let latest_blockhash = Hash::default(); /// # let tx = system_transaction::transfer(&key, &to, lamports, latest_blockhash); @@ -193,7 +198,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let commitment_config = CommitmentConfig::processed(); @@ -244,7 +249,7 @@ impl RpcClient { /// ``` /// # use std::time::Duration; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let commitment_config = CommitmentConfig::processed(); @@ -285,7 +290,7 @@ impl RpcClient { /// ``` /// # use std::time::Duration; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let commitment_config = CommitmentConfig::processed(); @@ -465,7 +470,7 @@ impl RpcClient { /// ``` /// # use std::net::{Ipv4Addr, SocketAddr}; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899)); /// let commitment_config = CommitmentConfig::processed(); /// let client = RpcClient::new_socket_with_commitment( @@ -571,12 +576,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -742,13 +745,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob @@ -830,13 +831,11 @@ impl RpcClient { /// # config::RpcSendTransactionConfig, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob @@ -950,12 +949,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob and wait for confirmation @@ -1009,13 +1006,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # use std::time::Duration; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -1184,13 +1179,11 @@ impl RpcClient { /// # response::RpcSimulateTransactionResult, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob @@ -1259,18 +1252,16 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::{ /// # client_error::Error, /// # config::RpcSimulateTransactionConfig, /// # response::RpcSimulateTransactionResult, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob @@ -1355,11 +1346,11 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_status_with_commitment_and_history`][RpcClient::get_signature_status_with_commitment_and_history] /// method. @@ -1375,13 +1366,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -1398,7 +1387,7 @@ impl RpcClient { pub async fn get_signature_status( &self, signature: &Signature, - ) -> ClientResult>> { + ) -> ClientResult>> { self.get_signature_status_with_commitment(signature, self.commitment()) .await } @@ -1422,7 +1411,7 @@ impl RpcClient { /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_statuses_with_history`][RpcClient::get_signature_statuses_with_history] /// method. @@ -1444,13 +1433,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use std::time::Duration; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -1524,13 +1511,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -1575,11 +1560,11 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_status_with_commitment_and_history`][RpcClient::get_signature_status_with_commitment_and_history] /// method. @@ -1595,13 +1580,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -1623,7 +1606,7 @@ impl RpcClient { &self, signature: &Signature, commitment_config: CommitmentConfig, - ) -> ClientResult>> { + ) -> ClientResult>> { let result: Response>> = self .send( RpcRequest::GetSignatureStatuses, @@ -1651,7 +1634,7 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This method optionally searches a node's full ledger history and (if /// implemented) long-term storage. @@ -1667,13 +1650,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -1698,7 +1679,7 @@ impl RpcClient { signature: &Signature, commitment_config: CommitmentConfig, search_transaction_history: bool, - ) -> ClientResult>> { + ) -> ClientResult>> { let result: Response>> = self .send( RpcRequest::GetSignatureStatuses, @@ -1754,7 +1735,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); @@ -1813,7 +1794,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); @@ -1845,7 +1826,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::slot_history::Slot; + /// # use solana_clock::Slot; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let start_slot = 1; @@ -1916,11 +1897,9 @@ impl RpcClient { /// # config::RpcBlockProductionConfigRange, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let start_slot = 1; @@ -1992,7 +1971,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); @@ -2029,7 +2008,7 @@ impl RpcClient { /// # config::RpcLargestAccountsFilter, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); @@ -2101,7 +2080,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { @@ -2144,11 +2123,9 @@ impl RpcClient { /// # config::RpcGetVoteAccountsConfig, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signer::keypair::Keypair, - /// # signature::Signer, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let vote_keypair = Keypair::new(); @@ -2471,7 +2448,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { @@ -2568,7 +2545,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { @@ -2620,11 +2597,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -2671,12 +2646,10 @@ impl RpcClient { /// # nonblocking::rpc_client::RpcClient, /// # rpc_client::GetConfirmedSignaturesForAddress2Config, /// # }; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -2740,12 +2713,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use solana_transaction_status_client_types::UiTransactionEncoding; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -2799,13 +2770,11 @@ impl RpcClient { /// # config::RpcTransactionConfig, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use solana_transaction_status_client_types::UiTransactionEncoding; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -2920,7 +2889,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::confirmed(); @@ -2956,7 +2925,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; @@ -2988,7 +2957,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; @@ -3032,7 +3001,7 @@ impl RpcClient { /// # config::RpcLeaderScheduleConfig, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; @@ -3134,7 +3103,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3262,7 +3232,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let epoch_info = rpc_client.get_epoch_info().await?; @@ -3314,7 +3285,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let expected_version = semver::Version::new(1, 7, 0); @@ -3386,11 +3358,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_pubkey::Pubkey; + /// # use solana_signer::Signer; /// # use std::str::FromStr; /// # futures::executor::block_on(async { /// # let mocks = rpc_client::create_rpc_client_mocks(); @@ -3427,12 +3397,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; + /// # use solana_pubkey::Pubkey; /// # use std::str::FromStr; /// # futures::executor::block_on(async { /// # let mocks = rpc_client::create_rpc_client_mocks(); @@ -3485,12 +3453,10 @@ impl RpcClient { /// # client_error::Error, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; + /// # use solana_pubkey::Pubkey; /// # use solana_account_decoder_client_types::UiAccountEncoding; /// # use std::str::FromStr; /// # futures::executor::block_on(async { @@ -3617,10 +3583,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3654,11 +3618,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3706,11 +3668,9 @@ impl RpcClient { /// # client_error::Error, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # use solana_account_decoder_client_types::UiAccountEncoding; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3777,11 +3737,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_pubkey::Pubkey; + /// # use solana_signer::Signer; /// # use std::str::FromStr; /// # futures::executor::block_on(async { /// # let mocks = rpc_client::create_rpc_client_mocks(); @@ -3855,10 +3813,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3887,11 +3843,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3934,10 +3888,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3980,11 +3932,9 @@ impl RpcClient { /// # filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, /// # }; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # use solana_account_decoder_client_types::{UiDataSliceConfig, UiAccountEncoding}; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -4081,7 +4031,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = rpc_client.get_stake_minimum_delegation_with_commitment(CommitmentConfig::confirmed()).await?; diff --git a/rpc-client/src/rpc_client.rs b/rpc-client/src/rpc_client.rs index b32517abfd6b4b..fad544ed4c44d3 100644 --- a/rpc-client/src/rpc_client.rs +++ b/rpc-client/src/rpc_client.rs @@ -19,26 +19,25 @@ use { }, serde::Serialize, serde_json::Value, + solana_account::{Account, ReadableAccount}, solana_account_decoder_client_types::token::{UiTokenAccount, UiTokenAmount}, + solana_clock::{Epoch, Slot, UnixTimestamp}, + solana_commitment_config::CommitmentConfig, + solana_epoch_info::EpochInfo, + solana_epoch_schedule::EpochSchedule, + solana_feature_gate_interface::Feature, + solana_hash::Hash, + solana_message::{v0, Message as LegacyMessage}, + solana_pubkey::Pubkey, solana_rpc_client_api::{ client_error::{Error as ClientError, ErrorKind, Result as ClientResult}, config::{RpcAccountInfoConfig, *}, request::{RpcRequest, TokenAccountsFilter}, response::*, }, - solana_sdk::{ - account::{Account, ReadableAccount}, - clock::{Epoch, Slot, UnixTimestamp}, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - epoch_schedule::EpochSchedule, - feature::Feature, - hash::Hash, - message::{v0, Message as LegacyMessage}, - pubkey::Pubkey, - signature::Signature, - transaction::{self, uses_durable_nonce, Transaction, VersionedTransaction}, - }, + solana_signature::Signature, + solana_transaction::{uses_durable_nonce, versioned::VersionedTransaction, Transaction}, + solana_transaction_error::TransactionResult, solana_transaction_status_client_types::{ EncodedConfirmedBlock, EncodedConfirmedTransactionWithStatusMeta, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, @@ -141,8 +140,8 @@ pub struct GetConfirmedSignaturesForAddress2Config { /// [`Processed`] commitment level. These exceptions are noted in the method /// documentation. /// -/// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized -/// [`Processed`]: solana_sdk::commitment_config::CommitmentLevel::Processed +/// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized +/// [`Processed`]: solana_commitment_config::CommitmentLevel::Processed /// [jsonprot]: https://solana.com/docs/rpc /// [JSON-RPC]: https://www.jsonrpc.org/specification /// [slots]: https://solana.com/docs/terminology#slot @@ -161,14 +160,15 @@ pub struct GetConfirmedSignaturesForAddress2Config { /// field, so it is common for the value to be accessed with `?.value`, as in /// /// ``` -/// # use solana_sdk::system_transaction; +/// # use solana_hash::Hash; +/// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; -/// # use solana_sdk::signature::{Keypair, Signer}; -/// # use solana_sdk::hash::Hash; +/// # use solana_system_transaction as system_transaction; +/// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let key = Keypair::new(); -/// # let to = solana_sdk::pubkey::new_rand(); +/// # let to = solana_pubkey::new_rand(); /// # let lamports = 50; /// # let latest_blockhash = Hash::default(); /// # let tx = system_transaction::transfer(&key, &to, lamports, latest_blockhash); @@ -233,7 +233,7 @@ impl RpcClient { /// level][cl] of [`Finalized`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// /// # Examples /// @@ -256,12 +256,12 @@ impl RpcClient { /// The client has a default timeout of 30 seconds, and a user-specified /// [`CommitmentLevel`] via [`CommitmentConfig`]. /// - /// [`CommitmentLevel`]: solana_sdk::commitment_config::CommitmentLevel + /// [`CommitmentLevel`]: solana_commitment_config::CommitmentLevel /// /// # Examples /// /// ``` - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let commitment_config = CommitmentConfig::processed(); @@ -283,7 +283,7 @@ impl RpcClient { /// [`Finalized`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// /// # Examples /// @@ -313,7 +313,7 @@ impl RpcClient { /// ``` /// # use std::time::Duration; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let commitment_config = CommitmentConfig::processed(); @@ -354,7 +354,7 @@ impl RpcClient { /// ``` /// # use std::time::Duration; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let commitment_config = CommitmentConfig::processed(); @@ -509,7 +509,7 @@ impl RpcClient { /// level][cl] of [`Finalized`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// /// # Examples /// @@ -530,14 +530,14 @@ impl RpcClient { /// The client has a default timeout of 30 seconds, and a user-specified /// [`CommitmentLevel`] via [`CommitmentConfig`]. /// - /// [`CommitmentLevel`]: solana_sdk::commitment_config::CommitmentLevel + /// [`CommitmentLevel`]: solana_commitment_config::CommitmentLevel /// /// # Examples /// /// ``` /// # use std::net::{Ipv4Addr, SocketAddr}; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899)); /// let commitment_config = CommitmentConfig::processed(); /// let client = RpcClient::new_socket_with_commitment( @@ -557,7 +557,7 @@ impl RpcClient { /// The client has a default [commitment level][cl] of [`Finalized`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// /// # Examples /// @@ -589,7 +589,7 @@ impl RpcClient { /// specified, the default commitment level is /// [`Finalized`]. /// - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// /// The default commitment level is overridden when calling methods that /// explicitly provide a [`CommitmentConfig`], like @@ -640,14 +640,12 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -751,15 +749,13 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob /// # let alice = Keypair::new(); @@ -827,18 +823,16 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::{ /// # client_error::Error, /// # config::RpcSendTransactionConfig, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob /// # let alice = Keypair::new(); @@ -896,14 +890,12 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob and wait for confirmation /// # let alice = Keypair::new(); @@ -949,15 +941,13 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_commitment_config::CommitmentConfig; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use std::time::Duration; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob and wait for confirmation @@ -1033,18 +1023,16 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::{ /// # client_error::Error, /// # response::RpcSimulateTransactionResult, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob /// # let alice = Keypair::new(); @@ -1103,18 +1091,16 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::{ /// # client_error::Error, /// # config::RpcSimulateTransactionConfig, /// # response::RpcSimulateTransactionResult, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Transfer lamports from Alice to Bob /// # let alice = Keypair::new(); @@ -1182,11 +1168,11 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_status_with_commitment_and_history`][RpcClient::get_signature_status_with_commitment_and_history] /// method. @@ -1200,15 +1186,13 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -1222,7 +1206,7 @@ impl RpcClient { pub fn get_signature_status( &self, signature: &Signature, - ) -> ClientResult>> { + ) -> ClientResult>> { self.invoke((self.rpc_client.as_ref()).get_signature_status(signature)) } @@ -1245,7 +1229,7 @@ impl RpcClient { /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_statuses_with_history`][RpcClient::get_signature_statuses_with_history] /// method. @@ -1265,15 +1249,13 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_keypair::Keypair; /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use std::time::Duration; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -1342,13 +1324,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # hash::Hash, - /// # system_transaction, - /// # }; + /// # use solana_hash::Hash; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # fn get_old_transaction_signature() -> Signature { Signature::default() } @@ -1383,11 +1363,11 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This function only searches a node's recent history, including all /// recent slots, plus up to - /// [`MAX_RECENT_BLOCKHASHES`][solana_sdk::clock::MAX_RECENT_BLOCKHASHES] + /// [`MAX_RECENT_BLOCKHASHES`][solana_clock::MAX_RECENT_BLOCKHASHES] /// rooted slots. To search the full transaction history use the /// [`get_signature_status_with_commitment_and_history`][RpcClient::get_signature_status_with_commitment_and_history] /// method. @@ -1403,13 +1383,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -1428,7 +1406,7 @@ impl RpcClient { &self, signature: &Signature, commitment_config: CommitmentConfig, - ) -> ClientResult>> { + ) -> ClientResult>> { self.invoke( (self.rpc_client.as_ref()) .get_signature_status_with_commitment(signature, commitment_config), @@ -1450,7 +1428,7 @@ impl RpcClient { /// and the transaction failed, this method returns `Ok(Some(Err(_)))`, /// where the interior error is type [`TransactionError`]. /// - /// [`TransactionError`]: solana_sdk::transaction::TransactionError + /// [`TransactionError`]: solana_transaction_error::TransactionError /// /// This method optionally searches a node's full ledger history and (if /// implemented) long-term storage. @@ -1466,13 +1444,11 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # commitment_config::CommitmentConfig, - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; + /// # use solana_system_transaction as system_transaction; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -1494,7 +1470,7 @@ impl RpcClient { signature: &Signature, commitment_config: CommitmentConfig, search_transaction_history: bool, - ) -> ClientResult>> { + ) -> ClientResult>> { self.invoke( (self.rpc_client.as_ref()).get_signature_status_with_commitment_and_history( signature, @@ -1542,7 +1518,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let slot = rpc_client.get_slot_with_commitment(commitment_config)?; @@ -1593,7 +1569,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let block_height = rpc_client.get_block_height_with_commitment( @@ -1621,7 +1597,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::slot_history::Slot; + /// # use solana_clock::Slot; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let start_slot = 1; /// let limit = 3; @@ -1669,11 +1645,9 @@ impl RpcClient { /// # config::{RpcBlockProductionConfig, RpcBlockProductionConfigRange}, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let start_slot = 1; /// # let limit = 3; @@ -1738,7 +1712,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let supply = rpc_client.supply_with_commitment( @@ -1770,7 +1744,7 @@ impl RpcClient { /// # config::{RpcLargestAccountsConfig, RpcLargestAccountsFilter}, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let config = RpcLargestAccountsConfig { @@ -1831,7 +1805,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let accounts = rpc_client.get_vote_accounts_with_commitment( @@ -1865,11 +1839,9 @@ impl RpcClient { /// # config::RpcGetVoteAccountsConfig, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signer::keypair::Keypair, - /// # signature::Signer, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let vote_keypair = Keypair::new(); /// let vote_pubkey = vote_keypair.pubkey(); @@ -2055,7 +2027,7 @@ impl RpcClient { /// /// This method uses the [`Finalized`] [commitment level][cl]. /// - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// [`get_blocks_with_limit`]: RpcClient::get_blocks_with_limit. /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment /// @@ -2109,7 +2081,7 @@ impl RpcClient { /// This method returns an error if the given commitment level is below /// [`Confirmed`]. /// - /// [`Confirmed`]: solana_sdk::commitment_config::CommitmentLevel::Confirmed + /// [`Confirmed`]: solana_commitment_config::CommitmentLevel::Confirmed /// /// # RPC Reference /// @@ -2122,7 +2094,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get up to the first 10 blocks /// let start_slot = 0; @@ -2193,7 +2165,7 @@ impl RpcClient { /// [`Confirmed`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Confirmed`]: solana_sdk::commitment_config::CommitmentLevel::Confirmed + /// [`Confirmed`]: solana_commitment_config::CommitmentLevel::Confirmed /// /// # RPC Reference /// @@ -2207,7 +2179,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the first 10 blocks /// let start_slot = 0; @@ -2256,11 +2228,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let signatures = rpc_client.get_signatures_for_address( @@ -2283,7 +2253,7 @@ impl RpcClient { /// [`Confirmed`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Confirmed`]: solana_sdk::commitment_config::CommitmentLevel::Confirmed + /// [`Confirmed`]: solana_commitment_config::CommitmentLevel::Confirmed /// /// # RPC Reference /// @@ -2297,12 +2267,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -2336,7 +2304,7 @@ impl RpcClient { /// /// This method uses the [`Finalized`] [commitment level][cl]. /// - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment /// /// # RPC Reference @@ -2350,12 +2318,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use solana_transaction_status_client_types::UiTransactionEncoding; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -2386,7 +2352,7 @@ impl RpcClient { /// [`Confirmed`]. /// /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment - /// [`Confirmed`]: solana_sdk::commitment_config::CommitmentLevel::Confirmed + /// [`Confirmed`]: solana_commitment_config::CommitmentLevel::Confirmed /// /// # RPC Reference /// @@ -2402,13 +2368,11 @@ impl RpcClient { /// # config::RpcTransactionConfig, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signature::Signature, - /// # signer::keypair::Keypair, - /// # system_transaction, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_system_transaction as system_transaction; + /// # use solana_signature::Signature; + /// # use solana_signer::Signer; /// # use solana_transaction_status_client_types::UiTransactionEncoding; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -2497,7 +2461,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::confirmed(); /// let epoch_info = rpc_client.get_epoch_info_with_commitment( @@ -2529,7 +2493,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let leader_schedule = rpc_client.get_leader_schedule( @@ -2557,7 +2521,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let commitment_config = CommitmentConfig::processed(); @@ -2593,7 +2557,7 @@ impl RpcClient { /// # config::RpcLeaderScheduleConfig, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// # let validator_pubkey_str = "7AYmEYBBetok8h5L3Eo3vi3bDWnjNnaFbSXfSNYV5ewB".to_string(); @@ -2684,7 +2648,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -2726,7 +2691,7 @@ impl RpcClient { /// /// This method uses the [`Finalized`] [commitment level][cl]. /// - /// [`Finalized`]: solana_sdk::commitment_config::CommitmentLevel::Finalized + /// [`Finalized`]: solana_commitment_config::CommitmentLevel::Finalized /// [cl]: https://solana.com/docs/rpc#configuring-state-commitment /// /// # RPC Reference @@ -2787,7 +2752,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let epoch_info = rpc_client.get_epoch_info()?; /// # let epoch = epoch_info.epoch; @@ -2821,7 +2787,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::signature::{Keypair, Signer}; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let expected_version = semver::Version::new(1, 7, 0); /// let version = rpc_client.get_version()?; @@ -2888,11 +2855,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_pubkey::Pubkey; + /// # use solana_signer::Signer; /// # use std::str::FromStr; /// # let mocks = rpc_client::create_rpc_client_mocks(); /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); @@ -2923,12 +2888,10 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; + /// # use solana_pubkey::Pubkey; /// # use std::str::FromStr; /// # let mocks = rpc_client::create_rpc_client_mocks(); /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); @@ -2973,12 +2936,10 @@ impl RpcClient { /// # client_error::Error, /// # }; /// # use solana_rpc_client::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; + /// # use solana_pubkey::Pubkey; /// # use solana_account_decoder_client_types::UiAccountEncoding; /// # use std::str::FromStr; /// # let mocks = rpc_client::create_rpc_client_mocks(); @@ -3064,10 +3025,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -3092,11 +3051,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// # let bob = Keypair::new(); @@ -3135,11 +3092,9 @@ impl RpcClient { /// # client_error::Error, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # use solana_account_decoder_client_types::UiAccountEncoding; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3184,11 +3139,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::{self, RpcClient}; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # pubkey::Pubkey, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_pubkey::Pubkey; + /// # use solana_signer::Signer; /// # use std::str::FromStr; /// # let mocks = rpc_client::create_rpc_client_mocks(); /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); @@ -3240,10 +3193,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let balance = rpc_client.get_balance(&alice.pubkey())?; @@ -3266,11 +3217,9 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let commitment_config = CommitmentConfig::processed(); @@ -3308,10 +3257,8 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # }; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let accounts = rpc_client.get_program_accounts(&alice.pubkey())?; @@ -3338,11 +3285,9 @@ impl RpcClient { /// # filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, /// # }; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::{ - /// # signature::Signer, - /// # signer::keypair::Keypair, - /// # commitment_config::CommitmentConfig, - /// # }; + /// # use solana_commitment_config::CommitmentConfig; + /// # use solana_keypair::Keypair; + /// # use solana_signer::Signer; /// # use solana_account_decoder_client_types::{UiDataSliceConfig, UiAccountEncoding}; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); @@ -3419,7 +3364,7 @@ impl RpcClient { /// ``` /// # use solana_rpc_client_api::client_error::Error; /// # use solana_rpc_client::rpc_client::RpcClient; - /// # use solana_sdk::commitment_config::CommitmentConfig; + /// # use solana_commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = /// rpc_client.get_stake_minimum_delegation_with_commitment(CommitmentConfig::confirmed())?; @@ -3764,13 +3709,12 @@ mod tests { serde_json::{json, Number}, solana_account_decoder::encode_ui_account, solana_account_decoder_client_types::UiAccountEncoding, + solana_instruction::error::InstructionError, + solana_keypair::Keypair, solana_rpc_client_api::client_error::ErrorKind, - solana_sdk::{ - instruction::InstructionError, - signature::{Keypair, Signer}, - system_transaction, - transaction::TransactionError, - }, + solana_signer::Signer, + solana_system_transaction as system_transaction, + solana_transaction_error::TransactionError, std::{io, thread}, }; @@ -3848,7 +3792,7 @@ mod tests { let rpc_client = RpcClient::new_mock("succeeds".to_string()); let key = Keypair::new(); - let to = solana_sdk::pubkey::new_rand(); + let to = solana_pubkey::new_rand(); let blockhash = Hash::default(); let tx = system_transaction::transfer(&key, &to, 50, blockhash); @@ -3902,7 +3846,7 @@ mod tests { let rpc_client = RpcClient::new_mock("succeeds".to_string()); let key = Keypair::new(); - let to = solana_sdk::pubkey::new_rand(); + let to = solana_pubkey::new_rand(); let blockhash = Hash::default(); let tx = system_transaction::transfer(&key, &to, 50, blockhash); let result = rpc_client.send_and_confirm_transaction(&tx); diff --git a/rpc/src/rewards_recorder_service.rs b/rpc/src/rewards_recorder_service.rs index 3467a151632317..5d4f62462ede67 100644 --- a/rpc/src/rewards_recorder_service.rs +++ b/rpc/src/rewards_recorder_service.rs @@ -2,9 +2,9 @@ //! persisting it into the `Blockstore`. use { - crossbeam_channel::RecvTimeoutError, + crossbeam_channel::TryRecvError, solana_ledger::{ - blockstore::Blockstore, + blockstore::{Blockstore, BlockstoreError}, blockstore_processor::{RewardsMessage, RewardsRecorderReceiver}, }, solana_runtime::bank::KeyedRewardsAndNumPartitions, @@ -14,7 +14,7 @@ use { atomic::{AtomicBool, AtomicU64, Ordering}, Arc, }, - thread::{self, Builder, JoinHandle}, + thread::{self, sleep, Builder, JoinHandle}, time::Duration, }, }; @@ -23,6 +23,10 @@ pub struct RewardsRecorderService { thread_hdl: JoinHandle<()>, } +// ReplayStage sends a new item to this service for every frozen Bank. Banks +// are frozen every 400ms at steady state so checking every 100ms is sufficient +const TRY_RECV_INTERVAL: Duration = Duration::from_millis(100); + impl RewardsRecorderService { pub fn new( rewards_receiver: RewardsRecorderReceiver, @@ -38,11 +42,25 @@ impl RewardsRecorderService { if exit.load(Ordering::Relaxed) { break; } - if let Err(RecvTimeoutError::Disconnected) = Self::write_rewards( - &rewards_receiver, - &max_complete_rewards_slot, - &blockstore, - ) { + + let rewards = match rewards_receiver.try_recv() { + Ok(rewards) => rewards, + Err(TryRecvError::Empty) => { + sleep(TRY_RECV_INTERVAL); + continue; + } + Err(err @ TryRecvError::Disconnected) => { + info!("RewardsRecorderService is stopping because: {err}"); + break; + } + }; + + if let Err(err) = + Self::write_rewards(rewards, &max_complete_rewards_slot, &blockstore) + { + error!("RewardsRecorderService is stopping because: {err}"); + // Set the exit flag to allow other services to gracefully stop + exit.store(true, Ordering::Relaxed); break; } } @@ -53,11 +71,11 @@ impl RewardsRecorderService { } fn write_rewards( - rewards_receiver: &RewardsRecorderReceiver, + rewards: RewardsMessage, max_complete_rewards_slot: &Arc, blockstore: &Blockstore, - ) -> Result<(), RecvTimeoutError> { - match rewards_receiver.recv_timeout(Duration::from_secs(1))? { + ) -> Result<(), BlockstoreError> { + match rewards { RewardsMessage::Batch(( slot, KeyedRewardsAndNumPartitions { @@ -76,20 +94,19 @@ impl RewardsRecorderService { }) .collect(); - blockstore - .write_rewards( - slot, - RewardsAndNumPartitions { - rewards: rpc_rewards, - num_partitions, - }, - ) - .expect("Expect database write to succeed"); + blockstore.write_rewards( + slot, + RewardsAndNumPartitions { + rewards: rpc_rewards, + num_partitions, + }, + )?; } RewardsMessage::Complete(slot) => { max_complete_rewards_slot.fetch_max(slot, Ordering::SeqCst); } } + Ok(()) } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 7ff38ba1c2b2f3..a839b12e0faf10 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3761,8 +3761,10 @@ impl Bank { .per_program_timings .iter() .fold(0, |acc: u64, (_, program_timing)| { - acc.saturating_add(program_timing.accumulated_units) - .saturating_add(program_timing.total_errored_units) + (std::num::Saturating(acc) + + program_timing.accumulated_units + + program_timing.total_errored_units) + .0 }); debug!("simulate_transaction: {:?}", timings); diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index dee8abdb6d62d7..e8260c3a279114 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5920,11 +5920,12 @@ dependencies = [ "rayon", "serde", "solana-hash", + "solana-message", "solana-metrics", "solana-packet", - "solana-program", "solana-pubkey", "solana-rayon-threadlimit", + "solana-sdk-ids", "solana-short-vec", "solana-signature", "solana-time-utils", @@ -6122,13 +6123,28 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "thiserror 2.0.4", @@ -6393,9 +6409,21 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "solana-account", "solana-account-decoder-client-types", + "solana-clock", + "solana-commitment-config", + "solana-epoch-info", + "solana-epoch-schedule", + "solana-feature-gate-interface", + "solana-hash", + "solana-instruction", + "solana-message", + "solana-pubkey", "solana-rpc-client-api", - "solana-sdk", + "solana-signature", + "solana-transaction", + "solana-transaction-error", "solana-transaction-status-client-types", "solana-version", "tokio", @@ -7149,7 +7177,7 @@ version = "2.2.0" dependencies = [ "eager", "enum-iterator", - "solana-sdk", + "solana-pubkey", ] [[package]] diff --git a/svm/src/message_processor.rs b/svm/src/message_processor.rs index 8bb42f72a144f6..ad4d1723baf4e2 100644 --- a/svm/src/message_processor.rs +++ b/svm/src/message_processor.rs @@ -4,7 +4,6 @@ use { solana_sdk::{ account::WritableAccount, precompiles::get_precompile, - saturating_add_assign, sysvar::instructions, transaction::TransactionError, transaction_context::{IndexOfAccount, InstructionAccount}, @@ -118,13 +117,10 @@ impl MessageProcessor { execute_timings.details.accumulate(&invoke_context.timings); ExecuteDetailsTimings::default() }; - saturating_add_assign!( - execute_timings - .execute_accessories - .process_instructions - .total_us, - process_instruction_us - ); + execute_timings + .execute_accessories + .process_instructions + .total_us += process_instruction_us; result .map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?; diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 0327a434fcbab3..f8c307a010ef9b 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -1011,10 +1011,7 @@ impl TransactionBatchProcessor { drop(invoke_context); - saturating_add_assign!( - execute_timings.execute_accessories.process_message_us, - process_message_time.as_us() - ); + execute_timings.execute_accessories.process_message_us += process_message_time.as_us(); let mut status = process_result .and_then(|info| { @@ -1076,14 +1073,8 @@ impl TransactionBatchProcessor { let status = status.map(|_| ()); loaded_transaction.accounts = accounts; - saturating_add_assign!( - execute_timings.details.total_account_count, - loaded_transaction.accounts.len() as u64 - ); - saturating_add_assign!( - execute_timings.details.changed_account_count, - touched_account_count - ); + execute_timings.details.total_account_count += loaded_transaction.accounts.len() as u64; + execute_timings.details.changed_account_count += touched_account_count; let return_data = if config.recording_config.enable_return_data_recording && !return_data.data.is_empty() diff --git a/svm/tests/integration_test.rs b/svm/tests/integration_test.rs index 0f835c9bcae75e..068fd73fce480c 100644 --- a/svm/tests/integration_test.rs +++ b/svm/tests/integration_test.rs @@ -2470,18 +2470,20 @@ fn svm_metrics_accumulation() { result .execute_timings .details - .create_executor_jit_compile_us, + .create_executor_jit_compile_us + .0, 0 ); assert_ne!( - result.execute_timings.details.create_executor_load_elf_us, + result.execute_timings.details.create_executor_load_elf_us.0, 0 ); assert_ne!( result .execute_timings .details - .create_executor_verify_code_us, + .create_executor_verify_code_us + .0, 0 ); } diff --git a/timings/Cargo.toml b/timings/Cargo.toml index c52b46ad905ccb..2f16de53426f30 100644 --- a/timings/Cargo.toml +++ b/timings/Cargo.toml @@ -12,7 +12,7 @@ edition = { workspace = true } [dependencies] eager = { workspace = true } enum-iterator = { workspace = true } -solana-sdk = { workspace = true } +solana-pubkey = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/timings/src/lib.rs b/timings/src/lib.rs index 35645593589065..94c415f5e5fa35 100644 --- a/timings/src/lib.rs +++ b/timings/src/lib.rs @@ -3,21 +3,22 @@ extern crate eager; use { core::fmt, enum_iterator::Sequence, - solana_sdk::{pubkey::Pubkey, saturating_add_assign}, + solana_pubkey::Pubkey, std::{ collections::HashMap, + num::Saturating, ops::{Index, IndexMut}, }, }; #[derive(Default, Debug, PartialEq, Eq)] pub struct ProgramTiming { - pub accumulated_us: u64, - pub accumulated_units: u64, - pub count: u32, + pub accumulated_us: Saturating, + pub accumulated_units: Saturating, + pub count: Saturating, pub errored_txs_compute_consumed: Vec, // Sum of all units in `errored_txs_compute_consumed` - pub total_errored_units: u64, + pub total_errored_units: Saturating, } impl ProgramTiming { @@ -25,19 +26,19 @@ impl ProgramTiming { for tx_error_compute_consumed in self.errored_txs_compute_consumed.drain(..) { let compute_units_update = std::cmp::max(current_estimated_program_cost, tx_error_compute_consumed); - saturating_add_assign!(self.accumulated_units, compute_units_update); - saturating_add_assign!(self.count, 1); + self.accumulated_units += compute_units_update; + self.count += 1; } } pub fn accumulate_program_timings(&mut self, other: &ProgramTiming) { - saturating_add_assign!(self.accumulated_us, other.accumulated_us); - saturating_add_assign!(self.accumulated_units, other.accumulated_units); - saturating_add_assign!(self.count, other.count); + self.accumulated_us += other.accumulated_us; + self.accumulated_units += other.accumulated_units; + self.count += other.count; // Clones the entire vector, maybe not great... self.errored_txs_compute_consumed .extend(other.errored_txs_compute_consumed.clone()); - saturating_add_assign!(self.total_errored_units, other.total_errored_units); + self.total_errored_units += other.total_errored_units; } } @@ -60,10 +61,10 @@ pub enum ExecuteTimingType { FilterExecutableUs, } -pub struct Metrics([u64; ExecuteTimingType::CARDINALITY]); +pub struct Metrics([Saturating; ExecuteTimingType::CARDINALITY]); impl Index for Metrics { - type Output = u64; + type Output = Saturating; fn index(&self, index: ExecuteTimingType) -> &Self::Output { self.0.index(index as usize) } @@ -77,7 +78,7 @@ impl IndexMut for Metrics { impl Default for Metrics { fn default() -> Self { - Metrics([0; ExecuteTimingType::CARDINALITY]) + Metrics([Saturating(0); ExecuteTimingType::CARDINALITY]) } } @@ -96,72 +97,72 @@ eager_macro_rules! { $eager_1 ($self: expr, $is_unified_scheduler_enabled: expr) => { ( "validate_transactions_us", - *$self + $self .metrics - .index(ExecuteTimingType::CheckUs), + .index(ExecuteTimingType::CheckUs).0, i64 ), ( "validate_fees_us", - *$self + $self .metrics - .index(ExecuteTimingType::ValidateFeesUs), + .index(ExecuteTimingType::ValidateFeesUs).0, i64 ), ( "filter_executable_us", - *$self + $self .metrics - .index(ExecuteTimingType::FilterExecutableUs), + .index(ExecuteTimingType::FilterExecutableUs).0, i64 ), ( "program_cache_us", - *$self + $self .metrics - .index(ExecuteTimingType::ProgramCacheUs), + .index(ExecuteTimingType::ProgramCacheUs).0, i64 ), ( "load_us", - *$self + $self .metrics - .index(ExecuteTimingType::LoadUs), + .index(ExecuteTimingType::LoadUs).0, i64 ), ( "execute_us", - *$self + $self .metrics - .index(ExecuteTimingType::ExecuteUs), + .index(ExecuteTimingType::ExecuteUs).0, i64 ), ( "collect_logs_us", - *$self + $self .metrics - .index(ExecuteTimingType::CollectLogsUs), + .index(ExecuteTimingType::CollectLogsUs).0, i64 ), ( "store_us", - *$self + $self .metrics - .index(ExecuteTimingType::StoreUs), + .index(ExecuteTimingType::StoreUs).0, i64 ), ( "update_stakes_cache_us", - *$self + $self .metrics - .index(ExecuteTimingType::UpdateStakesCacheUs), + .index(ExecuteTimingType::UpdateStakesCacheUs).0, i64 ), ( "execute_accessories_update_executors_us", - *$self.metrics.index(ExecuteTimingType::UpdateExecutorsUs), + $self.metrics.index(ExecuteTimingType::UpdateExecutorsUs).0, i64 ), ( @@ -169,9 +170,9 @@ eager_macro_rules! { $eager_1 (if $is_unified_scheduler_enabled { None } else { - Some(*$self + Some($self .metrics - .index(ExecuteTimingType::TotalBatchesLen)) + .index(ExecuteTimingType::TotalBatchesLen).0) }), Option ), @@ -180,96 +181,96 @@ eager_macro_rules! { $eager_1 (if $is_unified_scheduler_enabled { None } else { - Some(*$self + Some($self .metrics - .index(ExecuteTimingType::NumExecuteBatches)) + .index(ExecuteTimingType::NumExecuteBatches).0) }), Option ), ( "update_transaction_statuses", - *$self + $self .metrics - .index(ExecuteTimingType::UpdateTransactionStatuses), + .index(ExecuteTimingType::UpdateTransactionStatuses).0, i64 ), ( "check_block_limits_us", - *$self.metrics.index(ExecuteTimingType::CheckBlockLimitsUs), + $self.metrics.index(ExecuteTimingType::CheckBlockLimitsUs).0, i64 ), ( "execute_details_serialize_us", - $self.details.serialize_us, + $self.details.serialize_us.0, i64 ), ( "execute_details_create_vm_us", - $self.details.create_vm_us, + $self.details.create_vm_us.0, i64 ), ( "execute_details_execute_inner_us", - $self.details.execute_us, + $self.details.execute_us.0, i64 ), ( "execute_details_deserialize_us", - $self.details.deserialize_us, + $self.details.deserialize_us.0, i64 ), ( "execute_details_get_or_create_executor_us", - $self.details.get_or_create_executor_us, + $self.details.get_or_create_executor_us.0, i64 ), ( "execute_details_changed_account_count", - $self.details.changed_account_count, + $self.details.changed_account_count.0, i64 ), ( "execute_details_total_account_count", - $self.details.total_account_count, + $self.details.total_account_count.0, i64 ), ( "execute_details_create_executor_register_syscalls_us", $self .details - .create_executor_register_syscalls_us, + .create_executor_register_syscalls_us.0, i64 ), ( "execute_details_create_executor_load_elf_us", - $self.details.create_executor_load_elf_us, + $self.details.create_executor_load_elf_us.0, i64 ), ( "execute_details_create_executor_verify_code_us", - $self.details.create_executor_verify_code_us, + $self.details.create_executor_verify_code_us.0, i64 ), ( "execute_details_create_executor_jit_compile_us", - $self.details.create_executor_jit_compile_us, + $self.details.create_executor_jit_compile_us.0, i64 ), ( "execute_accessories_feature_set_clone_us", $self .execute_accessories - .feature_set_clone_us, + .feature_set_clone_us.0, i64 ), ( "execute_accessories_get_executors_us", - $self.execute_accessories.get_executors_us, + $self.execute_accessories.get_executors_us.0, i64 ), ( "execute_accessories_process_message_us", - $self.execute_accessories.process_message_us, + $self.execute_accessories.process_message_us.0, i64 ), ( @@ -277,7 +278,7 @@ eager_macro_rules! { $eager_1 $self .execute_accessories .process_instructions - .total_us, + .total_us.0, i64 ), ( @@ -285,7 +286,7 @@ eager_macro_rules! { $eager_1 $self .execute_accessories .process_instructions - .verify_caller_us, + .verify_caller_us.0, i64 ), ( @@ -293,7 +294,7 @@ eager_macro_rules! { $eager_1 $self .execute_accessories .process_instructions - .process_executable_chain_us, + .process_executable_chain_us.0, i64 ), ( @@ -301,7 +302,7 @@ eager_macro_rules! { $eager_1 $self .execute_accessories .process_instructions - .verify_callee_us, + .verify_callee_us.0, i64 ), } @@ -318,7 +319,7 @@ pub struct ExecuteTimings { impl ExecuteTimings { pub fn accumulate(&mut self, other: &ExecuteTimings) { for (t1, t2) in self.metrics.0.iter_mut().zip(other.metrics.0.iter()) { - saturating_add_assign!(*t1, *t2); + *t1 += *t2; } self.details.accumulate(&other.details); self.execute_accessories @@ -328,7 +329,7 @@ impl ExecuteTimings { pub fn saturating_add_in_place(&mut self, timing_type: ExecuteTimingType, value_to_add: u64) { let idx = timing_type as usize; match self.metrics.0.get_mut(idx) { - Some(elem) => *elem = elem.saturating_add(value_to_add), + Some(elem) => *elem += value_to_add, None => debug_assert!(idx < ExecuteTimingType::CARDINALITY, "Index out of bounds"), } } @@ -336,37 +337,34 @@ impl ExecuteTimings { #[derive(Default, Debug)] pub struct ExecuteProcessInstructionTimings { - pub total_us: u64, - pub verify_caller_us: u64, - pub process_executable_chain_us: u64, - pub verify_callee_us: u64, + pub total_us: Saturating, + pub verify_caller_us: Saturating, + pub process_executable_chain_us: Saturating, + pub verify_callee_us: Saturating, } impl ExecuteProcessInstructionTimings { pub fn accumulate(&mut self, other: &ExecuteProcessInstructionTimings) { - saturating_add_assign!(self.total_us, other.total_us); - saturating_add_assign!(self.verify_caller_us, other.verify_caller_us); - saturating_add_assign!( - self.process_executable_chain_us, - other.process_executable_chain_us - ); - saturating_add_assign!(self.verify_callee_us, other.verify_callee_us); + self.total_us += other.total_us; + self.verify_caller_us += other.verify_caller_us; + self.process_executable_chain_us += other.process_executable_chain_us; + self.verify_callee_us += other.verify_callee_us; } } #[derive(Default, Debug)] pub struct ExecuteAccessoryTimings { - pub feature_set_clone_us: u64, - pub get_executors_us: u64, - pub process_message_us: u64, + pub feature_set_clone_us: Saturating, + pub get_executors_us: Saturating, + pub process_message_us: Saturating, pub process_instructions: ExecuteProcessInstructionTimings, } impl ExecuteAccessoryTimings { pub fn accumulate(&mut self, other: &ExecuteAccessoryTimings) { - saturating_add_assign!(self.feature_set_clone_us, other.feature_set_clone_us); - saturating_add_assign!(self.get_executors_us, other.get_executors_us); - saturating_add_assign!(self.process_message_us, other.process_message_us); + self.feature_set_clone_us += other.feature_set_clone_us; + self.get_executors_us += other.get_executors_us; + self.process_message_us += other.process_message_us; self.process_instructions .accumulate(&other.process_instructions); } @@ -374,48 +372,33 @@ impl ExecuteAccessoryTimings { #[derive(Default, Debug, PartialEq, Eq)] pub struct ExecuteDetailsTimings { - pub serialize_us: u64, - pub create_vm_us: u64, - pub execute_us: u64, - pub deserialize_us: u64, - pub get_or_create_executor_us: u64, - pub changed_account_count: u64, - pub total_account_count: u64, - pub create_executor_register_syscalls_us: u64, - pub create_executor_load_elf_us: u64, - pub create_executor_verify_code_us: u64, - pub create_executor_jit_compile_us: u64, + pub serialize_us: Saturating, + pub create_vm_us: Saturating, + pub execute_us: Saturating, + pub deserialize_us: Saturating, + pub get_or_create_executor_us: Saturating, + pub changed_account_count: Saturating, + pub total_account_count: Saturating, + pub create_executor_register_syscalls_us: Saturating, + pub create_executor_load_elf_us: Saturating, + pub create_executor_verify_code_us: Saturating, + pub create_executor_jit_compile_us: Saturating, pub per_program_timings: HashMap, } impl ExecuteDetailsTimings { pub fn accumulate(&mut self, other: &ExecuteDetailsTimings) { - saturating_add_assign!(self.serialize_us, other.serialize_us); - saturating_add_assign!(self.create_vm_us, other.create_vm_us); - saturating_add_assign!(self.execute_us, other.execute_us); - saturating_add_assign!(self.deserialize_us, other.deserialize_us); - saturating_add_assign!( - self.get_or_create_executor_us, - other.get_or_create_executor_us - ); - saturating_add_assign!(self.changed_account_count, other.changed_account_count); - saturating_add_assign!(self.total_account_count, other.total_account_count); - saturating_add_assign!( - self.create_executor_register_syscalls_us, - other.create_executor_register_syscalls_us - ); - saturating_add_assign!( - self.create_executor_load_elf_us, - other.create_executor_load_elf_us - ); - saturating_add_assign!( - self.create_executor_verify_code_us, - other.create_executor_verify_code_us - ); - saturating_add_assign!( - self.create_executor_jit_compile_us, - other.create_executor_jit_compile_us - ); + self.serialize_us += other.serialize_us; + self.create_vm_us += other.create_vm_us; + self.execute_us += other.execute_us; + self.deserialize_us += other.deserialize_us; + self.get_or_create_executor_us += other.get_or_create_executor_us; + self.changed_account_count += other.changed_account_count; + self.total_account_count += other.total_account_count; + self.create_executor_register_syscalls_us += other.create_executor_register_syscalls_us; + self.create_executor_load_elf_us += other.create_executor_load_elf_us; + self.create_executor_verify_code_us += other.create_executor_verify_code_us; + self.create_executor_jit_compile_us += other.create_executor_jit_compile_us; for (id, other) in &other.per_program_timings { let program_timing = self.per_program_timings.entry(*id).or_default(); program_timing.accumulate_program_timings(other); @@ -430,19 +413,15 @@ impl ExecuteDetailsTimings { is_error: bool, ) { let program_timing = self.per_program_timings.entry(*program_id).or_default(); - program_timing.accumulated_us = program_timing.accumulated_us.saturating_add(us); + program_timing.accumulated_us += us; if is_error { program_timing .errored_txs_compute_consumed .push(compute_units_consumed); - program_timing.total_errored_units = program_timing - .total_errored_units - .saturating_add(compute_units_consumed); + program_timing.total_errored_units += compute_units_consumed; } else { - program_timing.accumulated_units = program_timing - .accumulated_units - .saturating_add(compute_units_consumed); - program_timing.count = program_timing.count.saturating_add(1); + program_timing.accumulated_units += compute_units_consumed; + program_timing.count += 1; }; } } @@ -482,14 +461,17 @@ mod tests { .unwrap(); // Both error and success transactions count towards `accumulated_us` - assert_eq!(program_timings.accumulated_us, us.saturating_mul(2)); - assert_eq!(program_timings.accumulated_units, compute_units_consumed); - assert_eq!(program_timings.count, 1,); + assert_eq!(program_timings.accumulated_us.0, us.saturating_mul(2)); + assert_eq!(program_timings.accumulated_units.0, compute_units_consumed); + assert_eq!(program_timings.count.0, 1,); assert_eq!( program_timings.errored_txs_compute_consumed, vec![compute_units_consumed] ); - assert_eq!(program_timings.total_errored_units, compute_units_consumed,); + assert_eq!( + program_timings.total_errored_units.0, + compute_units_consumed, + ); execute_details_timings } @@ -515,12 +497,12 @@ mod tests { let mut other_execute_details_timings = construct_execute_timings_with_program(&program_id, us, compute_units_consumed); let account_count = 1; - other_execute_details_timings.serialize_us = us; - other_execute_details_timings.create_vm_us = us; - other_execute_details_timings.execute_us = us; - other_execute_details_timings.deserialize_us = us; - other_execute_details_timings.changed_account_count = account_count; - other_execute_details_timings.total_account_count = account_count; + other_execute_details_timings.serialize_us.0 = us; + other_execute_details_timings.create_vm_us.0 = us; + other_execute_details_timings.execute_us.0 = us; + other_execute_details_timings.deserialize_us.0 = us; + other_execute_details_timings.changed_account_count.0 = account_count; + other_execute_details_timings.total_account_count.0 = account_count; // Accumulate the other instance into the current instance execute_details_timings.accumulate(&other_execute_details_timings); @@ -534,10 +516,10 @@ mod tests { let mut timings = ExecuteTimings::default(); timings.saturating_add_in_place(ExecuteTimingType::CheckUs, 1); let check_us = timings.metrics.index(ExecuteTimingType::CheckUs); - assert_eq!(1, *check_us); + assert_eq!(1, check_us.0); timings.saturating_add_in_place(ExecuteTimingType::CheckUs, 2); let check_us = timings.metrics.index(ExecuteTimingType::CheckUs); - assert_eq!(3, *check_us); + assert_eq!(3, check_us.0); } } diff --git a/unified-scheduler-pool/src/lib.rs b/unified-scheduler-pool/src/lib.rs index 61690f4ff3917f..4a27de9496bb8e 100644 --- a/unified-scheduler-pool/src/lib.rs +++ b/unified-scheduler-pool/src/lib.rs @@ -1806,7 +1806,7 @@ mod tests { let (result, timings) = bank.wait_for_completed_scheduler().unwrap(); assert_matches!(result, Ok(())); // ResultWithTimings should be carried over across active=>stale=>active transitions. - assert_eq!(timings.metrics[ExecuteTimingType::CheckUs], 246); + assert_eq!(timings.metrics[ExecuteTimingType::CheckUs].0, 246); } #[test]