Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just define BnakSlotDelta type alias (bp #8186) #8320

Merged
merged 2 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/src/snapshot_packager_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ mod tests {
snapshot_utils::{self, SNAPSHOT_STATUS_CACHE_FILE_NAME},
};
use solana_runtime::{
accounts_db::AccountStorageEntry, bank::MAX_SNAPSHOT_DATA_FILE_SIZE,
status_cache::SlotDelta,
accounts_db::AccountStorageEntry, bank::BankSlotDelta, bank::MAX_SNAPSHOT_DATA_FILE_SIZE,
};
use solana_sdk::transaction;
use std::{
fs::{self, remove_dir_all, OpenOptions},
io::Write,
Expand Down Expand Up @@ -149,7 +147,7 @@ mod tests {
// before we compare, stick an empty status_cache in this dir so that the package comparision works
// This is needed since the status_cache is added by the packager and is not collected from
// the source dir for snapshots
let dummy_slot_deltas: Vec<SlotDelta<transaction::Result<()>>> = vec![];
let dummy_slot_deltas: Vec<BankSlotDelta> = vec![];
snapshot_utils::serialize_snapshot_data_file(
&snapshots_dir.join(SNAPSHOT_STATUS_CACHE_FILE_NAME),
MAX_SNAPSHOT_DATA_FILE_SIZE,
Expand Down
8 changes: 4 additions & 4 deletions core/tests/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ mod tests {
snapshot_utils,
};
use solana_runtime::{
bank::Bank,
status_cache::{SlotDelta, MAX_CACHE_ENTRIES},
bank::{Bank, BankSlotDelta},
status_cache::MAX_CACHE_ENTRIES,
};
use solana_sdk::{
clock::Slot,
hash::hashv,
pubkey::Pubkey,
signature::{Keypair, KeypairUtil},
system_transaction, transaction,
system_transaction,
};
use std::{fs, path::PathBuf, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc};
use tempfile::TempDir;
Expand Down Expand Up @@ -312,7 +312,7 @@ mod tests {
// before we compare, stick an empty status_cache in this dir so that the package comparision works
// This is needed since the status_cache is added by the packager and is not collected from
// the source dir for snapshots
let dummy_slot_deltas: Vec<SlotDelta<transaction::Result<()>>> = vec![];
let dummy_slot_deltas: Vec<BankSlotDelta> = vec![];
snapshot_utils::serialize_snapshot_data_file(
&saved_snapshots_dir
.path()
Expand Down
8 changes: 4 additions & 4 deletions ledger/src/snapshot_package.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use solana_runtime::accounts_db::AccountStorageEntry;
use solana_runtime::status_cache::SlotDelta;
use solana_sdk::{clock::Slot, transaction};
use solana_runtime::bank::BankSlotDelta;
use solana_sdk::clock::Slot;
use std::path::PathBuf;
use std::sync::mpsc::{Receiver, SendError, Sender};
use std::sync::Arc;
Expand All @@ -13,7 +13,7 @@ pub type SnapshotPackageSendError = SendError<SnapshotPackage>;
#[derive(Debug)]
pub struct SnapshotPackage {
pub root: Slot,
pub slot_deltas: Vec<SlotDelta<transaction::Result<()>>>,
pub slot_deltas: Vec<BankSlotDelta>,
pub snapshot_links: TempDir,
pub storage_entries: Vec<Arc<AccountStorageEntry>>,
pub tar_output_file: PathBuf,
Expand All @@ -22,7 +22,7 @@ pub struct SnapshotPackage {
impl SnapshotPackage {
pub fn new(
root: Slot,
slot_deltas: Vec<SlotDelta<transaction::Result<()>>>,
slot_deltas: Vec<BankSlotDelta>,
snapshot_links: TempDir,
storage_entries: Vec<Arc<AccountStorageEntry>>,
tar_output_file: PathBuf,
Expand Down
13 changes: 5 additions & 8 deletions ledger/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use bzip2::bufread::BzDecoder;
use fs_extra::dir::CopyOptions;
use log::*;
use solana_measure::measure::Measure;
use solana_runtime::{
bank::{self, deserialize_from_snapshot, Bank, MAX_SNAPSHOT_DATA_FILE_SIZE},
status_cache::SlotDelta,
use solana_runtime::bank::{
self, deserialize_from_snapshot, Bank, BankSlotDelta, MAX_SNAPSHOT_DATA_FILE_SIZE,
};
use solana_sdk::transaction::Result as TransactionResult;
use solana_sdk::{clock::Slot, transaction};
use solana_sdk::clock::Slot;
use std::{
cmp::Ordering,
fs::{self, File},
Expand Down Expand Up @@ -362,7 +360,7 @@ pub fn add_snapshot<P: AsRef<Path>>(snapshot_path: P, bank: &Bank) -> Result<Slo

pub fn serialize_status_cache(
slot: Slot,
slot_deltas: &[SlotDelta<TransactionResult<()>>],
slot_deltas: &[BankSlotDelta],
snapshot_links: &TempDir,
) -> Result<()> {
// the status cache is stored as snapshot_path/status_cache
Expand Down Expand Up @@ -549,8 +547,7 @@ where
MAX_SNAPSHOT_DATA_FILE_SIZE,
|stream| {
info!("Rebuilding status cache...");
let slot_deltas: Vec<SlotDelta<transaction::Result<()>>> =
deserialize_from_snapshot(stream)?;
let slot_deltas: Vec<BankSlotDelta> = deserialize_from_snapshot(stream)?;
Ok(slot_deltas)
},
)?;
Expand Down
5 changes: 3 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub const MAX_SNAPSHOT_DATA_FILE_SIZE: u64 = 32 * 1024 * 1024 * 1024; // 32 GiB
pub const MAX_LEADER_SCHEDULE_STAKES: Epoch = 5;

type BankStatusCache = StatusCache<Result<()>>;
pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>;
type TransactionLoaderRefCells = Vec<Vec<(Pubkey, RefCell<Account>)>>;

Expand Down Expand Up @@ -143,7 +144,7 @@ pub struct StatusCacheRc {
}

impl StatusCacheRc {
pub fn slot_deltas(&self, slots: &[Slot]) -> Vec<SlotDelta<Result<()>>> {
pub fn slot_deltas(&self, slots: &[Slot]) -> Vec<BankSlotDelta> {
let sc = self.status_cache.read().unwrap();
sc.slot_deltas(slots)
}
Expand All @@ -159,7 +160,7 @@ impl StatusCacheRc {
.collect()
}

pub fn append(&self, slot_deltas: &[SlotDelta<Result<()>>]) {
pub fn append(&self, slot_deltas: &[BankSlotDelta]) {
let mut sc = self.status_cache.write().unwrap();
sc.append(slot_deltas);
}
Expand Down