Skip to content

Commit

Permalink
Garbage Collection - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrm50 committed Feb 27, 2025
1 parent b710a69 commit f03bb35
Show file tree
Hide file tree
Showing 6 changed files with 671 additions and 119 deletions.
17 changes: 15 additions & 2 deletions consensus/core/src/authority_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,15 @@ mod tests {
#[tokio::test(flavor = "current_thread")]
async fn test_authority_committee(
#[values(ConsensusNetwork::Tonic)] network_type: ConsensusNetwork,
#[values(0, 5, 10)] gc_depth: u32,
) {
let db_registry = Registry::new();
DBMetrics::init(&db_registry);

const NUM_OF_AUTHORITIES: usize = 4;
let (committee, keypairs) = local_committee_and_keys(0, [1; NUM_OF_AUTHORITIES].to_vec());
let mut protocol_config = ProtocolConfig::get_for_max_version_UNSAFE();
protocol_config.set_consensus_gc_depth_for_testing(gc_depth);
let temp_dirs = (0..NUM_OF_AUTHORITIES)
.map(|_| TempDir::new().unwrap())
.collect::<Vec<_>>();
Expand All @@ -504,6 +507,7 @@ mod tests {
keypairs.clone(),
network_type,
boot_counters[index],
protocol_config.clone(),
)
.await;
boot_counters[index] += 1;
Expand Down Expand Up @@ -560,6 +564,7 @@ mod tests {
keypairs.clone(),
network_type,
boot_counters[index],
protocol_config.clone(),
)
.await;
boot_counters[index] += 1;
Expand All @@ -577,6 +582,7 @@ mod tests {
#[tokio::test(flavor = "current_thread")]
async fn test_amnesia_recovery_success(
#[values(ConsensusNetwork::Tonic)] network_type: ConsensusNetwork,
#[values(0, 5, 10)] gc_depth: u32,
) {
telemetry_subscribers::init_for_testing();
let db_registry = Registry::new();
Expand All @@ -589,6 +595,9 @@ mod tests {
let mut temp_dirs = BTreeMap::new();
let mut boot_counters = [0; NUM_OF_AUTHORITIES];

let mut protocol_config = ProtocolConfig::get_for_max_version_UNSAFE();
protocol_config.set_consensus_gc_depth_for_testing(gc_depth);

for (index, _authority_info) in committee.authorities() {
let dir = TempDir::new().unwrap();
let (authority, receiver) = make_authority(
Expand All @@ -598,6 +607,7 @@ mod tests {
keypairs.clone(),
network_type,
boot_counters[index],
protocol_config.clone(),
)
.await;
assert!(
Expand Down Expand Up @@ -655,6 +665,7 @@ mod tests {
keypairs.clone(),
network_type,
boot_counters[index_1],
protocol_config.clone(),
)
.await;
assert!(
Expand All @@ -676,6 +687,7 @@ mod tests {
keypairs,
network_type,
boot_counters[index_2],
protocol_config.clone(),
)
.await;
assert!(
Expand Down Expand Up @@ -710,6 +722,7 @@ mod tests {
keypairs: Vec<(NetworkKeyPair, ProtocolKeyPair)>,
network_type: ConsensusNetwork,
boot_counter: u64,
protocol_config: ProtocolConfig,
) -> (ConsensusAuthority, UnboundedReceiver<CommittedSubDag>) {
let registry = Registry::new();

Expand All @@ -735,15 +748,15 @@ mod tests {
index,
committee,
parameters,
ProtocolConfig::get_for_max_version_UNSAFE(),
protocol_config,
protocol_keypair,
network_keypair,
Arc::new(txn_verifier),
commit_consumer,
registry,
boot_counter,
)
.await;
.await;

(authority, receiver)
}
Expand Down
Loading

0 comments on commit f03bb35

Please sign in to comment.