use the right id for delegate id
This commit is contained in:
parent
054ae3a3e3
commit
e45f7afd85
|
@ -58,21 +58,21 @@ impl EpochStakes {
|
||||||
let stakes = accounts.iter().map(|(k, v)| (*k, v.lamports)).collect();
|
let stakes = accounts.iter().map(|(k, v)| (*k, v.lamports)).collect();
|
||||||
Self::new(slot, stakes, &accounts[0].0)
|
Self::new(slot, stakes, &accounts[0].0)
|
||||||
}
|
}
|
||||||
pub fn new_from_bank(bank: &Bank) -> Self {
|
pub fn new_from_bank(bank: &Bank, my_id: &Pubkey) -> Self {
|
||||||
let bank_epoch = bank.get_epoch_and_slot_index(bank.slot()).0;
|
let bank_epoch = bank.get_epoch_and_slot_index(bank.slot()).0;
|
||||||
let stakes = staking_utils::vote_account_balances_at_epoch(bank, bank_epoch)
|
let stakes = staking_utils::vote_account_balances_at_epoch(bank, bank_epoch)
|
||||||
.expect("voting require a bank with stakes");
|
.expect("voting require a bank with stakes");
|
||||||
Self::new(bank_epoch, stakes, &bank.collector_id())
|
Self::new(bank_epoch, stakes, my_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Locktower {
|
impl Locktower {
|
||||||
pub fn new_from_forks(bank_forks: &BankForks) -> Self {
|
pub fn new_from_forks(bank_forks: &BankForks, my_id: &Pubkey) -> Self {
|
||||||
let mut frozen_banks: Vec<_> = bank_forks.frozen_banks().values().cloned().collect();
|
let mut frozen_banks: Vec<_> = bank_forks.frozen_banks().values().cloned().collect();
|
||||||
frozen_banks.sort_by_key(|b| (b.parents().len(), b.slot()));
|
frozen_banks.sort_by_key(|b| (b.parents().len(), b.slot()));
|
||||||
let epoch_stakes = {
|
let epoch_stakes = {
|
||||||
if let Some(bank) = frozen_banks.last() {
|
if let Some(bank) = frozen_banks.last() {
|
||||||
EpochStakes::new_from_bank(bank)
|
EpochStakes::new_from_bank(bank, my_id)
|
||||||
} else {
|
} else {
|
||||||
return Self::default();
|
return Self::default();
|
||||||
}
|
}
|
||||||
|
@ -90,18 +90,6 @@ impl Locktower {
|
||||||
Self::initialize_lockouts_from_bank(&bank, locktower.epoch_stakes.slot);
|
Self::initialize_lockouts_from_bank(&bank, locktower.epoch_stakes.slot);
|
||||||
locktower
|
locktower
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_bank(bank: &Bank) -> Self {
|
|
||||||
let current_epoch = bank.get_epoch_and_slot_index(bank.slot()).0;
|
|
||||||
let lockouts = Self::initialize_lockouts_from_bank(&bank, current_epoch);
|
|
||||||
let epoch_stakes = EpochStakes::new_from_bank(bank);
|
|
||||||
Self {
|
|
||||||
epoch_stakes,
|
|
||||||
threshold_depth: VOTE_THRESHOLD_DEPTH,
|
|
||||||
threshold_size: VOTE_THRESHOLD_SIZE,
|
|
||||||
lockouts,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn new(epoch_stakes: EpochStakes, threshold_depth: usize, threshold_size: f64) -> Self {
|
pub fn new(epoch_stakes: EpochStakes, threshold_depth: usize, threshold_size: f64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
epoch_stakes,
|
epoch_stakes,
|
||||||
|
@ -127,9 +115,16 @@ impl Locktower {
|
||||||
}
|
}
|
||||||
let mut vote_state: VoteState = VoteState::deserialize(&account.data)
|
let mut vote_state: VoteState = VoteState::deserialize(&account.data)
|
||||||
.expect("bank should always have valid VoteState data");
|
.expect("bank should always have valid VoteState data");
|
||||||
|
|
||||||
if key == self.epoch_stakes.delegate_id
|
if key == self.epoch_stakes.delegate_id
|
||||||
|| vote_state.delegate_id == self.epoch_stakes.delegate_id
|
|| vote_state.delegate_id == self.epoch_stakes.delegate_id
|
||||||
{
|
{
|
||||||
|
debug!("vote state {:?}", vote_state);
|
||||||
|
debug!(
|
||||||
|
"observed slot {}",
|
||||||
|
vote_state.nth_recent_vote(0).map(|v| v.slot).unwrap_or(0) as i64
|
||||||
|
);
|
||||||
|
debug!("observed root {}", vote_state.root_slot.unwrap_or(0) as i64);
|
||||||
solana_metrics::submit(
|
solana_metrics::submit(
|
||||||
influxdb::Point::new("counter-locktower-observed")
|
influxdb::Point::new("counter-locktower-observed")
|
||||||
.add_field(
|
.add_field(
|
||||||
|
@ -204,7 +199,7 @@ impl Locktower {
|
||||||
bank.slot(),
|
bank.slot(),
|
||||||
self.epoch_stakes.slot
|
self.epoch_stakes.slot
|
||||||
);
|
);
|
||||||
self.epoch_stakes = EpochStakes::new_from_bank(bank);
|
self.epoch_stakes = EpochStakes::new_from_bank(bank, &self.epoch_stakes.delegate_id);
|
||||||
solana_metrics::submit(
|
solana_metrics::submit(
|
||||||
influxdb::Point::new("counter-locktower-epoch")
|
influxdb::Point::new("counter-locktower-epoch")
|
||||||
.add_field(
|
.add_field(
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl ReplayStage {
|
||||||
let my_id = *my_id;
|
let my_id = *my_id;
|
||||||
let vote_account = *vote_account;
|
let vote_account = *vote_account;
|
||||||
let mut ticks_per_slot = 0;
|
let mut ticks_per_slot = 0;
|
||||||
let mut locktower = Locktower::new_from_forks(&bank_forks.read().unwrap());
|
let mut locktower = Locktower::new_from_forks(&bank_forks.read().unwrap(), &my_id);
|
||||||
|
|
||||||
// Start the replay stage loop
|
// Start the replay stage loop
|
||||||
let t_replay = Builder::new()
|
let t_replay = Builder::new()
|
||||||
|
|
Loading…
Reference in New Issue