refactor: highest_cluster_confirmed_root -> highest_super_majority_root (#31619)
This commit is contained in:
parent
531c5ebe97
commit
3e8f5bad81
|
@ -251,7 +251,7 @@ impl Banks for BanksServer {
|
|||
optimistically_confirmed_bank.get_signature_status_slot(&signature);
|
||||
|
||||
let confirmations = if r_block_commitment_cache.root() >= slot
|
||||
&& r_block_commitment_cache.highest_confirmed_root() >= slot
|
||||
&& r_block_commitment_cache.highest_super_majority_root() >= slot
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
|
|
@ -185,7 +185,7 @@ fn test_account_subscription() {
|
|||
slot: 2,
|
||||
root: 1,
|
||||
highest_confirmed_slot: 1,
|
||||
highest_confirmed_root: 1,
|
||||
highest_super_majority_root: 1,
|
||||
};
|
||||
subscriptions.notify_subscribers(commitment_slots);
|
||||
|
||||
|
@ -390,7 +390,7 @@ fn test_program_subscription() {
|
|||
slot: 2,
|
||||
root: 1,
|
||||
highest_confirmed_slot: 1,
|
||||
highest_confirmed_root: 1,
|
||||
highest_super_majority_root: 1,
|
||||
};
|
||||
subscriptions.notify_subscribers(commitment_slots);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl CommitmentAggregationData {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_highest_confirmed_root(mut rooted_stake: Vec<(Slot, u64)>, total_stake: u64) -> Slot {
|
||||
fn get_highest_super_majority_root(mut rooted_stake: Vec<(Slot, u64)>, total_stake: u64) -> Slot {
|
||||
rooted_stake.sort_by(|a, b| a.0.cmp(&b.0).reverse());
|
||||
let mut stake_sum = 0;
|
||||
for (root, stake) in rooted_stake {
|
||||
|
@ -117,8 +117,8 @@ impl AggregateCommitmentService {
|
|||
i64
|
||||
),
|
||||
(
|
||||
"highest-confirmed-root",
|
||||
update_commitment_slots.highest_confirmed_root as i64,
|
||||
"highest-super-majority-root",
|
||||
update_commitment_slots.highest_super_majority_root as i64,
|
||||
i64
|
||||
),
|
||||
(
|
||||
|
@ -143,8 +143,8 @@ impl AggregateCommitmentService {
|
|||
let (block_commitment, rooted_stake) =
|
||||
Self::aggregate_commitment(&ancestors, &aggregation_data.bank);
|
||||
|
||||
let highest_confirmed_root =
|
||||
get_highest_confirmed_root(rooted_stake, aggregation_data.total_stake);
|
||||
let highest_super_majority_root =
|
||||
get_highest_super_majority_root(rooted_stake, aggregation_data.total_stake);
|
||||
|
||||
let mut new_block_commitment = BlockCommitmentCache::new(
|
||||
block_commitment,
|
||||
|
@ -153,7 +153,7 @@ impl AggregateCommitmentService {
|
|||
slot: aggregation_data.bank.slot(),
|
||||
root: aggregation_data.root,
|
||||
highest_confirmed_slot: aggregation_data.root,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
},
|
||||
);
|
||||
let highest_confirmed_slot = new_block_commitment.calculate_highest_confirmed_slot();
|
||||
|
@ -161,11 +161,11 @@ impl AggregateCommitmentService {
|
|||
|
||||
let mut w_block_commitment_cache = block_commitment_cache.write().unwrap();
|
||||
|
||||
let highest_confirmed_root = max(
|
||||
new_block_commitment.highest_confirmed_root(),
|
||||
w_block_commitment_cache.highest_confirmed_root(),
|
||||
let highest_super_majority_root = max(
|
||||
new_block_commitment.highest_super_majority_root(),
|
||||
w_block_commitment_cache.highest_super_majority_root(),
|
||||
);
|
||||
new_block_commitment.set_highest_confirmed_root(highest_confirmed_root);
|
||||
new_block_commitment.set_highest_super_majority_root(highest_super_majority_root);
|
||||
|
||||
*w_block_commitment_cache = new_block_commitment;
|
||||
w_block_commitment_cache.commitment_slots()
|
||||
|
@ -265,12 +265,12 @@ mod tests {
|
|||
};
|
||||
|
||||
#[test]
|
||||
fn test_get_highest_confirmed_root() {
|
||||
assert_eq!(get_highest_confirmed_root(vec![], 10), 0);
|
||||
fn test_get_highest_super_majority_root() {
|
||||
assert_eq!(get_highest_super_majority_root(vec![], 10), 0);
|
||||
let rooted_stake = vec![(0, 5), (1, 5)];
|
||||
assert_eq!(get_highest_confirmed_root(rooted_stake, 10), 0);
|
||||
assert_eq!(get_highest_super_majority_root(rooted_stake, 10), 0);
|
||||
let rooted_stake = vec![(1, 5), (0, 10), (2, 5), (1, 4)];
|
||||
assert_eq!(get_highest_confirmed_root(rooted_stake, 10), 1);
|
||||
assert_eq!(get_highest_super_majority_root(rooted_stake, 10), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -483,11 +483,11 @@ mod tests {
|
|||
}
|
||||
}
|
||||
assert_eq!(rooted_stake.len(), 2);
|
||||
assert_eq!(get_highest_confirmed_root(rooted_stake, 100), 1)
|
||||
assert_eq!(get_highest_super_majority_root(rooted_stake, 100), 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_highest_confirmed_root_advance() {
|
||||
fn test_highest_super_majority_root_advance() {
|
||||
fn get_vote_account_root_slot(vote_pubkey: Pubkey, bank: &Arc<Bank>) -> Slot {
|
||||
let vote_account = bank.get_vote_account(&vote_pubkey).unwrap();
|
||||
let slot = vote_account
|
||||
|
@ -569,20 +569,20 @@ mod tests {
|
|||
},
|
||||
ancestors,
|
||||
);
|
||||
let highest_confirmed_root = block_commitment_cache
|
||||
let highest_super_majority_root = block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
.highest_super_majority_root();
|
||||
bank_forks.set_root(
|
||||
root,
|
||||
&AbsRequestSender::default(),
|
||||
Some(highest_confirmed_root),
|
||||
Some(highest_super_majority_root),
|
||||
);
|
||||
let highest_confirmed_root_bank = bank_forks.get(highest_confirmed_root);
|
||||
assert!(highest_confirmed_root_bank.is_some());
|
||||
let highest_super_majority_root_bank = bank_forks.get(highest_super_majority_root);
|
||||
assert!(highest_super_majority_root_bank.is_some());
|
||||
|
||||
// Add a forked bank. Because the vote for bank 33 landed in the non-ancestor, the vote
|
||||
// account's root (and thus the highest_confirmed_root) rolls back to slot 1
|
||||
// account's root (and thus the highest_super_majority_root) rolls back to slot 1
|
||||
let bank33 = bank_forks.get(33).unwrap();
|
||||
let bank35 = Bank::new_from_parent(&bank33, &Pubkey::default(), 35);
|
||||
bank_forks.insert(bank35);
|
||||
|
@ -598,12 +598,12 @@ mod tests {
|
|||
},
|
||||
ancestors,
|
||||
);
|
||||
let highest_confirmed_root = block_commitment_cache
|
||||
let highest_super_majority_root = block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
let highest_confirmed_root_bank = bank_forks.get(highest_confirmed_root);
|
||||
assert!(highest_confirmed_root_bank.is_some());
|
||||
.highest_super_majority_root();
|
||||
let highest_super_majority_root_bank = bank_forks.get(highest_super_majority_root);
|
||||
assert!(highest_super_majority_root_bank.is_some());
|
||||
|
||||
// Add additional banks beyond lockout built on the new fork to ensure that behavior
|
||||
// continues normally
|
||||
|
@ -638,16 +638,16 @@ mod tests {
|
|||
},
|
||||
ancestors,
|
||||
);
|
||||
let highest_confirmed_root = block_commitment_cache
|
||||
let highest_super_majority_root = block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
.highest_super_majority_root();
|
||||
bank_forks.set_root(
|
||||
root,
|
||||
&AbsRequestSender::default(),
|
||||
Some(highest_confirmed_root),
|
||||
Some(highest_super_majority_root),
|
||||
);
|
||||
let highest_confirmed_root_bank = bank_forks.get(highest_confirmed_root);
|
||||
assert!(highest_confirmed_root_bank.is_some());
|
||||
let highest_super_majority_root_bank = bank_forks.get(highest_super_majority_root);
|
||||
assert!(highest_super_majority_root_bank.is_some());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2130,18 +2130,18 @@ impl ReplayStage {
|
|||
blockstore
|
||||
.set_roots(rooted_slots.iter())
|
||||
.expect("Ledger set roots failed");
|
||||
let highest_confirmed_root = Some(
|
||||
let highest_super_majority_root = Some(
|
||||
block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root(),
|
||||
.highest_super_majority_root(),
|
||||
);
|
||||
Self::handle_new_root(
|
||||
new_root,
|
||||
bank_forks,
|
||||
progress,
|
||||
accounts_background_request_sender,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
heaviest_subtree_fork_choice,
|
||||
duplicate_slots_tracker,
|
||||
gossip_duplicate_confirmed_slots,
|
||||
|
@ -3619,7 +3619,7 @@ impl ReplayStage {
|
|||
bank_forks: &RwLock<BankForks>,
|
||||
progress: &mut ProgressMap,
|
||||
accounts_background_request_sender: &AbsRequestSender,
|
||||
highest_confirmed_root: Option<Slot>,
|
||||
highest_super_majority_root: Option<Slot>,
|
||||
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
||||
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
|
||||
gossip_duplicate_confirmed_slots: &mut GossipDuplicateConfirmedSlots,
|
||||
|
@ -3632,7 +3632,7 @@ impl ReplayStage {
|
|||
let removed_banks = bank_forks.write().unwrap().set_root(
|
||||
new_root,
|
||||
accounts_background_request_sender,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
);
|
||||
|
||||
drop_bank_sender
|
||||
|
@ -4201,7 +4201,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_handle_new_root_ahead_of_highest_confirmed_root() {
|
||||
fn test_handle_new_root_ahead_of_highest_super_majority_root() {
|
||||
let genesis_config = create_genesis_config(10_000).genesis_config;
|
||||
let bank0 = Bank::new_for_tests(&genesis_config);
|
||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank0)));
|
||||
|
|
|
@ -979,7 +979,7 @@ impl Validator {
|
|||
block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(bank_forks.read().unwrap().root());
|
||||
.set_highest_super_majority_root(bank_forks.read().unwrap().root());
|
||||
|
||||
// Park with the RPC service running, ready for inspection!
|
||||
warn!("Validator halted");
|
||||
|
|
|
@ -2512,7 +2512,7 @@ impl Blockstore {
|
|||
pub fn get_confirmed_signatures_for_address2(
|
||||
&self,
|
||||
address: Pubkey,
|
||||
highest_slot: Slot, // highest_confirmed_root or highest_confirmed_slot
|
||||
highest_slot: Slot, // highest_super_majority_root or highest_confirmed_slot
|
||||
before: Option<Signature>,
|
||||
until: Option<Signature>,
|
||||
limit: usize,
|
||||
|
@ -8334,13 +8334,13 @@ pub mod tests {
|
|||
blockstore
|
||||
.set_roots(vec![1, 2, 4, 5, 6, 7, 8].iter())
|
||||
.unwrap();
|
||||
let highest_confirmed_root = 8;
|
||||
let highest_super_majority_root = 8;
|
||||
|
||||
// Fetch all rooted signatures for address 0 at once...
|
||||
let sig_infos = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
None,
|
||||
None,
|
||||
usize::MAX,
|
||||
|
@ -8354,7 +8354,7 @@ pub mod tests {
|
|||
let all1 = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address1,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
None,
|
||||
None,
|
||||
usize::MAX,
|
||||
|
@ -8368,7 +8368,7 @@ pub mod tests {
|
|||
let sig_infos = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
if i == 0 {
|
||||
None
|
||||
} else {
|
||||
|
@ -8388,7 +8388,7 @@ pub mod tests {
|
|||
let results = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
if i == 0 {
|
||||
None
|
||||
} else {
|
||||
|
@ -8410,7 +8410,7 @@ pub mod tests {
|
|||
let sig_infos = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
Some(all0[all0.len() - 1].signature),
|
||||
None,
|
||||
1,
|
||||
|
@ -8422,7 +8422,7 @@ pub mod tests {
|
|||
assert!(blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
None,
|
||||
Some(all0[0].signature),
|
||||
2,
|
||||
|
@ -8437,7 +8437,7 @@ pub mod tests {
|
|||
let results = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
if i == 0 {
|
||||
None
|
||||
} else {
|
||||
|
@ -8460,7 +8460,7 @@ pub mod tests {
|
|||
let results = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address1,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
if i == 0 {
|
||||
None
|
||||
} else {
|
||||
|
@ -8482,7 +8482,7 @@ pub mod tests {
|
|||
let sig_infos = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
Some(all1[0].signature),
|
||||
None,
|
||||
usize::MAX,
|
||||
|
@ -8497,7 +8497,7 @@ pub mod tests {
|
|||
let results2 = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
Some(all1[0].signature),
|
||||
Some(all1[4].signature),
|
||||
usize::MAX,
|
||||
|
@ -8688,7 +8688,7 @@ pub mod tests {
|
|||
let sig_infos = blockstore
|
||||
.get_confirmed_signatures_for_address2(
|
||||
address0,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
Some(all0[0].signature),
|
||||
None,
|
||||
usize::MAX,
|
||||
|
|
|
@ -129,7 +129,7 @@ fn is_finalized(
|
|||
blockstore: &Blockstore,
|
||||
slot: Slot,
|
||||
) -> bool {
|
||||
slot <= block_commitment_cache.highest_confirmed_root()
|
||||
slot <= block_commitment_cache.highest_super_majority_root()
|
||||
&& (blockstore.is_root(slot) || bank.status_cache_ancestors().contains(&slot))
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ impl JsonRpcRequestProcessor {
|
|||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root()
|
||||
.highest_super_majority_root()
|
||||
{
|
||||
self.check_blockstore_writes_complete(slot)?;
|
||||
let result = self.blockstore.get_rooted_block(slot, true);
|
||||
|
@ -1167,16 +1167,16 @@ impl JsonRpcRequestProcessor {
|
|||
let commitment = commitment.unwrap_or_default();
|
||||
check_is_at_least_confirmed(commitment)?;
|
||||
|
||||
let highest_confirmed_root = self
|
||||
let highest_super_majority_root = self
|
||||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
.highest_super_majority_root();
|
||||
|
||||
let end_slot = min(
|
||||
end_slot.unwrap_or_else(|| start_slot.saturating_add(MAX_GET_CONFIRMED_BLOCKS_RANGE)),
|
||||
if commitment.is_finalized() {
|
||||
highest_confirmed_root
|
||||
highest_super_majority_root
|
||||
} else {
|
||||
self.bank(Some(CommitmentConfig::confirmed())).slot()
|
||||
},
|
||||
|
@ -1220,7 +1220,7 @@ impl JsonRpcRequestProcessor {
|
|||
.blockstore
|
||||
.rooted_slot_iterator(max(start_slot, lowest_blockstore_slot))
|
||||
.map_err(|_| Error::internal_error())?
|
||||
.filter(|&slot| slot <= end_slot && slot <= highest_confirmed_root)
|
||||
.filter(|&slot| slot <= end_slot && slot <= highest_super_majority_root)
|
||||
.collect();
|
||||
let last_element = blocks
|
||||
.last()
|
||||
|
@ -1273,11 +1273,11 @@ impl JsonRpcRequestProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
let highest_confirmed_root = self
|
||||
let highest_super_majority_root = self
|
||||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
.highest_super_majority_root();
|
||||
|
||||
// Finalized blocks
|
||||
let mut blocks: Vec<_> = self
|
||||
|
@ -1285,7 +1285,7 @@ impl JsonRpcRequestProcessor {
|
|||
.rooted_slot_iterator(max(start_slot, lowest_blockstore_slot))
|
||||
.map_err(|_| Error::internal_error())?
|
||||
.take(limit)
|
||||
.filter(|&slot| slot <= highest_confirmed_root)
|
||||
.filter(|&slot| slot <= highest_super_majority_root)
|
||||
.collect();
|
||||
|
||||
// Maybe add confirmed blocks
|
||||
|
@ -1316,7 +1316,7 @@ impl JsonRpcRequestProcessor {
|
|||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root()
|
||||
.highest_super_majority_root()
|
||||
{
|
||||
let result = self.blockstore.get_block_time(slot);
|
||||
self.check_blockstore_root(&result, slot)?;
|
||||
|
@ -1400,7 +1400,7 @@ impl JsonRpcRequestProcessor {
|
|||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root()
|
||||
.highest_super_majority_root()
|
||||
})
|
||||
.map(|(slot, status_meta)| {
|
||||
let err = status_meta.status.clone().err();
|
||||
|
@ -1517,7 +1517,7 @@ impl JsonRpcRequestProcessor {
|
|||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root()
|
||||
.highest_super_majority_root()
|
||||
{
|
||||
return Ok(Some(encode_transaction(confirmed_transaction)?));
|
||||
}
|
||||
|
@ -1553,7 +1553,7 @@ impl JsonRpcRequestProcessor {
|
|||
self.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root(),
|
||||
.highest_super_majority_root(),
|
||||
);
|
||||
self.blockstore
|
||||
.get_confirmed_signatures_for_address(pubkey, start_slot, end_slot)
|
||||
|
@ -1575,23 +1575,23 @@ impl JsonRpcRequestProcessor {
|
|||
check_is_at_least_confirmed(commitment)?;
|
||||
|
||||
if self.config.enable_rpc_transaction_history {
|
||||
let highest_confirmed_root = self
|
||||
let highest_super_majority_root = self
|
||||
.block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
.highest_super_majority_root();
|
||||
let highest_slot = if commitment.is_confirmed() {
|
||||
let confirmed_bank = self.get_bank_with_config(config)?;
|
||||
confirmed_bank.slot()
|
||||
} else {
|
||||
let min_context_slot = config.min_context_slot.unwrap_or_default();
|
||||
if highest_confirmed_root < min_context_slot {
|
||||
if highest_super_majority_root < min_context_slot {
|
||||
return Err(RpcCustomError::MinContextSlotNotReached {
|
||||
context_slot: highest_confirmed_root,
|
||||
context_slot: highest_super_majority_root,
|
||||
}
|
||||
.into());
|
||||
}
|
||||
highest_confirmed_root
|
||||
highest_super_majority_root
|
||||
};
|
||||
|
||||
let SignatureInfosForAddress {
|
||||
|
@ -1607,7 +1607,7 @@ impl JsonRpcRequestProcessor {
|
|||
.into_iter()
|
||||
.map(|x| {
|
||||
let mut item: RpcConfirmedTransactionStatusWithSignature = x.into();
|
||||
if item.slot <= highest_confirmed_root {
|
||||
if item.slot <= highest_super_majority_root {
|
||||
item.confirmation_status =
|
||||
Some(TransactionConfirmationStatus::Finalized);
|
||||
} else {
|
||||
|
@ -6989,7 +6989,7 @@ pub mod tests {
|
|||
rpc.block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(8);
|
||||
.set_highest_super_majority_root(8);
|
||||
|
||||
let request = create_test_request("getBlockProduction", Some(json!([])));
|
||||
let result: RpcResponse<RpcBlockProduction> =
|
||||
|
@ -7046,7 +7046,7 @@ pub mod tests {
|
|||
rpc.block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(8);
|
||||
.set_highest_super_majority_root(8);
|
||||
|
||||
let request = create_test_request("getBlocks", Some(json!([0u64])));
|
||||
let result: Vec<Slot> = parse_success_result(rpc.handle_request_sync(request));
|
||||
|
@ -7071,7 +7071,7 @@ pub mod tests {
|
|||
rpc.block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(std::u64::MAX);
|
||||
.set_highest_super_majority_root(std::u64::MAX);
|
||||
|
||||
let request = create_test_request(
|
||||
"getBlocks",
|
||||
|
@ -7099,7 +7099,7 @@ pub mod tests {
|
|||
rpc.block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(8);
|
||||
.set_highest_super_majority_root(8);
|
||||
|
||||
let request = create_test_request("getBlocksWithLimit", Some(json!([0u64, 500_001u64])));
|
||||
let response = parse_failure_response(rpc.handle_request_sync(request));
|
||||
|
@ -7145,7 +7145,7 @@ pub mod tests {
|
|||
rpc.block_commitment_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_highest_confirmed_root(7);
|
||||
.set_highest_super_majority_root(7);
|
||||
|
||||
let slot_duration = slot_duration_from_slots_per_year(rpc.working_bank().slots_per_year());
|
||||
|
||||
|
@ -7391,13 +7391,13 @@ pub mod tests {
|
|||
block_commitment.entry(1).or_insert(cache0);
|
||||
block_commitment.entry(2).or_insert(cache1);
|
||||
block_commitment.entry(3).or_insert(cache2);
|
||||
let highest_confirmed_root = 1;
|
||||
let highest_super_majority_root = 1;
|
||||
let block_commitment_cache = BlockCommitmentCache::new(
|
||||
block_commitment,
|
||||
50,
|
||||
CommitmentSlots {
|
||||
slot: bank.slot(),
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
..CommitmentSlots::default()
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1239,7 +1239,7 @@ mod tests {
|
|||
slot: 2,
|
||||
root: 1,
|
||||
highest_confirmed_slot: 1,
|
||||
highest_confirmed_root: 1,
|
||||
highest_super_majority_root: 1,
|
||||
};
|
||||
subscriptions.notify_subscribers(commitment_slots);
|
||||
let expected = json!({
|
||||
|
|
|
@ -461,7 +461,7 @@ fn initial_last_notified_slot(
|
|||
block_commitment_cache
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root()
|
||||
.highest_super_majority_root()
|
||||
} else if params.commitment.is_confirmed() {
|
||||
optimistically_confirmed_bank.read().unwrap().bank.slot()
|
||||
} else {
|
||||
|
@ -960,7 +960,7 @@ impl RpcSubscriptions {
|
|||
subscriptions.for_each(|(_id, subscription)| {
|
||||
let slot = if let Some(commitment) = subscription.commitment() {
|
||||
if commitment.is_finalized() {
|
||||
Some(commitment_slots.highest_confirmed_root)
|
||||
Some(commitment_slots.highest_super_majority_root)
|
||||
} else if commitment.is_confirmed() {
|
||||
Some(commitment_slots.highest_confirmed_slot)
|
||||
} else {
|
||||
|
@ -1567,7 +1567,7 @@ pub(crate) mod tests {
|
|||
slot,
|
||||
root: slot,
|
||||
highest_confirmed_slot: slot,
|
||||
highest_confirmed_root: slot,
|
||||
highest_super_majority_root: slot,
|
||||
});
|
||||
let should_err = receiver.recv_timeout(Duration::from_millis(300));
|
||||
assert!(should_err.is_err());
|
||||
|
@ -1769,7 +1769,7 @@ pub(crate) mod tests {
|
|||
slot,
|
||||
root: slot,
|
||||
highest_confirmed_slot: slot,
|
||||
highest_confirmed_root: slot,
|
||||
highest_super_majority_root: slot,
|
||||
});
|
||||
let actual_resp = receiver.recv();
|
||||
let actual_resp = serde_json::from_str::<serde_json::Value>(&actual_resp).unwrap();
|
||||
|
|
|
@ -241,7 +241,7 @@ impl BankForks {
|
|||
&mut self,
|
||||
root: Slot,
|
||||
accounts_background_request_sender: &AbsRequestSender,
|
||||
highest_confirmed_root: Option<Slot>,
|
||||
highest_super_majority_root: Option<Slot>,
|
||||
) -> (Vec<Arc<Bank>>, SetRootMetrics) {
|
||||
let old_epoch = self.root_bank().epoch();
|
||||
// To support `RootBankCache` (via `ReadOnlyAtomicSlot`) accessing `root` *without* locking
|
||||
|
@ -380,7 +380,7 @@ impl BankForks {
|
|||
let accounts_data_len = root_bank.load_accounts_data_size() as i64;
|
||||
let mut prune_time = Measure::start("set_root::prune");
|
||||
let (removed_banks, prune_slots_ms, prune_remove_ms) =
|
||||
self.prune_non_rooted(root, highest_confirmed_root);
|
||||
self.prune_non_rooted(root, highest_super_majority_root);
|
||||
prune_time.stop();
|
||||
let dropped_banks_len = removed_banks.len();
|
||||
|
||||
|
@ -411,7 +411,7 @@ impl BankForks {
|
|||
&mut self,
|
||||
root: Slot,
|
||||
accounts_background_request_sender: &AbsRequestSender,
|
||||
highest_confirmed_root: Option<Slot>,
|
||||
highest_super_majority_root: Option<Slot>,
|
||||
) -> Vec<Arc<Bank>> {
|
||||
let program_cache_prune_start = Instant::now();
|
||||
let root_bank = self
|
||||
|
@ -427,7 +427,7 @@ impl BankForks {
|
|||
let (removed_banks, set_root_metrics) = self.do_set_root_return_metrics(
|
||||
root,
|
||||
accounts_background_request_sender,
|
||||
highest_confirmed_root,
|
||||
highest_super_majority_root,
|
||||
);
|
||||
datapoint_info!(
|
||||
"bank-forks_set_root",
|
||||
|
@ -581,14 +581,14 @@ impl BankForks {
|
|||
fn prune_non_rooted(
|
||||
&mut self,
|
||||
root: Slot,
|
||||
highest_confirmed_root: Option<Slot>,
|
||||
highest_super_majority_root: Option<Slot>,
|
||||
) -> (Vec<Arc<Bank>>, u64, u64) {
|
||||
// Clippy doesn't like separating the two collects below,
|
||||
// but we want to collect timing separately, and the 2nd requires
|
||||
// a unique borrow to self which is already borrowed by self.banks
|
||||
#![allow(clippy::needless_collect)]
|
||||
let mut prune_slots_time = Measure::start("prune_slots");
|
||||
let highest_confirmed_root = highest_confirmed_root.unwrap_or(root);
|
||||
let highest_super_majority_root = highest_super_majority_root.unwrap_or(root);
|
||||
let prune_slots: Vec<_> = self
|
||||
.banks
|
||||
.keys()
|
||||
|
@ -597,7 +597,7 @@ impl BankForks {
|
|||
let keep = *slot == root
|
||||
|| self.descendants[&root].contains(slot)
|
||||
|| (*slot < root
|
||||
&& *slot >= highest_confirmed_root
|
||||
&& *slot >= highest_super_majority_root
|
||||
&& self.descendants[slot].contains(&root));
|
||||
!keep
|
||||
})
|
||||
|
@ -938,7 +938,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_bank_forks_with_highest_confirmed_root() {
|
||||
fn test_bank_forks_with_highest_super_majority_root() {
|
||||
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000);
|
||||
let mut banks = vec![Arc::new(Bank::new_for_tests(&genesis_config))];
|
||||
assert_eq!(banks[0].slot(), 0);
|
||||
|
|
|
@ -97,8 +97,8 @@ impl BlockCommitmentCache {
|
|||
self.commitment_slots.highest_confirmed_slot
|
||||
}
|
||||
|
||||
pub fn highest_confirmed_root(&self) -> Slot {
|
||||
self.commitment_slots.highest_confirmed_root
|
||||
pub fn highest_super_majority_root(&self) -> Slot {
|
||||
self.commitment_slots.highest_super_majority_root
|
||||
}
|
||||
|
||||
pub fn commitment_slots(&self) -> CommitmentSlots {
|
||||
|
@ -120,7 +120,7 @@ impl BlockCommitmentCache {
|
|||
CommitmentLevel::SingleGossip | CommitmentLevel::Confirmed => {
|
||||
self.highest_gossip_confirmed_slot()
|
||||
}
|
||||
CommitmentLevel::Max | CommitmentLevel::Finalized => self.highest_confirmed_root(),
|
||||
CommitmentLevel::Max | CommitmentLevel::Finalized => self.highest_super_majority_root(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ impl BlockCommitmentCache {
|
|||
slot,
|
||||
root,
|
||||
highest_confirmed_slot: root,
|
||||
highest_confirmed_root: root,
|
||||
highest_super_majority_root: root,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ impl BlockCommitmentCache {
|
|||
self.commitment_slots.highest_confirmed_slot = slot;
|
||||
}
|
||||
|
||||
pub fn set_highest_confirmed_root(&mut self, root: Slot) {
|
||||
self.commitment_slots.highest_confirmed_root = root;
|
||||
pub fn set_highest_super_majority_root(&mut self, root: Slot) {
|
||||
self.commitment_slots.highest_super_majority_root = root;
|
||||
}
|
||||
|
||||
pub fn initialize_slots(&mut self, slot: Slot, root: Slot) {
|
||||
|
@ -202,7 +202,7 @@ impl BlockCommitmentCache {
|
|||
self.commitment_slots.slot = slot;
|
||||
self.commitment_slots.highest_confirmed_slot = slot;
|
||||
self.commitment_slots.root = root;
|
||||
self.commitment_slots.highest_confirmed_root = root;
|
||||
self.commitment_slots.highest_super_majority_root = root;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,8 +214,8 @@ pub struct CommitmentSlots {
|
|||
pub root: Slot,
|
||||
/// Highest cluster-confirmed slot
|
||||
pub highest_confirmed_slot: Slot,
|
||||
/// Highest cluster-confirmed root
|
||||
pub highest_confirmed_root: Slot,
|
||||
/// Highest slot rooted by a super majority of the cluster
|
||||
pub highest_super_majority_root: Slot,
|
||||
}
|
||||
|
||||
impl CommitmentSlots {
|
||||
|
|
Loading…
Reference in New Issue