Remove last_entry_id/next_blob_index from TvuRotationInfo

This commit is contained in:
Michael Vines
2019-02-28 12:59:26 -08:00
parent 6cf6a1ccc3
commit 6b228df3df
5 changed files with 15 additions and 55 deletions

View File

@ -6,7 +6,6 @@ use rayon::prelude::*;
use solana_metrics::counter::Counter; use solana_metrics::counter::Counter;
use solana_runtime::bank::{Bank, BankError, Result}; use solana_runtime::bank::{Bank, BankError, Result};
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::Hash;
use solana_sdk::timing::duration_as_ms; use solana_sdk::timing::duration_as_ms;
use solana_sdk::timing::MAX_ENTRY_IDS; use solana_sdk::timing::MAX_ENTRY_IDS;
use std::sync::Arc; use std::sync::Arc;
@ -101,8 +100,6 @@ fn process_block(bank: &Bank, entries: &[Entry]) -> Result<()> {
pub struct BankForksInfo { pub struct BankForksInfo {
pub bank_id: u64, pub bank_id: u64,
pub entry_height: u64, pub entry_height: u64,
pub last_entry_id: Hash,
pub next_blob_index: u64,
} }
pub fn process_blocktree( pub fn process_blocktree(
@ -195,8 +192,6 @@ pub fn process_blocktree(
let bfi = BankForksInfo { let bfi = BankForksInfo {
bank_id: slot, bank_id: slot,
entry_height: starting_entry_height, entry_height: starting_entry_height,
last_entry_id: starting_bank.last_id(),
next_blob_index: 0,
}; };
fork_info.push((starting_bank, bfi)); fork_info.push((starting_bank, bfi));
continue; continue;
@ -211,8 +206,6 @@ pub fn process_blocktree(
let bfi = BankForksInfo { let bfi = BankForksInfo {
bank_id: slot, bank_id: slot,
entry_height, entry_height,
last_entry_id: bank.last_id(),
next_blob_index: meta.consumed,
}; };
fork_info.push((bank, bfi)); fork_info.push((bank, bfi));
continue; continue;
@ -253,6 +246,7 @@ mod tests {
use crate::blocktree::tests::entries_to_blobs; use crate::blocktree::tests::entries_to_blobs;
use crate::entry::{create_ticks, next_entry, Entry}; use crate::entry::{create_ticks, next_entry, Entry};
use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction; use solana_sdk::system_transaction::SystemTransaction;
@ -298,8 +292,6 @@ mod tests {
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot) let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot)
.expect("Expected to successfully open database ledger"); .expect("Expected to successfully open database ledger");
let expected_last_entry_id = last_id;
// Write slot 1 // Write slot 1
// slot 1, points at slot 0. Missing one tick // slot 1, points at slot 0. Missing one tick
{ {
@ -326,8 +318,6 @@ mod tests {
BankForksInfo { BankForksInfo {
bank_id: 1, // never finished first slot bank_id: 1, // never finished first slot
entry_height: ticks_per_slot, entry_height: ticks_per_slot,
last_entry_id: expected_last_entry_id,
next_blob_index: 0,
} }
); );
} }
@ -385,8 +375,6 @@ mod tests {
BankForksInfo { BankForksInfo {
bank_id: 3, // Fork 1's head is slot 3 bank_id: 3, // Fork 1's head is slot 3
entry_height: ticks_per_slot * 4, entry_height: ticks_per_slot * 4,
last_entry_id: last_fork1_entry_id,
next_blob_index: ticks_per_slot, // this fork is done, but we need to look for children in replay
} }
); );
assert_eq!( assert_eq!(
@ -394,8 +382,6 @@ mod tests {
BankForksInfo { BankForksInfo {
bank_id: 4, // Fork 2's head is slot 4 bank_id: 4, // Fork 2's head is slot 4
entry_height: ticks_per_slot * 3, entry_height: ticks_per_slot * 3,
last_entry_id: last_fork2_entry_id,
next_blob_index: ticks_per_slot, // this fork is done, but we need to look for children in replay
} }
); );
@ -499,8 +485,6 @@ mod tests {
BankForksInfo { BankForksInfo {
bank_id: 1, bank_id: 1,
entry_height, entry_height,
last_entry_id: entries.last().unwrap().id,
next_blob_index: entries.len() as u64,
} }
); );

View File

@ -131,14 +131,10 @@ impl Fullnode {
let bank_info = &bank_forks_info[0]; let bank_info = &bank_forks_info[0];
let bank = bank_forks[bank_info.bank_id].clone(); let bank = bank_forks[bank_info.bank_id].clone();
info!( info!("starting PoH... {} {}", bank.tick_height(), bank.last_id(),);
"starting PoH... {} {}",
bank.tick_height(),
bank_info.last_entry_id
);
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new( let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(
bank.tick_height(), bank.tick_height(),
bank_info.last_entry_id, bank.last_id(),
))); )));
let poh_service = PohService::new(poh_recorder.clone(), &config.tick_config, exit.clone()); let poh_service = PohService::new(poh_recorder.clone(), &config.tick_config, exit.clone());
@ -270,11 +266,10 @@ impl Fullnode {
fn rotate(&mut self, rotation_info: TvuRotationInfo) -> FullnodeReturnType { fn rotate(&mut self, rotation_info: TvuRotationInfo) -> FullnodeReturnType {
trace!( trace!(
"{:?}: rotate for slot={} to leader={:?} using last_entry_id={:?}", "{:?}: rotate for slot={} to leader={:?}",
self.id, self.id,
rotation_info.slot, rotation_info.slot,
rotation_info.leader_id, rotation_info.leader_id,
rotation_info.last_entry_id,
); );
let was_leader = leader_schedule_utils::slot_leader(&rotation_info.bank) == self.id; let was_leader = leader_schedule_utils::slot_leader(&rotation_info.bank) == self.id;
@ -351,7 +346,7 @@ impl Fullnode {
//instead of here //instead of here
self.poh_recorder.lock().unwrap().reset( self.poh_recorder.lock().unwrap().reset(
rotation_info.bank.tick_height(), rotation_info.bank.tick_height(),
rotation_info.last_entry_id, rotation_info.bank.last_id(),
); );
let slot = rotation_info.slot; let slot = rotation_info.slot;
let transition = self.rotate(rotation_info); let transition = self.rotate(rotation_info);

View File

@ -185,20 +185,11 @@ impl ReplayStage {
let subscriptions_ = subscriptions.clone(); let subscriptions_ = subscriptions.clone();
// Gather up all the metadata about the current state of the ledger // Gather up all the metadata about the current state of the ledger
let (mut bank, tick_height, mut last_entry_id, mut current_blob_index) = { let mut bank = bank_forks.read().unwrap()[bank_forks_info[0].bank_id].clone();
let bank = bank_forks.read().unwrap()[bank_forks_info[0].bank_id].clone();
let tick_height = bank.tick_height();
(
bank,
tick_height,
bank_forks_info[0].last_entry_id,
bank_forks_info[0].next_blob_index,
)
};
assert_eq!(bank.last_id(), last_entry_id); // TODO: remove last_entry_id, this assert proves it's unnecessary
// Update Tpu and other fullnode components with the current bank // Update Tpu and other fullnode components with the current bank
let (mut current_slot, mut current_leader_id, mut max_tick_height_for_slot) = { let (mut current_slot, mut current_leader_id, mut max_tick_height_for_slot) = {
let tick_height = bank.tick_height();
let slot = (tick_height + 1) / bank.ticks_per_slot(); let slot = (tick_height + 1) / bank.ticks_per_slot();
let first_tick_in_slot = slot * bank.ticks_per_slot(); let first_tick_in_slot = slot * bank.ticks_per_slot();
@ -208,13 +199,9 @@ impl ReplayStage {
let old_bank = bank.clone(); let old_bank = bank.clone();
// If the next slot is going to be a new slot and we're the leader for that slot, // If the next slot is going to be a new slot and we're the leader for that slot,
// make a new working bank, set it as the working bank. // make a new working bank, set it as the working bank.
if tick_height + 1 == first_tick_in_slot { if tick_height + 1 == first_tick_in_slot && leader_id == my_id {
if leader_id == my_id {
bank = Self::create_and_set_working_bank(slot, &bank_forks, &old_bank); bank = Self::create_and_set_working_bank(slot, &bank_forks, &old_bank);
} }
current_blob_index = 0;
}
assert_eq!(current_blob_index, 0); // TODO: remove next_blob_index, this assert proves it's unnecessary
// Send a rotation notification back to Fullnode to initialize the TPU to the right // Send a rotation notification back to Fullnode to initialize the TPU to the right
// state. After this point, the bank.tick_height() is live, which it means it can // state. After this point, the bank.tick_height() is live, which it means it can
@ -222,7 +209,6 @@ impl ReplayStage {
to_leader_sender to_leader_sender
.send(TvuRotationInfo { .send(TvuRotationInfo {
bank: bank.clone(), bank: bank.clone(),
last_entry_id,
slot, slot,
leader_id, leader_id,
}) })
@ -233,6 +219,8 @@ impl ReplayStage {
(Some(slot), leader_id, max_tick_height_for_slot) (Some(slot), leader_id, max_tick_height_for_slot)
}; };
let mut last_entry_id = bank.last_id();
let mut current_blob_index = 0;
// Start the replay stage loop // Start the replay stage loop
let bank_forks = bank_forks.clone(); let bank_forks = bank_forks.clone();
@ -388,7 +376,6 @@ impl ReplayStage {
to_leader_sender to_leader_sender
.send(TvuRotationInfo { .send(TvuRotationInfo {
bank: bank.clone(), bank: bank.clone(),
last_entry_id,
slot: next_slot, slot: next_slot,
leader_id, leader_id,
}) })
@ -508,7 +495,7 @@ mod test {
let (bank_forks, bank_forks_info, blocktree, l_receiver) = let (bank_forks, bank_forks_info, blocktree, l_receiver) =
new_banks_from_blocktree(&my_ledger_path, None); new_banks_from_blocktree(&my_ledger_path, None);
let bank = bank_forks.working_bank(); let bank = bank_forks.working_bank();
let last_entry_id = bank_forks_info[0].last_entry_id; let last_entry_id = bank.last_id();
let blocktree = Arc::new(blocktree); let blocktree = Arc::new(blocktree);
let (replay_stage, _slot_full_receiver, ledger_writer_recv) = ReplayStage::new( let (replay_stage, _slot_full_receiver, ledger_writer_recv) = ReplayStage::new(

View File

@ -24,7 +24,6 @@ use crate::rpc_subscriptions::RpcSubscriptions;
use crate::service::Service; use crate::service::Service;
use crate::storage_stage::{StorageStage, StorageState}; use crate::storage_stage::{StorageStage, StorageState};
use solana_runtime::bank::Bank; use solana_runtime::bank::Bank;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use std::net::UdpSocket; use std::net::UdpSocket;
@ -35,7 +34,6 @@ use std::thread;
pub struct TvuRotationInfo { pub struct TvuRotationInfo {
pub bank: Arc<Bank>, // Bank to use pub bank: Arc<Bank>, // Bank to use
pub last_entry_id: Hash, // last_entry_id of that bank
pub slot: u64, // slot height to initiate a rotation pub slot: u64, // slot height to initiate a rotation
pub leader_id: Pubkey, // leader upon rotation pub leader_id: Pubkey, // leader upon rotation
} }
@ -218,8 +216,6 @@ pub mod tests {
let bank_forks_info = vec![BankForksInfo { let bank_forks_info = vec![BankForksInfo {
bank_id: 0, bank_id: 0,
entry_height: 0, entry_height: 0,
last_entry_id: bank_forks.working_bank().last_id(),
next_blob_index: 0,
}]; }];
//start cluster_info1 //start cluster_info1

View File

@ -91,8 +91,6 @@ fn test_replay() {
let bank_forks_info = vec![BankForksInfo { let bank_forks_info = vec![BankForksInfo {
bank_id: 0, bank_id: 0,
entry_height: 0, entry_height: 0,
last_entry_id: cur_hash,
next_blob_index: 0,
}]; }];
let bank = bank_forks.working_bank(); let bank = bank_forks.working_bank();