Revert "Revert "Reformat imports to a consistent style for imports""
This reverts commit d7377d4794
.
This commit is contained in:
committed by
Tyera Eulberg
parent
9fff4aa8b8
commit
9f53f3455a
@@ -3,30 +3,32 @@
|
||||
|
||||
extern crate test;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use rand::Rng;
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use solana_runtime::{
|
||||
accounts::{create_test_accounts, AccountAddressFilter, Accounts},
|
||||
accounts_db::AccountShrinkThreshold,
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
ancestors::Ancestors,
|
||||
bank::*,
|
||||
use {
|
||||
dashmap::DashMap,
|
||||
rand::Rng,
|
||||
rayon::iter::{IntoParallelRefIterator, ParallelIterator},
|
||||
solana_runtime::{
|
||||
accounts::{create_test_accounts, AccountAddressFilter, Accounts},
|
||||
accounts_db::AccountShrinkThreshold,
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
ancestors::Ancestors,
|
||||
bank::*,
|
||||
},
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
genesis_config::{create_genesis_config, ClusterType},
|
||||
hash::Hash,
|
||||
lamports::LamportsError,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
thread::Builder,
|
||||
},
|
||||
test::Bencher,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
genesis_config::{create_genesis_config, ClusterType},
|
||||
hash::Hash,
|
||||
lamports::LamportsError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
thread::Builder,
|
||||
};
|
||||
use test::Bencher;
|
||||
|
||||
fn deposit_many(bank: &Bank, pubkeys: &mut Vec<Pubkey>, num: usize) -> Result<(), LamportsError> {
|
||||
for t in 0..num {
|
||||
|
@@ -2,13 +2,15 @@
|
||||
|
||||
extern crate test;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_runtime::{
|
||||
accounts_db::AccountInfo,
|
||||
accounts_index::{AccountSecondaryIndexes, AccountsIndex},
|
||||
use {
|
||||
rand::{thread_rng, Rng},
|
||||
solana_runtime::{
|
||||
accounts_db::AccountInfo,
|
||||
accounts_index::{AccountSecondaryIndexes, AccountsIndex},
|
||||
},
|
||||
solana_sdk::pubkey::{self, Pubkey},
|
||||
test::Bencher,
|
||||
};
|
||||
use solana_sdk::pubkey::{self, Pubkey};
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn bench_accounts_index(bencher: &mut Bencher) {
|
||||
|
@@ -1,19 +1,20 @@
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_runtime::append_vec::{
|
||||
test_utils::{create_test_account, get_append_vec_path},
|
||||
AppendVec,
|
||||
use {
|
||||
rand::{thread_rng, Rng},
|
||||
solana_runtime::append_vec::{
|
||||
test_utils::{create_test_account, get_append_vec_path},
|
||||
AppendVec,
|
||||
},
|
||||
solana_sdk::{account::ReadableAccount, hash::Hash},
|
||||
std::{
|
||||
sync::{Arc, Mutex},
|
||||
thread::{sleep, spawn},
|
||||
time::Duration,
|
||||
},
|
||||
test::Bencher,
|
||||
};
|
||||
use solana_sdk::{account::ReadableAccount, hash::Hash};
|
||||
use std::{
|
||||
sync::{Arc, Mutex},
|
||||
thread::sleep,
|
||||
thread::spawn,
|
||||
time::Duration,
|
||||
};
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn append_vec_append(bencher: &mut Bencher) {
|
||||
|
@@ -3,22 +3,23 @@
|
||||
|
||||
extern crate test;
|
||||
|
||||
use log::*;
|
||||
use solana_runtime::{bank::*, bank_client::BankClient, loader_utils::create_invoke_instruction};
|
||||
use solana_sdk::{
|
||||
client::AsyncClient,
|
||||
client::SyncClient,
|
||||
clock::MAX_RECENT_BLOCKHASHES,
|
||||
genesis_config::create_genesis_config,
|
||||
instruction::InstructionError,
|
||||
message::Message,
|
||||
process_instruction::InvokeContext,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
use {
|
||||
log::*,
|
||||
solana_runtime::{bank::*, bank_client::BankClient, loader_utils::create_invoke_instruction},
|
||||
solana_sdk::{
|
||||
client::{AsyncClient, SyncClient},
|
||||
clock::MAX_RECENT_BLOCKHASHES,
|
||||
genesis_config::create_genesis_config,
|
||||
instruction::InstructionError,
|
||||
message::Message,
|
||||
process_instruction::InvokeContext,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
},
|
||||
std::{sync::Arc, thread::sleep, time::Duration},
|
||||
test::Bencher,
|
||||
};
|
||||
use std::{sync::Arc, thread::sleep, time::Duration};
|
||||
use test::Bencher;
|
||||
|
||||
const BUILTIN_PROGRAM_ID: [u8; 32] = [
|
||||
98, 117, 105, 108, 116, 105, 110, 95, 112, 114, 111, 103, 114, 97, 109, 95, 105, 100, 0, 0, 0,
|
||||
|
@@ -1,17 +1,18 @@
|
||||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
use bv::BitVec;
|
||||
use fnv::FnvHasher;
|
||||
use rand::Rng;
|
||||
use solana_runtime::bloom::{AtomicBloom, Bloom, BloomHashIndex};
|
||||
use solana_sdk::{
|
||||
hash::{hash, Hash},
|
||||
signature::Signature,
|
||||
use {
|
||||
bv::BitVec,
|
||||
fnv::FnvHasher,
|
||||
rand::Rng,
|
||||
solana_runtime::bloom::{AtomicBloom, Bloom, BloomHashIndex},
|
||||
solana_sdk::{
|
||||
hash::{hash, Hash},
|
||||
signature::Signature,
|
||||
},
|
||||
std::{collections::HashSet, hash::Hasher},
|
||||
test::Bencher,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use std::hash::Hasher;
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
#[ignore]
|
||||
|
@@ -2,10 +2,12 @@
|
||||
|
||||
extern crate test;
|
||||
|
||||
use log::*;
|
||||
use solana_runtime::message_processor::{ExecuteDetailsTimings, PreAccount};
|
||||
use solana_sdk::{account::AccountSharedData, pubkey, rent::Rent};
|
||||
use test::Bencher;
|
||||
use {
|
||||
log::*,
|
||||
solana_runtime::message_processor::{ExecuteDetailsTimings, PreAccount},
|
||||
solana_sdk::{account::AccountSharedData, pubkey, rent::Rent},
|
||||
test::Bencher,
|
||||
};
|
||||
|
||||
#[bench]
|
||||
fn bench_verify_account_changes_data(bencher: &mut Bencher) {
|
||||
|
@@ -2,13 +2,15 @@
|
||||
|
||||
extern crate test;
|
||||
|
||||
use bincode::serialize;
|
||||
use solana_runtime::status_cache::*;
|
||||
use solana_sdk::{
|
||||
hash::{hash, Hash},
|
||||
signature::Signature,
|
||||
use {
|
||||
bincode::serialize,
|
||||
solana_runtime::status_cache::*,
|
||||
solana_sdk::{
|
||||
hash::{hash, Hash},
|
||||
signature::Signature,
|
||||
},
|
||||
test::Bencher,
|
||||
};
|
||||
use test::Bencher;
|
||||
|
||||
type BankStatusCache = StatusCache<()>;
|
||||
|
||||
|
@@ -1,47 +1,48 @@
|
||||
use crate::{
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, BankHashInfo, ErrorCounters,
|
||||
LoadHint, LoadedAccount, ScanStorageResult,
|
||||
use {
|
||||
crate::{
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, BankHashInfo, ErrorCounters,
|
||||
LoadHint, LoadedAccount, ScanStorageResult,
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::Ancestors,
|
||||
bank::{
|
||||
NonceRollbackFull, NonceRollbackInfo, RentDebits, TransactionCheckResult,
|
||||
TransactionExecutionResult,
|
||||
},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
rent_collector::RentCollector,
|
||||
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::Ancestors,
|
||||
bank::{
|
||||
NonceRollbackFull, NonceRollbackInfo, RentDebits, TransactionCheckResult,
|
||||
TransactionExecutionResult,
|
||||
dashmap::{
|
||||
mapref::entry::Entry::{Occupied, Vacant},
|
||||
DashMap,
|
||||
},
|
||||
log::*,
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
|
||||
feature_set::{self, FeatureSet},
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::ClusterType,
|
||||
hash::Hash,
|
||||
message::{Message, MessageProgramIdsCache},
|
||||
native_loader,
|
||||
nonce::{self, NONCED_TX_MARKER_IX_INDEX},
|
||||
pubkey::Pubkey,
|
||||
transaction::{Result, Transaction, TransactionError},
|
||||
},
|
||||
std::{
|
||||
cmp::Reverse,
|
||||
collections::{hash_map, BinaryHeap, HashMap, HashSet},
|
||||
ops::RangeBounds,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
rent_collector::RentCollector,
|
||||
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
|
||||
};
|
||||
use dashmap::{
|
||||
mapref::entry::Entry::{Occupied, Vacant},
|
||||
DashMap,
|
||||
};
|
||||
use log::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
|
||||
feature_set::{self, FeatureSet},
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::ClusterType,
|
||||
hash::Hash,
|
||||
message::{Message, MessageProgramIdsCache},
|
||||
native_loader, nonce,
|
||||
nonce::NONCED_TX_MARKER_IX_INDEX,
|
||||
pubkey::Pubkey,
|
||||
transaction::Result,
|
||||
transaction::{Transaction, TransactionError},
|
||||
};
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
collections::{hash_map, BinaryHeap, HashMap, HashSet},
|
||||
ops::RangeBounds,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, AbiExample)]
|
||||
@@ -1155,24 +1156,26 @@ pub fn update_accounts_bench(accounts: &Accounts, pubkeys: &[Pubkey], slot: u64)
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::rent_collector::RentCollector;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
epoch_schedule::EpochSchedule,
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::ClusterType,
|
||||
hash::Hash,
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
message::Message,
|
||||
nonce, nonce_account,
|
||||
rent::Rent,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
system_instruction, system_program,
|
||||
};
|
||||
use std::{
|
||||
sync::atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
{thread, time},
|
||||
use {
|
||||
super::*,
|
||||
crate::rent_collector::RentCollector,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
epoch_schedule::EpochSchedule,
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::ClusterType,
|
||||
hash::Hash,
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
message::Message,
|
||||
nonce, nonce_account,
|
||||
rent::Rent,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
system_instruction, system_program,
|
||||
},
|
||||
std::{
|
||||
sync::atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
thread, time,
|
||||
},
|
||||
};
|
||||
|
||||
fn load_accounts_with_fee_and_rent(
|
||||
|
@@ -2,29 +2,31 @@
|
||||
//
|
||||
// This can be expensive since we have to walk the append vecs being cleaned up.
|
||||
|
||||
use crate::{
|
||||
bank::{Bank, BankSlotDelta, DropCallback},
|
||||
bank_forks::{BankForks, SnapshotConfig},
|
||||
snapshot_package::AccountsPackageSender,
|
||||
snapshot_utils,
|
||||
};
|
||||
use crossbeam_channel::{Receiver, SendError, Sender};
|
||||
use log::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::{
|
||||
clock::{BankId, Slot},
|
||||
hash::Hash,
|
||||
};
|
||||
use std::{
|
||||
boxed::Box,
|
||||
fmt::{Debug, Formatter},
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc, RwLock,
|
||||
use {
|
||||
crate::{
|
||||
bank::{Bank, BankSlotDelta, DropCallback},
|
||||
bank_forks::{BankForks, SnapshotConfig},
|
||||
snapshot_package::AccountsPackageSender,
|
||||
snapshot_utils,
|
||||
},
|
||||
crossbeam_channel::{Receiver, SendError, Sender},
|
||||
log::*,
|
||||
rand::{thread_rng, Rng},
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{
|
||||
clock::{BankId, Slot},
|
||||
hash::Hash,
|
||||
},
|
||||
std::{
|
||||
boxed::Box,
|
||||
fmt::{Debug, Formatter},
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc, RwLock,
|
||||
},
|
||||
thread::{self, sleep, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
},
|
||||
thread::{self, sleep, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
const INTERVAL_MS: u64 = 100;
|
||||
@@ -455,10 +457,12 @@ impl AccountsBackgroundService {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::genesis_utils::create_genesis_config;
|
||||
use crossbeam_channel::unbounded;
|
||||
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey};
|
||||
use {
|
||||
super::*,
|
||||
crate::genesis_utils::create_genesis_config,
|
||||
crossbeam_channel::unbounded,
|
||||
solana_sdk::{account::AccountSharedData, pubkey::Pubkey},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_accounts_background_service_remove_dead_slots() {
|
||||
|
@@ -1,17 +1,19 @@
|
||||
use dashmap::DashMap;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
collections::BTreeSet,
|
||||
ops::Deref,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
Arc, RwLock,
|
||||
use {
|
||||
dashmap::DashMap,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
borrow::Borrow,
|
||||
collections::BTreeSet,
|
||||
ops::Deref,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
Arc, RwLock,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -18,61 +18,64 @@
|
||||
//! tracks the number of commits to the entire data store. So the latest
|
||||
//! commit for each slot entry would be indexed.
|
||||
|
||||
use crate::{
|
||||
accounts_background_service::{DroppedSlotsSender, SendDroppedBankCallback},
|
||||
accounts_cache::{AccountsCache, CachedAccount, SlotCache},
|
||||
accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats, PreviousPass},
|
||||
accounts_index::{
|
||||
AccountIndexGetResult, AccountSecondaryIndexes, AccountsIndex, AccountsIndexRootsStats,
|
||||
IndexKey, IsCached, ScanResult, SlotList, SlotSlice, ZeroLamport,
|
||||
},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::Ancestors,
|
||||
append_vec::{AppendVec, StoredAccountMeta, StoredMeta, StoredMetaWriteVersion},
|
||||
contains::Contains,
|
||||
pubkey_bins::PubkeyBinCalculator16,
|
||||
read_only_accounts_cache::ReadOnlyAccountsCache,
|
||||
sorted_storages::SortedStorages,
|
||||
};
|
||||
use blake3::traits::digest::Digest;
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use dashmap::{
|
||||
mapref::entry::Entry::{Occupied, Vacant},
|
||||
DashMap, DashSet,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
use log::*;
|
||||
use rand::{prelude::SliceRandom, thread_rng, Rng};
|
||||
use rayon::{prelude::*, ThreadPool};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::{BankId, Epoch, Slot},
|
||||
genesis_config::ClusterType,
|
||||
hash::{Hash, Hasher},
|
||||
pubkey::Pubkey,
|
||||
timing::AtomicInterval,
|
||||
};
|
||||
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
|
||||
use std::{
|
||||
borrow::{Borrow, Cow},
|
||||
boxed::Box,
|
||||
collections::{hash_map::Entry, BTreeSet, HashMap, HashSet},
|
||||
convert::TryFrom,
|
||||
io::{Error as IoError, Result as IoResult},
|
||||
ops::{Range, RangeBounds},
|
||||
path::{Path, PathBuf},
|
||||
sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
|
||||
sync::{Arc, Condvar, Mutex, MutexGuard, RwLock},
|
||||
thread::Builder,
|
||||
time::Instant,
|
||||
};
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[cfg(test)]
|
||||
use std::{thread::sleep, time::Duration};
|
||||
use {
|
||||
crate::{
|
||||
accounts_background_service::{DroppedSlotsSender, SendDroppedBankCallback},
|
||||
accounts_cache::{AccountsCache, CachedAccount, SlotCache},
|
||||
accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats, PreviousPass},
|
||||
accounts_index::{
|
||||
AccountIndexGetResult, AccountSecondaryIndexes, AccountsIndex, AccountsIndexRootsStats,
|
||||
IndexKey, IsCached, ScanResult, SlotList, SlotSlice, ZeroLamport,
|
||||
},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::Ancestors,
|
||||
append_vec::{AppendVec, StoredAccountMeta, StoredMeta, StoredMetaWriteVersion},
|
||||
contains::Contains,
|
||||
pubkey_bins::PubkeyBinCalculator16,
|
||||
read_only_accounts_cache::ReadOnlyAccountsCache,
|
||||
sorted_storages::SortedStorages,
|
||||
},
|
||||
blake3::traits::digest::Digest,
|
||||
crossbeam_channel::{unbounded, Receiver, Sender},
|
||||
dashmap::{
|
||||
mapref::entry::Entry::{Occupied, Vacant},
|
||||
DashMap, DashSet,
|
||||
},
|
||||
lazy_static::lazy_static,
|
||||
log::*,
|
||||
rand::{prelude::SliceRandom, thread_rng, Rng},
|
||||
rayon::{prelude::*, ThreadPool},
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_measure::measure::Measure,
|
||||
solana_rayon_threadlimit::get_thread_count,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::{BankId, Epoch, Slot},
|
||||
genesis_config::ClusterType,
|
||||
hash::{Hash, Hasher},
|
||||
pubkey::Pubkey,
|
||||
timing::AtomicInterval,
|
||||
},
|
||||
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
|
||||
std::{
|
||||
borrow::{Borrow, Cow},
|
||||
boxed::Box,
|
||||
collections::{hash_map::Entry, BTreeSet, HashMap, HashSet},
|
||||
convert::TryFrom,
|
||||
io::{Error as IoError, Result as IoResult},
|
||||
ops::{Range, RangeBounds},
|
||||
path::{Path, PathBuf},
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
|
||||
Arc, Condvar, Mutex, MutexGuard, RwLock,
|
||||
},
|
||||
thread::Builder,
|
||||
time::Instant,
|
||||
},
|
||||
tempfile::TempDir,
|
||||
};
|
||||
|
||||
const PAGE_SIZE: u64 = 4 * 1024;
|
||||
const MAX_RECYCLE_STORES: usize = 1000;
|
||||
@@ -6328,26 +6331,29 @@ impl AccountsDb {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
accounts_hash::MERKLE_FANOUT,
|
||||
accounts_index::RefCount,
|
||||
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude},
|
||||
append_vec::{test_utils::TempFile, AccountMeta},
|
||||
inline_spl_token,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::{
|
||||
account::{accounts_equal, Account, AccountSharedData, ReadableAccount, WritableAccount},
|
||||
hash::HASH_BYTES,
|
||||
pubkey::PUBKEY_BYTES,
|
||||
};
|
||||
use std::{
|
||||
iter::FromIterator,
|
||||
str::FromStr,
|
||||
thread::{self, sleep, Builder, JoinHandle},
|
||||
time::Duration,
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
accounts_hash::MERKLE_FANOUT,
|
||||
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude, RefCount},
|
||||
append_vec::{test_utils::TempFile, AccountMeta},
|
||||
inline_spl_token,
|
||||
},
|
||||
assert_matches::assert_matches,
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::{
|
||||
account::{
|
||||
accounts_equal, Account, AccountSharedData, ReadableAccount, WritableAccount,
|
||||
},
|
||||
hash::HASH_BYTES,
|
||||
pubkey::PUBKEY_BYTES,
|
||||
},
|
||||
std::{
|
||||
iter::FromIterator,
|
||||
str::FromStr,
|
||||
thread::{self, sleep, Builder, JoinHandle},
|
||||
time::Duration,
|
||||
},
|
||||
};
|
||||
|
||||
fn linear_ancestors(end_slot: u64) -> Ancestors {
|
||||
|
@@ -1,11 +1,13 @@
|
||||
use log::*;
|
||||
use rayon::prelude::*;
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::{
|
||||
hash::{Hash, Hasher},
|
||||
pubkey::Pubkey,
|
||||
use {
|
||||
log::*,
|
||||
rayon::prelude::*,
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{
|
||||
hash::{Hash, Hasher},
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{convert::TryInto, sync::Mutex},
|
||||
};
|
||||
use std::{convert::TryInto, sync::Mutex};
|
||||
|
||||
pub const ZERO_RAW_LAMPORTS_SENTINEL: u64 = std::u64::MAX;
|
||||
pub const MERKLE_FANOUT: usize = 16;
|
||||
@@ -782,8 +784,7 @@ impl AccountsHash {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use std::str::FromStr;
|
||||
use {super::*, std::str::FromStr};
|
||||
|
||||
#[test]
|
||||
fn test_accountsdb_div_ceil() {
|
||||
|
@@ -1,33 +1,35 @@
|
||||
use crate::{
|
||||
ancestors::Ancestors,
|
||||
contains::Contains,
|
||||
inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
||||
secondary_index::*,
|
||||
};
|
||||
use bv::BitVec;
|
||||
use log::*;
|
||||
use ouroboros::self_referencing;
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::{
|
||||
clock::{BankId, Slot},
|
||||
pubkey::{Pubkey, PUBKEY_BYTES},
|
||||
};
|
||||
use std::{
|
||||
collections::{
|
||||
btree_map::{self, BTreeMap, Entry},
|
||||
HashSet,
|
||||
use {
|
||||
crate::{
|
||||
ancestors::Ancestors,
|
||||
contains::Contains,
|
||||
inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
||||
secondary_index::*,
|
||||
},
|
||||
ops::{
|
||||
Bound,
|
||||
Bound::{Excluded, Included, Unbounded},
|
||||
Range, RangeBounds,
|
||||
bv::BitVec,
|
||||
log::*,
|
||||
ouroboros::self_referencing,
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{
|
||||
clock::{BankId, Slot},
|
||||
pubkey::{Pubkey, PUBKEY_BYTES},
|
||||
},
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard,
|
||||
std::{
|
||||
collections::{
|
||||
btree_map::{self, BTreeMap, Entry},
|
||||
HashSet,
|
||||
},
|
||||
ops::{
|
||||
Bound,
|
||||
Bound::{Excluded, Included, Unbounded},
|
||||
Range, RangeBounds,
|
||||
},
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard,
|
||||
},
|
||||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
pub const ITER_BATCH_SIZE: usize = 1000;
|
||||
const BINS: usize = 16;
|
||||
@@ -1733,8 +1735,10 @@ impl<T: 'static + Clone + IsCached + ZeroLamport + std::marker::Sync + std::mark
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::signature::{Keypair, Signer};
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::signature::{Keypair, Signer},
|
||||
};
|
||||
|
||||
pub enum SecondaryIndexTypes<'a> {
|
||||
RwLock(&'a SecondaryIndex<RwLockSecondaryIndexEntry>),
|
||||
|
@@ -1,6 +1,4 @@
|
||||
use crate::accounts_index::RollingBitField;
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::collections::HashMap;
|
||||
use {crate::accounts_index::RollingBitField, solana_sdk::clock::Slot, std::collections::HashMap};
|
||||
|
||||
pub type AncestorsForSerialization = HashMap<Slot, usize>;
|
||||
|
||||
@@ -82,11 +80,10 @@ impl Ancestors {
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::contains::Contains;
|
||||
use log::*;
|
||||
use solana_measure::measure::Measure;
|
||||
use std::collections::HashSet;
|
||||
use {
|
||||
super::*, crate::contains::Contains, log::*, solana_measure::measure::Measure,
|
||||
std::collections::HashSet,
|
||||
};
|
||||
|
||||
impl std::iter::FromIterator<(Slot, usize)> for Ancestors {
|
||||
fn from_iter<I>(iter: I) -> Self
|
||||
|
@@ -1,24 +1,27 @@
|
||||
//! Persistent storage for accounts. For more information, see:
|
||||
//! https://docs.solana.com/implemented-proposals/persistent-account-storage
|
||||
|
||||
use log::*;
|
||||
use memmap2::MmapMut;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount},
|
||||
clock::{Epoch, Slot},
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
fs::{remove_file, OpenOptions},
|
||||
io,
|
||||
io::{Seek, SeekFrom, Write},
|
||||
mem,
|
||||
path::{Path, PathBuf},
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
sync::Mutex,
|
||||
use {
|
||||
log::*,
|
||||
memmap2::MmapMut,
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount},
|
||||
clock::{Epoch, Slot},
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
borrow::Borrow,
|
||||
fs::{remove_file, OpenOptions},
|
||||
io::{self, Seek, SeekFrom, Write},
|
||||
mem,
|
||||
path::{Path, PathBuf},
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Mutex,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Data placement should be aligned at the next boundary. Without alignment accessing the memory may
|
||||
@@ -526,13 +529,12 @@ impl AppendVec {
|
||||
}
|
||||
|
||||
pub mod test_utils {
|
||||
use super::StoredMeta;
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::account::AccountSharedData;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::fs::create_dir_all;
|
||||
use std::path::PathBuf;
|
||||
use {
|
||||
super::StoredMeta,
|
||||
rand::{distributions::Alphanumeric, thread_rng, Rng},
|
||||
solana_sdk::{account::AccountSharedData, pubkey::Pubkey},
|
||||
std::{fs::create_dir_all, path::PathBuf},
|
||||
};
|
||||
|
||||
pub struct TempFile {
|
||||
pub path: PathBuf,
|
||||
@@ -575,12 +577,13 @@ pub mod test_utils {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::test_utils::*;
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::{account::WritableAccount, timing::duration_as_ms};
|
||||
use std::time::Instant;
|
||||
use {
|
||||
super::{test_utils::*, *},
|
||||
assert_matches::assert_matches,
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::{account::WritableAccount, timing::duration_as_ms},
|
||||
std::time::Instant,
|
||||
};
|
||||
|
||||
impl AppendVec {
|
||||
fn append_account_test(&self, data: &(StoredMeta, AccountSharedData)) -> Option<usize> {
|
||||
|
@@ -33,111 +33,112 @@
|
||||
//! It offers a high-level API that signs transactions
|
||||
//! on behalf of the caller, and a low-level API for when they have
|
||||
//! already been signed and verified.
|
||||
use crate::{
|
||||
accounts::{
|
||||
AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult,
|
||||
TransactionLoaders,
|
||||
use {
|
||||
crate::{
|
||||
accounts::{
|
||||
AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult,
|
||||
TransactionLoaders,
|
||||
},
|
||||
accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::{Ancestors, AncestorsForSerialization},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{self, ActivationType},
|
||||
cost_tracker::CostTracker,
|
||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||
hashed_transaction::{HashedTransaction, HashedTransactionSlice},
|
||||
inline_spl_token,
|
||||
instruction_recorder::InstructionRecorder,
|
||||
log_collector::LogCollector,
|
||||
message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor},
|
||||
rent_collector::RentCollector,
|
||||
stake_weighted_timestamp::{
|
||||
calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE,
|
||||
MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW,
|
||||
},
|
||||
stakes::Stakes,
|
||||
status_cache::{SlotDelta, StatusCache},
|
||||
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
|
||||
transaction_batch::TransactionBatch,
|
||||
vote_account::ArcVoteAccount,
|
||||
},
|
||||
accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||
ancestors::{Ancestors, AncestorsForSerialization},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{self, ActivationType},
|
||||
cost_tracker::CostTracker,
|
||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||
hashed_transaction::{HashedTransaction, HashedTransactionSlice},
|
||||
inline_spl_token,
|
||||
instruction_recorder::InstructionRecorder,
|
||||
log_collector::LogCollector,
|
||||
message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor},
|
||||
rent_collector::RentCollector,
|
||||
stake_weighted_timestamp::{
|
||||
calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE,
|
||||
MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW,
|
||||
byteorder::{ByteOrder, LittleEndian},
|
||||
dashmap::DashMap,
|
||||
itertools::Itertools,
|
||||
log::*,
|
||||
rayon::{
|
||||
iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator},
|
||||
ThreadPool, ThreadPoolBuilder,
|
||||
},
|
||||
stakes::Stakes,
|
||||
status_cache::{SlotDelta, StatusCache},
|
||||
system_instruction_processor::{get_system_account_kind, SystemAccountKind},
|
||||
transaction_batch::TransactionBatch,
|
||||
vote_account::ArcVoteAccount,
|
||||
};
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use dashmap::DashMap;
|
||||
use itertools::Itertools;
|
||||
use log::*;
|
||||
use rayon::{
|
||||
iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator},
|
||||
ThreadPool, ThreadPoolBuilder,
|
||||
};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
|
||||
use solana_sdk::{
|
||||
account::{
|
||||
create_account_shared_data_with_fields as create_account, from_account, Account,
|
||||
AccountSharedData, InheritableAccountFields, ReadableAccount, WritableAccount,
|
||||
solana_measure::measure::Measure,
|
||||
solana_metrics::{inc_new_counter_debug, inc_new_counter_info},
|
||||
solana_sdk::{
|
||||
account::{
|
||||
create_account_shared_data_with_fields as create_account, from_account, Account,
|
||||
AccountSharedData, InheritableAccountFields, ReadableAccount, WritableAccount,
|
||||
},
|
||||
account_utils::StateMut,
|
||||
clock::{
|
||||
BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND,
|
||||
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES,
|
||||
MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY,
|
||||
},
|
||||
compute_budget,
|
||||
epoch_info::EpochInfo,
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature,
|
||||
feature_set::{self, tx_wide_compute_cap, FeatureSet},
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
hard_forks::HardForks,
|
||||
hash::{extend_and_hash, hashv, Hash},
|
||||
incinerator,
|
||||
inflation::Inflation,
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
lamports::LamportsError,
|
||||
message::Message,
|
||||
native_loader,
|
||||
native_token::sol_to_lamports,
|
||||
nonce, nonce_account,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, ComputeMeter, Executor, ProcessInstructionWithContext,
|
||||
},
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
recent_blockhashes_account,
|
||||
sanitize::Sanitize,
|
||||
signature::{Keypair, Signature},
|
||||
slot_hashes::SlotHashes,
|
||||
slot_history::SlotHistory,
|
||||
system_transaction,
|
||||
sysvar::{self},
|
||||
timing::years_as_slots,
|
||||
transaction::{self, Result, Transaction, TransactionError},
|
||||
},
|
||||
account_utils::StateMut,
|
||||
clock::{
|
||||
BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND,
|
||||
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES,
|
||||
MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY,
|
||||
solana_stake_program::stake_state::{
|
||||
self, Delegation, InflationPointCalculationEvent, PointValue, StakeState,
|
||||
},
|
||||
compute_budget,
|
||||
epoch_info::EpochInfo,
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature,
|
||||
feature_set::{self, tx_wide_compute_cap, FeatureSet},
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
hard_forks::HardForks,
|
||||
hash::{extend_and_hash, hashv, Hash},
|
||||
incinerator,
|
||||
inflation::Inflation,
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
lamports::LamportsError,
|
||||
message::Message,
|
||||
native_loader,
|
||||
native_token::sol_to_lamports,
|
||||
nonce, nonce_account,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, ComputeMeter, Executor, ProcessInstructionWithContext,
|
||||
solana_vote_program::{
|
||||
vote_instruction::VoteInstruction,
|
||||
vote_state::{VoteState, VoteStateVersions},
|
||||
},
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
recent_blockhashes_account,
|
||||
sanitize::Sanitize,
|
||||
signature::{Keypair, Signature},
|
||||
slot_hashes::SlotHashes,
|
||||
slot_history::SlotHistory,
|
||||
system_transaction,
|
||||
sysvar::{self},
|
||||
timing::years_as_slots,
|
||||
transaction::{self, Result, Transaction, TransactionError},
|
||||
};
|
||||
use solana_stake_program::stake_state::{
|
||||
self, Delegation, InflationPointCalculationEvent, PointValue, StakeState,
|
||||
};
|
||||
use solana_vote_program::{
|
||||
vote_instruction::VoteInstruction,
|
||||
vote_state::{VoteState, VoteStateVersions},
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
collections::{HashMap, HashSet},
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt, mem,
|
||||
ops::RangeInclusive,
|
||||
path::PathBuf,
|
||||
ptr,
|
||||
rc::Rc,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, Ordering::Relaxed},
|
||||
LockResult, RwLockWriteGuard, {Arc, RwLock, RwLockReadGuard},
|
||||
std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
collections::{HashMap, HashSet},
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt, mem,
|
||||
ops::RangeInclusive,
|
||||
path::PathBuf,
|
||||
ptr,
|
||||
rc::Rc,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, Ordering::Relaxed},
|
||||
Arc, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard,
|
||||
},
|
||||
time::{Duration, Instant},
|
||||
},
|
||||
time::Duration,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
pub const SECONDS_PER_YEAR: f64 = 365.25 * 24.0 * 60.0 * 60.0;
|
||||
@@ -6053,52 +6054,55 @@ fn is_simple_vote_transaction(transaction: &Transaction) -> bool {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
accounts_background_service::{AbsRequestHandler, SendDroppedBankCallback},
|
||||
accounts_db::DEFAULT_ACCOUNTS_SHRINK_RATIO,
|
||||
accounts_index::{
|
||||
AccountIndex, AccountMap, AccountSecondaryIndexes, ScanError, ITER_BATCH_SIZE,
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
accounts_background_service::{AbsRequestHandler, SendDroppedBankCallback},
|
||||
accounts_db::DEFAULT_ACCOUNTS_SHRINK_RATIO,
|
||||
accounts_index::{
|
||||
AccountIndex, AccountMap, AccountSecondaryIndexes, ScanError, ITER_BATCH_SIZE,
|
||||
},
|
||||
ancestors::Ancestors,
|
||||
genesis_utils::{
|
||||
activate_all_features, bootstrap_validator_stake_lamports,
|
||||
create_genesis_config_with_leader, create_genesis_config_with_vote_accounts,
|
||||
GenesisConfigInfo, ValidatorVoteKeypairs,
|
||||
},
|
||||
status_cache::MAX_CACHE_ENTRIES,
|
||||
},
|
||||
ancestors::Ancestors,
|
||||
genesis_utils::{
|
||||
activate_all_features, bootstrap_validator_stake_lamports,
|
||||
create_genesis_config_with_leader, create_genesis_config_with_vote_accounts,
|
||||
GenesisConfigInfo, ValidatorVoteKeypairs,
|
||||
crossbeam_channel::{bounded, unbounded},
|
||||
solana_sdk::{
|
||||
account::Account,
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
|
||||
compute_budget,
|
||||
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
|
||||
feature::Feature,
|
||||
genesis_config::create_genesis_config,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||
message::{Message, MessageHeader},
|
||||
nonce,
|
||||
poh_config::PohConfig,
|
||||
process_instruction::InvokeContext,
|
||||
rent::Rent,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
stake::{
|
||||
instruction as stake_instruction,
|
||||
state::{Authorized, Delegation, Lockup, Stake},
|
||||
},
|
||||
system_instruction::{self, SystemError},
|
||||
system_program,
|
||||
sysvar::{fees::Fees, rewards::Rewards},
|
||||
timing::duration_as_s,
|
||||
},
|
||||
status_cache::MAX_CACHE_ENTRIES,
|
||||
solana_vote_program::{
|
||||
vote_instruction,
|
||||
vote_state::{
|
||||
self, BlockTimestamp, Vote, VoteInit, VoteState, VoteStateVersions,
|
||||
MAX_LOCKOUT_HISTORY,
|
||||
},
|
||||
},
|
||||
std::{result, thread::Builder, time::Duration},
|
||||
};
|
||||
use crossbeam_channel::{bounded, unbounded};
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
|
||||
compute_budget,
|
||||
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
|
||||
feature::Feature,
|
||||
genesis_config::create_genesis_config,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||
message::{Message, MessageHeader},
|
||||
nonce,
|
||||
poh_config::PohConfig,
|
||||
process_instruction::InvokeContext,
|
||||
rent::Rent,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
stake::{
|
||||
instruction as stake_instruction,
|
||||
state::{Authorized, Delegation, Lockup, Stake},
|
||||
},
|
||||
system_instruction::{self, SystemError},
|
||||
system_program,
|
||||
sysvar::{fees::Fees, rewards::Rewards},
|
||||
timing::duration_as_s,
|
||||
};
|
||||
use solana_vote_program::{
|
||||
vote_instruction,
|
||||
vote_state::{
|
||||
self, BlockTimestamp, Vote, VoteInit, VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY,
|
||||
},
|
||||
};
|
||||
use std::{result, thread::Builder, time::Duration};
|
||||
|
||||
#[test]
|
||||
fn test_nonce_rollback_info() {
|
||||
|
@@ -1,28 +1,30 @@
|
||||
use crate::bank::Bank;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
client::{AsyncClient, Client, SyncClient},
|
||||
commitment_config::CommitmentConfig,
|
||||
epoch_info::EpochInfo,
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
hash::Hash,
|
||||
instruction::Instruction,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signature, Signer},
|
||||
signers::Signers,
|
||||
system_instruction,
|
||||
transaction::{self, Transaction},
|
||||
transport::{Result, TransportError},
|
||||
};
|
||||
use std::{
|
||||
io,
|
||||
sync::{
|
||||
mpsc::{channel, Receiver, Sender},
|
||||
Arc, Mutex,
|
||||
use {
|
||||
crate::bank::Bank,
|
||||
solana_sdk::{
|
||||
account::Account,
|
||||
client::{AsyncClient, Client, SyncClient},
|
||||
commitment_config::CommitmentConfig,
|
||||
epoch_info::EpochInfo,
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
hash::Hash,
|
||||
instruction::Instruction,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signature, Signer},
|
||||
signers::Signers,
|
||||
system_instruction,
|
||||
transaction::{self, Transaction},
|
||||
transport::{Result, TransportError},
|
||||
},
|
||||
std::{
|
||||
io,
|
||||
sync::{
|
||||
mpsc::{channel, Receiver, Sender},
|
||||
Arc, Mutex,
|
||||
},
|
||||
thread::{sleep, Builder},
|
||||
time::{Duration, Instant},
|
||||
},
|
||||
thread::{sleep, Builder},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
pub struct BankClient {
|
||||
@@ -307,8 +309,10 @@ impl BankClient {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{genesis_config::create_genesis_config, instruction::AccountMeta};
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::{genesis_config::create_genesis_config, instruction::AccountMeta},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_bank_client_new_with_keypairs() {
|
||||
|
@@ -1,21 +1,22 @@
|
||||
//! The `bank_forks` module implements BankForks a DAG of checkpointed Banks
|
||||
|
||||
use crate::{
|
||||
accounts_background_service::{AbsRequestSender, SnapshotRequest},
|
||||
bank::Bank,
|
||||
};
|
||||
use log::*;
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::{clock::Slot, hash::Hash, timing};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
ops::Index,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
pub use crate::snapshot_utils::SnapshotVersion;
|
||||
use {
|
||||
crate::{
|
||||
accounts_background_service::{AbsRequestSender, SnapshotRequest},
|
||||
bank::Bank,
|
||||
},
|
||||
log::*,
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{clock::Slot, hash::Hash, timing},
|
||||
std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
ops::Index,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ArchiveFormat {
|
||||
@@ -521,21 +522,23 @@ impl BankForks {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
bank::tests::update_vote_account_timestamp,
|
||||
genesis_utils::{
|
||||
create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo,
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
bank::tests::update_vote_account_timestamp,
|
||||
genesis_utils::{
|
||||
create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo,
|
||||
},
|
||||
},
|
||||
solana_sdk::{
|
||||
clock::UnixTimestamp,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
sysvar::epoch_schedule::EpochSchedule,
|
||||
},
|
||||
solana_vote_program::vote_state::BlockTimestamp,
|
||||
};
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::{
|
||||
clock::UnixTimestamp,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
sysvar::epoch_schedule::EpochSchedule,
|
||||
};
|
||||
use solana_vote_program::vote_state::BlockTimestamp;
|
||||
|
||||
#[test]
|
||||
fn test_bank_forks_new() {
|
||||
|
@@ -1,11 +1,13 @@
|
||||
use crate::{
|
||||
bank::{Bank, TransactionResults},
|
||||
genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
|
||||
hashed_transaction::HashedTransaction,
|
||||
vote_sender_types::ReplayVoteSender,
|
||||
use {
|
||||
crate::{
|
||||
bank::{Bank, TransactionResults},
|
||||
genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
|
||||
hashed_transaction::HashedTransaction,
|
||||
vote_sender_types::ReplayVoteSender,
|
||||
},
|
||||
solana_sdk::{pubkey::Pubkey, signature::Signer},
|
||||
solana_vote_program::vote_transaction,
|
||||
};
|
||||
use solana_sdk::{pubkey::Pubkey, signature::Signer};
|
||||
use solana_vote_program::vote_transaction;
|
||||
|
||||
pub fn setup_bank_and_vote_pubkeys(num_vote_accounts: usize, stake: u64) -> (Bank, Vec<Pubkey>) {
|
||||
// Create some voters at genesis
|
||||
|
@@ -1,10 +1,12 @@
|
||||
//! defines block cost related limits
|
||||
//!
|
||||
use lazy_static::lazy_static;
|
||||
use solana_sdk::{
|
||||
feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program, system_program,
|
||||
use {
|
||||
lazy_static::lazy_static,
|
||||
solana_sdk::{
|
||||
feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program, system_program,
|
||||
},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Static configurations:
|
||||
///
|
||||
|
@@ -1,8 +1,10 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::{
|
||||
fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp,
|
||||
use {
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_sdk::{
|
||||
fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp,
|
||||
},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
||||
struct HashAge {
|
||||
@@ -133,10 +135,12 @@ impl BlockhashQueue {
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem,
|
||||
use {
|
||||
super::*,
|
||||
bincode::serialize,
|
||||
solana_sdk::{
|
||||
clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem,
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@@ -1,12 +1,17 @@
|
||||
//! Simple Bloom Filter
|
||||
use bv::BitVec;
|
||||
use fnv::FnvHasher;
|
||||
use rand::{self, Rng};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::sanitize::{Sanitize, SanitizeError};
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::{cmp, hash::Hasher, marker::PhantomData};
|
||||
use {
|
||||
bv::BitVec,
|
||||
fnv::FnvHasher,
|
||||
rand::{self, Rng},
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_sdk::sanitize::{Sanitize, SanitizeError},
|
||||
std::{
|
||||
cmp, fmt,
|
||||
hash::Hasher,
|
||||
marker::PhantomData,
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
/// Generate a stable hash of `self` for each `hash_index`
|
||||
/// Best effort can be made for uniqueness of each hash.
|
||||
@@ -217,9 +222,11 @@ impl<T: BloomHashIndex> From<AtomicBloom<T>> for Bloom<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use rayon::prelude::*;
|
||||
use solana_sdk::hash::{hash, Hash};
|
||||
use {
|
||||
super::*,
|
||||
rayon::prelude::*,
|
||||
solana_sdk::hash::{hash, Hash},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_bloom_filter() {
|
||||
|
@@ -1,13 +1,15 @@
|
||||
use crate::{
|
||||
bank::{Builtin, Builtins},
|
||||
system_instruction_processor,
|
||||
};
|
||||
use solana_sdk::{
|
||||
feature_set,
|
||||
instruction::InstructionError,
|
||||
process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext},
|
||||
pubkey::Pubkey,
|
||||
stake, system_program,
|
||||
use {
|
||||
crate::{
|
||||
bank::{Builtin, Builtins},
|
||||
system_instruction_processor,
|
||||
},
|
||||
solana_sdk::{
|
||||
feature_set,
|
||||
instruction::InstructionError,
|
||||
process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext},
|
||||
pubkey::Pubkey,
|
||||
stake, system_program,
|
||||
},
|
||||
};
|
||||
|
||||
fn process_instruction_with_program_logging(
|
||||
|
@@ -1,6 +1,8 @@
|
||||
use solana_sdk::{clock::Slot, commitment_config::CommitmentLevel};
|
||||
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
|
||||
use std::collections::HashMap;
|
||||
use {
|
||||
solana_sdk::{clock::Slot, commitment_config::CommitmentLevel},
|
||||
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
|
||||
std::collections::HashMap,
|
||||
};
|
||||
|
||||
pub const VOTE_THRESHOLD_SIZE: f64 = 2f64 / 3f64;
|
||||
|
||||
|
@@ -4,10 +4,12 @@
|
||||
//!
|
||||
//! The main function is `calculate_cost` which returns &TransactionCost.
|
||||
//!
|
||||
use crate::{block_cost_limits::*, execute_cost_table::ExecuteCostTable};
|
||||
use log::*;
|
||||
use solana_sdk::{pubkey::Pubkey, transaction::Transaction};
|
||||
use std::collections::HashMap;
|
||||
use {
|
||||
crate::{block_cost_limits::*, execute_cost_table::ExecuteCostTable},
|
||||
log::*,
|
||||
solana_sdk::{pubkey::Pubkey, transaction::Transaction},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
|
||||
const MAX_WRITABLE_ACCOUNTS: usize = 256;
|
||||
|
||||
@@ -180,24 +182,26 @@ impl CostModel {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
};
|
||||
use solana_sdk::{
|
||||
bpf_loader,
|
||||
hash::Hash,
|
||||
instruction::CompiledInstruction,
|
||||
message::Message,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction::{self},
|
||||
system_program, system_transaction,
|
||||
};
|
||||
use std::{
|
||||
str::FromStr,
|
||||
sync::{Arc, RwLock},
|
||||
thread::{self, JoinHandle},
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
},
|
||||
solana_sdk::{
|
||||
bpf_loader,
|
||||
hash::Hash,
|
||||
instruction::CompiledInstruction,
|
||||
message::Message,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction::{self},
|
||||
system_program, system_transaction,
|
||||
},
|
||||
std::{
|
||||
str::FromStr,
|
||||
sync::{Arc, RwLock},
|
||||
thread::{self, JoinHandle},
|
||||
},
|
||||
};
|
||||
|
||||
fn test_setup() -> (Keypair, Hash) {
|
||||
|
@@ -3,10 +3,11 @@
|
||||
//! - would_transaction_fit(&tx_cost), immutable function to test if tx with tx_cost would fit into current block
|
||||
//! - add_transaction_cost(&tx_cost), mutable function to accumulate tx_cost to tracker.
|
||||
//!
|
||||
use crate::block_cost_limits::*;
|
||||
use crate::cost_model::TransactionCost;
|
||||
use solana_sdk::{clock::Slot, pubkey::Pubkey, transaction::Transaction};
|
||||
use std::collections::HashMap;
|
||||
use {
|
||||
crate::{block_cost_limits::*, cost_model::TransactionCost},
|
||||
solana_sdk::{clock::Slot, pubkey::Pubkey, transaction::Transaction},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
|
||||
const WRITABLE_ACCOUNTS_PER_BLOCK: usize = 512;
|
||||
|
||||
@@ -153,18 +154,20 @@ impl CostTracker {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
},
|
||||
solana_sdk::{
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
system_transaction,
|
||||
transaction::Transaction,
|
||||
},
|
||||
std::{cmp, sync::Arc},
|
||||
};
|
||||
use solana_sdk::{
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
system_transaction,
|
||||
transaction::Transaction,
|
||||
};
|
||||
use std::{cmp, sync::Arc};
|
||||
|
||||
fn test_setup() -> (Keypair, Hash) {
|
||||
solana_logger::setup();
|
||||
|
@@ -1,7 +1,9 @@
|
||||
use crate::{stakes::Stakes, vote_account::ArcVoteAccount};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::{clock::Epoch, pubkey::Pubkey};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use {
|
||||
crate::{stakes::Stakes, vote_account::ArcVoteAccount},
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_sdk::{clock::Epoch, pubkey::Pubkey},
|
||||
std::{collections::HashMap, sync::Arc},
|
||||
};
|
||||
|
||||
pub type NodeIdToVoteAccounts = HashMap<Pubkey, NodeVoteAccounts>;
|
||||
pub type EpochAuthorizedVoters = HashMap<Pubkey, Pubkey>;
|
||||
@@ -115,10 +117,10 @@ impl EpochStakes {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::account::AccountSharedData;
|
||||
use solana_vote_program::vote_state::create_account_with_authorized;
|
||||
use std::iter;
|
||||
use {
|
||||
super::*, solana_sdk::account::AccountSharedData,
|
||||
solana_vote_program::vote_state::create_account_with_authorized, std::iter,
|
||||
};
|
||||
|
||||
struct VoteAccountInfo {
|
||||
vote_account: Pubkey,
|
||||
|
@@ -4,8 +4,7 @@
|
||||
/// When its capacity limit is reached, it prunes old and less-used programs
|
||||
/// to make room for new ones.
|
||||
use log::*;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::collections::HashMap;
|
||||
use {solana_sdk::pubkey::Pubkey, std::collections::HashMap};
|
||||
|
||||
// prune is rather expensive op, free up bulk space in each operation
|
||||
// would be more efficient. PRUNE_RATIO defines the after prune table
|
||||
|
@@ -1,19 +1,20 @@
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
account::AccountSharedData,
|
||||
feature::{self, Feature},
|
||||
feature_set::FeatureSet,
|
||||
fee_calculator::FeeRateGovernor,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
signature::{Keypair, Signer},
|
||||
stake::state::StakeState,
|
||||
system_program,
|
||||
use {
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
feature::{self, Feature},
|
||||
feature_set::FeatureSet,
|
||||
fee_calculator::FeeRateGovernor,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
signature::{Keypair, Signer},
|
||||
stake::state::StakeState,
|
||||
system_program,
|
||||
},
|
||||
solana_stake_program::stake_state,
|
||||
solana_vote_program::vote_state,
|
||||
std::borrow::Borrow,
|
||||
};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state;
|
||||
use std::borrow::Borrow;
|
||||
|
||||
// Default amount received by the validator
|
||||
const VALIDATOR_LAMPORTS: u64 = 42;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
use solana_sdk::genesis_config::{DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE};
|
||||
use {
|
||||
bzip2::bufread::BzDecoder,
|
||||
log::*,
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::genesis_config::GenesisConfig,
|
||||
solana_sdk::genesis_config::{GenesisConfig, DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE},
|
||||
std::{
|
||||
collections::HashMap,
|
||||
fs::{self, File},
|
||||
@@ -474,9 +473,11 @@ fn is_valid_genesis_archive_entry(parts: &[&str], kind: tar::EntryType) -> bool
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use tar::{Builder, Header};
|
||||
use {
|
||||
super::*,
|
||||
assert_matches::assert_matches,
|
||||
tar::{Builder, Header},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_archive_is_valid_entry() {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
use solana_sdk::{hash::Hash, transaction::Transaction, vote};
|
||||
use std::borrow::Cow;
|
||||
use {
|
||||
solana_sdk::{hash::Hash, transaction::Transaction, vote},
|
||||
std::borrow::Cow,
|
||||
};
|
||||
|
||||
/// Transaction and the hash of its message
|
||||
#[derive(Debug, Clone)]
|
||||
|
@@ -1,8 +1,9 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use solana_sdk::{
|
||||
instruction::{CompiledInstruction, Instruction},
|
||||
message::Message,
|
||||
use {
|
||||
solana_sdk::{
|
||||
instruction::{CompiledInstruction, Instruction},
|
||||
message::Message,
|
||||
},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
};
|
||||
|
||||
/// Records and compiles cross-program invoked instructions
|
||||
|
@@ -1,13 +1,15 @@
|
||||
use serde::Serialize;
|
||||
use solana_sdk::{
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
client::Client,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
loader_instruction,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction,
|
||||
use {
|
||||
serde::Serialize,
|
||||
solana_sdk::{
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
client::Client,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
loader_instruction,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn load_program<T: Client>(
|
||||
|
@@ -1,39 +1,41 @@
|
||||
use crate::{
|
||||
accounts::Accounts, ancestors::Ancestors, instruction_recorder::InstructionRecorder,
|
||||
log_collector::LogCollector, native_loader::NativeLoader, rent_collector::RentCollector,
|
||||
};
|
||||
use log::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
feature_set::{
|
||||
demote_program_write_locks, fix_write_privs, instructions_sysvar_enabled,
|
||||
neon_evm_compute_budget, remove_native_loader, requestable_heap_size, tx_wide_compute_cap,
|
||||
updated_verify_policy, FeatureSet,
|
||||
use {
|
||||
crate::{
|
||||
accounts::Accounts, ancestors::Ancestors, instruction_recorder::InstructionRecorder,
|
||||
log_collector::LogCollector, native_loader::NativeLoader, rent_collector::RentCollector,
|
||||
},
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
||||
message::Message,
|
||||
native_loader,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, ComputeMeter, Executor, InvokeContext, InvokeContextStackFrame, Logger,
|
||||
ProcessInstructionWithContext,
|
||||
log::*,
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
feature_set::{
|
||||
demote_program_write_locks, fix_write_privs, instructions_sysvar_enabled,
|
||||
neon_evm_compute_budget, remove_native_loader, requestable_heap_size,
|
||||
tx_wide_compute_cap, updated_verify_policy, FeatureSet,
|
||||
},
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
||||
message::Message,
|
||||
native_loader,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, ComputeMeter, Executor, InvokeContext, InvokeContextStackFrame,
|
||||
Logger, ProcessInstructionWithContext,
|
||||
},
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
system_program,
|
||||
sysvar::instructions,
|
||||
transaction::TransactionError,
|
||||
},
|
||||
std::{
|
||||
cell::{Ref, RefCell},
|
||||
collections::HashMap,
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
},
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
system_program,
|
||||
sysvar::instructions,
|
||||
transaction::TransactionError,
|
||||
};
|
||||
use std::{
|
||||
cell::{Ref, RefCell},
|
||||
collections::HashMap,
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub struct Executors {
|
||||
@@ -1341,13 +1343,15 @@ impl MessageProcessor {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
message::Message,
|
||||
native_loader::create_loadable_account_for_test,
|
||||
process_instruction::MockComputeMeter,
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::{
|
||||
account::Account,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
message::Message,
|
||||
native_loader::create_loadable_account_for_test,
|
||||
process_instruction::MockComputeMeter,
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@@ -3,26 +3,28 @@
|
||||
use libloading::os::unix::*;
|
||||
#[cfg(windows)]
|
||||
use libloading::os::windows::*;
|
||||
use log::*;
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use solana_sdk::{
|
||||
account::ReadableAccount,
|
||||
decode_error::DecodeError,
|
||||
entrypoint_native::ProgramEntrypoint,
|
||||
instruction::InstructionError,
|
||||
keyed_account::keyed_account_at_index,
|
||||
native_loader,
|
||||
process_instruction::{InvokeContext, LoaderEntrypoint},
|
||||
pubkey::Pubkey,
|
||||
use {
|
||||
log::*,
|
||||
num_derive::{FromPrimitive, ToPrimitive},
|
||||
solana_sdk::{
|
||||
account::ReadableAccount,
|
||||
decode_error::DecodeError,
|
||||
entrypoint_native::ProgramEntrypoint,
|
||||
instruction::InstructionError,
|
||||
keyed_account::keyed_account_at_index,
|
||||
native_loader,
|
||||
process_instruction::{InvokeContext, LoaderEntrypoint},
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
str,
|
||||
sync::RwLock,
|
||||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
str,
|
||||
sync::RwLock,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
pub enum NativeLoaderError {
|
||||
|
@@ -195,15 +195,16 @@ solana_sdk::pubkeys!(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
account::AccountSharedData,
|
||||
epoch_schedule::EpochSchedule,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
stake::state::{Authorized, Lockup, Meta},
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
epoch_schedule::EpochSchedule,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
stake::state::{Authorized, Lockup, Meta},
|
||||
},
|
||||
std::{collections::BTreeMap, sync::Arc},
|
||||
};
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
fn new_from_parent(parent: &Arc<Bank>) -> Bank {
|
||||
Bank::new_from_parent(parent, &Pubkey::default(), parent.slot() + 1)
|
||||
|
@@ -1,20 +1,21 @@
|
||||
//! ReadOnlyAccountsCache used to store accounts, such as executable accounts,
|
||||
//! which can be large, loaded many times, and rarely change.
|
||||
use dashmap::{mapref::entry::Entry, DashMap};
|
||||
//use mapref::entry::{Entry, OccupiedEntry, VacantEntry};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::Slot,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use std::thread::{sleep, Builder, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
|
||||
Arc, RwLock,
|
||||
use {
|
||||
dashmap::{mapref::entry::Entry, DashMap},
|
||||
std::{
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
|
||||
Arc, RwLock,
|
||||
},
|
||||
thread::{sleep, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
type ReadOnlyCacheKey = (Pubkey, Slot);
|
||||
@@ -240,8 +241,10 @@ impl ReadOnlyAccountsCache {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::account::{accounts_equal, Account, WritableAccount};
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::account::{accounts_equal, Account, WritableAccount},
|
||||
};
|
||||
#[test]
|
||||
fn test_accountsdb_sizeof() {
|
||||
// size_of(arc(x)) does not return the size of x
|
||||
|
@@ -126,8 +126,7 @@ impl RentCollector {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::account::Account;
|
||||
use {super::*, solana_sdk::account::Account};
|
||||
|
||||
#[test]
|
||||
fn test_collect_from_account_created_and_existing() {
|
||||
|
@@ -1,11 +1,13 @@
|
||||
use dashmap::{mapref::entry::Entry::Occupied, DashMap};
|
||||
use solana_sdk::{pubkey::Pubkey, timing::AtomicInterval};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fmt::Debug,
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
RwLock,
|
||||
use {
|
||||
dashmap::{mapref::entry::Entry::Occupied, DashMap},
|
||||
solana_sdk::{pubkey::Pubkey, timing::AtomicInterval},
|
||||
std::{
|
||||
collections::HashSet,
|
||||
fmt::Debug,
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
RwLock,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
use solana_frozen_abi::abi_example::IgnoreAsHelper;
|
||||
use {
|
||||
crate::{
|
||||
accounts::Accounts,
|
||||
@@ -17,8 +19,7 @@ use {
|
||||
serde_snapshot::future::SerializableStorage,
|
||||
stakes::Stakes,
|
||||
},
|
||||
bincode,
|
||||
bincode::{config::Options, Error},
|
||||
bincode::{self, config::Options, Error},
|
||||
log::*,
|
||||
rayon::prelude::*,
|
||||
serde::{de::DeserializeOwned, Deserialize, Serialize},
|
||||
@@ -27,8 +28,7 @@ use {
|
||||
clock::{Epoch, Slot, UnixTimestamp},
|
||||
epoch_schedule::EpochSchedule,
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
genesis_config::ClusterType,
|
||||
genesis_config::GenesisConfig,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
hard_forks::HardForks,
|
||||
hash::Hash,
|
||||
inflation::Inflation,
|
||||
@@ -43,23 +43,18 @@ use {
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
use solana_frozen_abi::abi_example::IgnoreAsHelper;
|
||||
|
||||
mod common;
|
||||
mod future;
|
||||
mod tests;
|
||||
mod utils;
|
||||
|
||||
use future::Context as TypeContextFuture;
|
||||
#[allow(unused_imports)]
|
||||
use utils::{serialize_iter_as_map, serialize_iter_as_seq, serialize_iter_as_tuple};
|
||||
|
||||
// a number of test cases in accounts_db use this
|
||||
#[cfg(test)]
|
||||
pub(crate) use self::tests::reconstruct_accounts_db_via_serialization;
|
||||
|
||||
pub(crate) use crate::accounts_db::{SnapshotStorage, SnapshotStorages};
|
||||
use future::Context as TypeContextFuture;
|
||||
#[allow(unused_imports)]
|
||||
use utils::{serialize_iter_as_map, serialize_iter_as_seq, serialize_iter_as_tuple};
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub(crate) enum SerdeStyle {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
use super::*;
|
||||
use std::collections::HashSet;
|
||||
use {super::*, std::collections::HashSet};
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
||||
pub(crate) struct UnusedAccounts {
|
||||
|
@@ -1,9 +1,11 @@
|
||||
use super::common::UnusedAccounts;
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
use solana_frozen_abi::abi_example::IgnoreAsHelper;
|
||||
use {super::*, solana_measure::measure::Measure, std::cell::RefCell};
|
||||
|
||||
use crate::ancestors::AncestorsForSerialization;
|
||||
use {
|
||||
super::{common::UnusedAccounts, *},
|
||||
crate::ancestors::AncestorsForSerialization,
|
||||
solana_measure::measure::Measure,
|
||||
std::cell::RefCell,
|
||||
};
|
||||
|
||||
type AccountsDbFields = super::AccountsDbFields<SerializableAccountStorageEntry>;
|
||||
|
||||
|
@@ -1,14 +1,15 @@
|
||||
use crate::bank_forks::ArchiveFormat;
|
||||
use crate::snapshot_utils::SnapshotVersion;
|
||||
use crate::{accounts_db::SnapshotStorages, bank::BankSlotDelta};
|
||||
use solana_sdk::clock::Slot;
|
||||
use solana_sdk::genesis_config::ClusterType;
|
||||
use solana_sdk::hash::Hash;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::mpsc::{Receiver, SendError, Sender},
|
||||
use {
|
||||
crate::{
|
||||
accounts_db::SnapshotStorages, bank::BankSlotDelta, bank_forks::ArchiveFormat,
|
||||
snapshot_utils::SnapshotVersion,
|
||||
},
|
||||
solana_sdk::{clock::Slot, genesis_config::ClusterType, hash::Hash},
|
||||
std::{
|
||||
path::PathBuf,
|
||||
sync::mpsc::{Receiver, SendError, Sender},
|
||||
},
|
||||
tempfile::TempDir,
|
||||
};
|
||||
use tempfile::TempDir;
|
||||
|
||||
pub type AccountsPackageSender = Sender<AccountsPackagePre>;
|
||||
pub type AccountsPackageReceiver = Receiver<AccountsPackagePre>;
|
||||
|
@@ -23,8 +23,7 @@ use {
|
||||
solana_measure::measure::Measure,
|
||||
solana_sdk::{clock::Slot, genesis_config::GenesisConfig, hash::Hash, pubkey::Pubkey},
|
||||
std::{
|
||||
cmp::max,
|
||||
cmp::Ordering,
|
||||
cmp::{max, Ordering},
|
||||
collections::HashSet,
|
||||
fmt,
|
||||
fs::{self, File},
|
||||
@@ -1113,10 +1112,12 @@ pub fn process_accounts_package_pre(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use bincode::{deserialize_from, serialize_into};
|
||||
use std::mem::size_of;
|
||||
use {
|
||||
super::*,
|
||||
assert_matches::assert_matches,
|
||||
bincode::{deserialize_from, serialize_into},
|
||||
std::mem::size_of,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_serialize_snapshot_data_file_under_limit() {
|
||||
|
@@ -1,8 +1,7 @@
|
||||
use crate::accounts_db::SnapshotStorage;
|
||||
use log::*;
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::ops::Range;
|
||||
use {
|
||||
crate::accounts_db::SnapshotStorage, log::*, solana_measure::measure::Measure,
|
||||
solana_sdk::clock::Slot, std::ops::Range,
|
||||
};
|
||||
|
||||
pub struct SortedStorages<'a> {
|
||||
range: Range<Slot>,
|
||||
|
@@ -100,8 +100,10 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{account::Account, native_token::sol_to_lamports};
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::{account::Account, native_token::sol_to_lamports},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_calculate_stake_weighted_timestamp_uses_median() {
|
||||
|
@@ -1,23 +1,25 @@
|
||||
//! Stakes serve as a cache of stake and vote accounts to derive
|
||||
//! node stakes
|
||||
use crate::vote_account::{ArcVoteAccount, VoteAccounts, VoteAccountsHashMap};
|
||||
use rayon::{
|
||||
iter::{IntoParallelRefIterator, ParallelIterator},
|
||||
ThreadPool,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::Epoch,
|
||||
pubkey::Pubkey,
|
||||
stake::{
|
||||
self,
|
||||
state::{Delegation, StakeActivationStatus, StakeState},
|
||||
use {
|
||||
crate::vote_account::{ArcVoteAccount, VoteAccounts, VoteAccountsHashMap},
|
||||
rayon::{
|
||||
iter::{IntoParallelRefIterator, ParallelIterator},
|
||||
ThreadPool,
|
||||
},
|
||||
stake_history::StakeHistory,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::Epoch,
|
||||
pubkey::Pubkey,
|
||||
stake::{
|
||||
self,
|
||||
state::{Delegation, StakeActivationStatus, StakeState},
|
||||
},
|
||||
stake_history::StakeHistory,
|
||||
},
|
||||
solana_stake_program::stake_state,
|
||||
solana_vote_program::vote_state::VoteState,
|
||||
std::collections::HashMap,
|
||||
};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state::VoteState;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
||||
pub struct Stakes {
|
||||
@@ -293,11 +295,13 @@ impl Stakes {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state::{self, VoteState, VoteStateVersions};
|
||||
use {
|
||||
super::*,
|
||||
rayon::ThreadPoolBuilder,
|
||||
solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent},
|
||||
solana_stake_program::stake_state,
|
||||
solana_vote_program::vote_state::{self, VoteState, VoteStateVersions},
|
||||
};
|
||||
|
||||
// set up some dummies for a staked node (( vote ) ( stake ))
|
||||
pub fn create_staked_node_accounts(
|
||||
|
@@ -1,15 +1,16 @@
|
||||
use crate::ancestors::Ancestors;
|
||||
|
||||
use log::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
use serde::Serialize;
|
||||
use solana_sdk::{
|
||||
clock::{Slot, MAX_RECENT_BLOCKHASHES},
|
||||
hash::Hash,
|
||||
};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
sync::{Arc, Mutex},
|
||||
use {
|
||||
crate::ancestors::Ancestors,
|
||||
log::*,
|
||||
rand::{thread_rng, Rng},
|
||||
serde::Serialize,
|
||||
solana_sdk::{
|
||||
clock::{Slot, MAX_RECENT_BLOCKHASHES},
|
||||
hash::Hash,
|
||||
},
|
||||
std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
sync::{Arc, Mutex},
|
||||
},
|
||||
};
|
||||
|
||||
pub const MAX_CACHE_ENTRIES: usize = MAX_RECENT_BLOCKHASHES;
|
||||
@@ -294,8 +295,10 @@ impl<T: Serialize + Clone> StatusCache<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{hash::hash, signature::Signature};
|
||||
use {
|
||||
super::*,
|
||||
solana_sdk::{hash::hash, signature::Signature},
|
||||
};
|
||||
|
||||
type BankStatusCache = StatusCache<()>;
|
||||
|
||||
|
@@ -1,20 +1,22 @@
|
||||
use log::*;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
feature_set, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
|
||||
nonce,
|
||||
nonce_keyed_account::NonceKeyedAccount,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH},
|
||||
system_program,
|
||||
sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent},
|
||||
use {
|
||||
log::*,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
feature_set, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
|
||||
nonce,
|
||||
nonce_keyed_account::NonceKeyedAccount,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH},
|
||||
system_program,
|
||||
sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent},
|
||||
},
|
||||
std::collections::HashSet,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
// represents an address that may or may not have been generated
|
||||
// from a seed
|
||||
@@ -459,27 +461,28 @@ pub fn get_system_account_kind(account: &AccountSharedData) -> Option<SystemAcco
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{bank::Bank, bank_client::BankClient};
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
client::SyncClient,
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::create_genesis_config,
|
||||
hash::{hash, Hash},
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
message::Message,
|
||||
nonce, nonce_account,
|
||||
process_instruction::MockInvokeContext,
|
||||
recent_blockhashes_account,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction, system_program, sysvar,
|
||||
sysvar::recent_blockhashes::IterItem,
|
||||
transaction::TransactionError,
|
||||
use {
|
||||
super::*,
|
||||
crate::{bank::Bank, bank_client::BankClient},
|
||||
bincode::serialize,
|
||||
solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
client::SyncClient,
|
||||
fee_calculator::FeeCalculator,
|
||||
genesis_config::create_genesis_config,
|
||||
hash::{hash, Hash},
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
message::Message,
|
||||
nonce, nonce_account,
|
||||
process_instruction::MockInvokeContext,
|
||||
recent_blockhashes_account,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction, system_program,
|
||||
sysvar::{self, recent_blockhashes::IterItem},
|
||||
transaction::TransactionError,
|
||||
},
|
||||
std::{cell::RefCell, sync::Arc},
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
|
||||
impl From<Pubkey> for Address {
|
||||
fn from(address: Pubkey) -> Self {
|
||||
|
@@ -1,7 +1,8 @@
|
||||
use crate::bank::Bank;
|
||||
use crate::hashed_transaction::HashedTransaction;
|
||||
use solana_sdk::transaction::{Result, Transaction};
|
||||
use std::borrow::Cow;
|
||||
use {
|
||||
crate::{bank::Bank, hashed_transaction::HashedTransaction},
|
||||
solana_sdk::transaction::{Result, Transaction},
|
||||
std::borrow::Cow,
|
||||
};
|
||||
|
||||
// Represents the results of trying to lock a set of accounts
|
||||
pub struct TransactionBatch<'a, 'b> {
|
||||
@@ -52,9 +53,11 @@ impl<'a, 'b> Drop for TransactionBatch<'a, 'b> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo};
|
||||
use solana_sdk::{signature::Keypair, system_transaction};
|
||||
use {
|
||||
super::*,
|
||||
crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
||||
solana_sdk::{signature::Keypair, system_transaction},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_transaction_batch() {
|
||||
|
@@ -1,15 +1,21 @@
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use solana_sdk::{
|
||||
account::Account, account::AccountSharedData, instruction::InstructionError, pubkey::Pubkey,
|
||||
};
|
||||
use solana_vote_program::vote_state::VoteState;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
iter::FromIterator,
|
||||
ops::Deref,
|
||||
sync::{Arc, Once, RwLock, RwLockReadGuard},
|
||||
use {
|
||||
serde::{
|
||||
de::{Deserialize, Deserializer},
|
||||
ser::{Serialize, Serializer},
|
||||
},
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
instruction::InstructionError,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
solana_vote_program::vote_state::VoteState,
|
||||
std::{
|
||||
cmp::Ordering,
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
iter::FromIterator,
|
||||
ops::Deref,
|
||||
sync::{Arc, Once, RwLock, RwLockReadGuard},
|
||||
},
|
||||
};
|
||||
|
||||
// The value here does not matter. It will be overwritten
|
||||
@@ -315,12 +321,14 @@ impl<'de> Deserialize<'de> for VoteAccounts {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bincode::Options;
|
||||
use rand::Rng;
|
||||
use solana_sdk::{pubkey::Pubkey, sysvar::clock::Clock};
|
||||
use solana_vote_program::vote_state::{VoteInit, VoteStateVersions};
|
||||
use std::iter::repeat_with;
|
||||
use {
|
||||
super::*,
|
||||
bincode::Options,
|
||||
rand::Rng,
|
||||
solana_sdk::{pubkey::Pubkey, sysvar::clock::Clock},
|
||||
solana_vote_program::vote_state::{VoteInit, VoteStateVersions},
|
||||
std::iter::repeat_with,
|
||||
};
|
||||
|
||||
fn new_rand_vote_account<R: Rng>(
|
||||
rng: &mut R,
|
||||
|
@@ -1,6 +1,8 @@
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use solana_sdk::{hash::Hash, pubkey::Pubkey};
|
||||
use solana_vote_program::vote_state::Vote;
|
||||
use {
|
||||
crossbeam_channel::{Receiver, Sender},
|
||||
solana_sdk::{hash::Hash, pubkey::Pubkey},
|
||||
solana_vote_program::vote_state::Vote,
|
||||
};
|
||||
|
||||
pub type ReplayedVote = (Pubkey, Vote, Option<Hash>);
|
||||
pub type ReplayVoteSender = Sender<ReplayedVote>;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
use clap::{crate_description, crate_name, value_t_or_exit, App, Arg};
|
||||
use log::*;
|
||||
use solana_runtime::append_vec::AppendVec;
|
||||
use {
|
||||
clap::{crate_description, crate_name, value_t_or_exit, App, Arg},
|
||||
log::*,
|
||||
solana_runtime::append_vec::AppendVec,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
solana_logger::setup_with_default("solana=info");
|
||||
|
@@ -1,20 +1,26 @@
|
||||
use log::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
use rayon::prelude::*;
|
||||
use solana_runtime::{
|
||||
accounts_db::{AccountsDb, LoadHint},
|
||||
ancestors::Ancestors,
|
||||
use {
|
||||
log::*,
|
||||
rand::{thread_rng, Rng},
|
||||
rayon::prelude::*,
|
||||
solana_runtime::{
|
||||
accounts_db::{AccountsDb, LoadHint},
|
||||
ancestors::Ancestors,
|
||||
},
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
clock::Slot,
|
||||
genesis_config::ClusterType,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
collections::HashSet,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
time::Instant,
|
||||
},
|
||||
};
|
||||
use solana_sdk::genesis_config::ClusterType;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
clock::Slot,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
#[test]
|
||||
fn test_shrink_and_clean() {
|
||||
|
@@ -1,6 +1,8 @@
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::{genesis_config::create_genesis_config, hash::hash};
|
||||
use std::{sync::Arc, thread::Builder};
|
||||
use {
|
||||
solana_runtime::bank::Bank,
|
||||
solana_sdk::{genesis_config::create_genesis_config, hash::hash},
|
||||
std::{sync::Arc, thread::Builder},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_race_register_tick_freeze() {
|
||||
|
@@ -1,28 +1,30 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use solana_runtime::{
|
||||
bank::Bank,
|
||||
bank_client::BankClient,
|
||||
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::from_account,
|
||||
account_utils::StateMut,
|
||||
client::SyncClient,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
stake::{
|
||||
self, instruction as stake_instruction,
|
||||
state::{Authorized, Lockup, StakeState},
|
||||
use {
|
||||
solana_runtime::{
|
||||
bank::Bank,
|
||||
bank_client::BankClient,
|
||||
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
||||
},
|
||||
sysvar::{self, stake_history::StakeHistory},
|
||||
solana_sdk::{
|
||||
account::from_account,
|
||||
account_utils::StateMut,
|
||||
client::SyncClient,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
stake::{
|
||||
self, instruction as stake_instruction,
|
||||
state::{Authorized, Lockup, StakeState},
|
||||
},
|
||||
sysvar::{self, stake_history::StakeHistory},
|
||||
},
|
||||
solana_stake_program::stake_state,
|
||||
solana_vote_program::{
|
||||
vote_instruction,
|
||||
vote_state::{Vote, VoteInit, VoteState, VoteStateVersions},
|
||||
},
|
||||
std::sync::Arc,
|
||||
};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::{
|
||||
vote_instruction,
|
||||
vote_state::{Vote, VoteInit, VoteState, VoteStateVersions},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
fn next_epoch(bank: &Arc<Bank>) -> Arc<Bank> {
|
||||
bank.squash();
|
||||
|
Reference in New Issue
Block a user