Only allow votes when root distance gets too high (#19917)
This commit is contained in:
@ -984,6 +984,8 @@ pub struct Bank {
|
||||
pub drop_callback: RwLock<OptionalDropCallback>,
|
||||
|
||||
pub freeze_started: AtomicBool,
|
||||
|
||||
vote_only_bank: bool,
|
||||
}
|
||||
|
||||
impl Default for BlockhashQueue {
|
||||
@ -1109,6 +1111,7 @@ impl Bank {
|
||||
feature_set: Arc::<FeatureSet>::default(),
|
||||
drop_callback: RwLock::<OptionalDropCallback>::default(),
|
||||
freeze_started: AtomicBool::default(),
|
||||
vote_only_bank: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1219,7 +1222,22 @@ impl Bank {
|
||||
|
||||
/// Create a new bank that points to an immutable checkpoint of another bank.
|
||||
pub fn new_from_parent(parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot) -> Self {
|
||||
Self::_new_from_parent(parent, collector_id, slot, &mut null_tracer())
|
||||
Self::_new_from_parent(parent, collector_id, slot, &mut null_tracer(), false)
|
||||
}
|
||||
|
||||
pub fn new_from_parent_with_vote_only(
|
||||
parent: &Arc<Bank>,
|
||||
collector_id: &Pubkey,
|
||||
slot: Slot,
|
||||
vote_only_bank: bool,
|
||||
) -> Self {
|
||||
Self::_new_from_parent(
|
||||
parent,
|
||||
collector_id,
|
||||
slot,
|
||||
&mut null_tracer(),
|
||||
vote_only_bank,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_from_parent_with_tracer(
|
||||
@ -1228,7 +1246,13 @@ impl Bank {
|
||||
slot: Slot,
|
||||
reward_calc_tracer: impl FnMut(&RewardCalculationEvent),
|
||||
) -> Self {
|
||||
Self::_new_from_parent(parent, collector_id, slot, &mut Some(reward_calc_tracer))
|
||||
Self::_new_from_parent(
|
||||
parent,
|
||||
collector_id,
|
||||
slot,
|
||||
&mut Some(reward_calc_tracer),
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
fn _new_from_parent(
|
||||
@ -1236,6 +1260,7 @@ impl Bank {
|
||||
collector_id: &Pubkey,
|
||||
slot: Slot,
|
||||
reward_calc_tracer: &mut Option<impl FnMut(&RewardCalculationEvent)>,
|
||||
vote_only_bank: bool,
|
||||
) -> Self {
|
||||
parent.freeze();
|
||||
assert_ne!(slot, parent.slot());
|
||||
@ -1284,6 +1309,7 @@ impl Bank {
|
||||
fee_calculator: fee_rate_governor.create_fee_calculator(),
|
||||
fee_rate_governor,
|
||||
capitalization: AtomicU64::new(parent.capitalization()),
|
||||
vote_only_bank,
|
||||
inflation: parent.inflation.clone(),
|
||||
transaction_count: AtomicU64::new(parent.transaction_count()),
|
||||
transaction_error_count: AtomicU64::new(0),
|
||||
@ -1374,6 +1400,10 @@ impl Bank {
|
||||
*self.drop_callback.write().unwrap() = OptionalDropCallback(callback);
|
||||
}
|
||||
|
||||
pub fn vote_only_bank(&self) -> bool {
|
||||
self.vote_only_bank
|
||||
}
|
||||
|
||||
/// Like `new_from_parent` but additionally:
|
||||
/// * Doesn't assume that the parent is anywhere near `slot`, parent could be millions of slots
|
||||
/// in the past
|
||||
@ -1469,6 +1499,7 @@ impl Bank {
|
||||
feature_set: new(),
|
||||
drop_callback: RwLock::new(OptionalDropCallback(None)),
|
||||
freeze_started: AtomicBool::new(fields.hash != Hash::default()),
|
||||
vote_only_bank: false,
|
||||
};
|
||||
bank.finish_init(
|
||||
genesis_config,
|
||||
@ -5698,7 +5729,7 @@ pub fn goto_end_of_slot(bank: &mut Bank) {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_simple_vote_transaction(transaction: &SanitizedTransaction) -> bool {
|
||||
pub fn is_simple_vote_transaction(transaction: &SanitizedTransaction) -> bool {
|
||||
if transaction.message().instructions().len() == 1 {
|
||||
let (program_pubkey, instruction) = transaction
|
||||
.message()
|
||||
|
Reference in New Issue
Block a user