Skip to content

Commit 7b79af8

Browse files
committed
gc for view < decided view
1 parent b404a4e commit 7b79af8

11 files changed

Lines changed: 3 additions & 43 deletions

File tree

crates/espresso/node/src/context.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{
22
fmt::{Debug, Display},
33
future::Future,
44
marker::PhantomData,
5-
num::NonZeroU64,
65
sync::Arc,
76
time::{Duration, Instant},
87
};
@@ -126,7 +125,6 @@ where
126125
event_consumer: impl PersistenceEventConsumer + 'static,
127126
proposal_fetcher_cfg: ProposalFetcherConfig,
128127
bootstrap_epoch_catchup_timeout: Duration,
129-
new_protocol_consensus_gc_interval: NonZeroU64,
130128
) -> anyhow::Result<Self> {
131129
let config = &network_config.config;
132130
let pub_key = validator_config.public_key;
@@ -221,7 +219,6 @@ where
221219
.stake_table_capacity(stake_table_capacity)
222220
.timeout_duration(Duration::from_secs(10))
223221
.storage(Arc::clone(&persistence))
224-
.garbage_collection_interval(new_protocol_consensus_gc_interval.get())
225222
.make();
226223

227224
let legacy_event_rx = handle.event_stream_known_impl().deactivate();

crates/espresso/node/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod state_cert;
1919
pub mod state_signature;
2020
pub mod util;
2121

22-
use std::{fmt::Debug, marker::PhantomData, num::NonZeroU64, sync::Arc, time::Duration};
22+
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration};
2323

2424
use alloy::primitives::U256;
2525
use anyhow::Context;
@@ -133,8 +133,6 @@ pub struct NetworkParams {
133133
/// Per-step timeout for the startup stake-table catchup walk
134134
/// (`bootstrap_epoch_window`).
135135
pub bootstrap_epoch_catchup_timeout: Duration,
136-
/// Number of blocks between new-protocol consensus garbage collection passes.
137-
pub new_protocol_consensus_gc_interval: NonZeroU64,
138136
/// The address to advertise as our public API's URL
139137
pub public_api_url: Option<Url>,
140138
/// Cliquenet network address.
@@ -830,7 +828,6 @@ where
830828
event_consumer,
831829
proposal_fetcher_config,
832830
network_params.bootstrap_epoch_catchup_timeout,
833-
network_params.new_protocol_consensus_gc_interval,
834831
)
835832
.await?;
836833

@@ -1660,7 +1657,6 @@ pub mod testing {
16601657
event_consumer,
16611658
Default::default(),
16621659
Duration::from_secs(2),
1663-
NonZeroU64::new(100).unwrap(),
16641660
)
16651661
.await
16661662
.unwrap()

crates/espresso/node/src/options.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::{
66
collections::HashSet,
77
fmt::{self, Formatter},
88
iter::once,
9-
num::NonZeroU64,
109
path::PathBuf,
1110
time::Duration,
1211
};
@@ -341,18 +340,6 @@ pub struct Options {
341340
#[clap(long, env = "ESPRESSO_NODE_BOOTSTRAP_EPOCH_CATCHUP_TIMEOUT", default_value = "30s", value_parser = parse_duration)]
342341
pub bootstrap_epoch_catchup_timeout: Duration,
343342

344-
/// Number of blocks between new-protocol garbage collection passes.
345-
///
346-
/// Controls how often the new-protocol coordinator triggers garbage
347-
/// collection of decided views/epochs across consensus state, VID,
348-
/// vote collectors, and storage.
349-
#[clap(
350-
long,
351-
env = "ESPRESSO_NODE_NEW_PROTOCOL_CONSENSUS_GC_INTERVAL",
352-
default_value = "100"
353-
)]
354-
pub new_protocol_consensus_gc_interval: NonZeroU64,
355-
356343
#[clap(flatten)]
357344
pub logging: logging::Config,
358345

@@ -691,7 +678,6 @@ pub struct PublicNodeConfig {
691678
pub catchup_base_timeout: Duration,
692679
pub local_catchup_timeout: Duration,
693680
pub bootstrap_epoch_catchup_timeout: Duration,
694-
pub new_protocol_consensus_gc_interval: NonZeroU64,
695681
pub catchup_backoff: BackoffParams,
696682
pub proposal_fetcher: ProposalFetcherConfig,
697683
pub libp2p: Libp2pTuning,
@@ -1031,7 +1017,6 @@ impl PublicNodeConfig {
10311017
catchup_base_timeout: opt.catchup_base_timeout,
10321018
local_catchup_timeout: opt.local_catchup_timeout,
10331019
bootstrap_epoch_catchup_timeout: opt.bootstrap_epoch_catchup_timeout,
1034-
new_protocol_consensus_gc_interval: opt.new_protocol_consensus_gc_interval,
10351020
catchup_backoff: opt.catchup_backoff,
10361021
proposal_fetcher: opt.proposal_fetcher_config,
10371022
libp2p: Libp2pTuning::from(opt),

crates/espresso/node/src/run.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ where
103103
catchup_base_timeout: opt.catchup_base_timeout,
104104
local_catchup_timeout: opt.local_catchup_timeout,
105105
bootstrap_epoch_catchup_timeout: opt.bootstrap_epoch_catchup_timeout,
106-
new_protocol_consensus_gc_interval: opt.new_protocol_consensus_gc_interval,
107106
libp2p_history_gossip: opt.libp2p_history_gossip,
108107
libp2p_history_length: opt.libp2p_history_length,
109108
libp2p_max_ihave_length: opt.libp2p_max_ihave_length,

crates/hotshot/new-protocol/bench/src/node.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ async fn build_coordinator(
131131
upgrade_lock.clone(),
132132
genesis_leaf.clone(),
133133
epoch_height,
134-
100,
135134
);
136135

137136
let vote1_collector = VoteCollector::new(membership.clone(), upgrade_lock.clone());

crates/hotshot/new-protocol/src/consensus.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ pub struct Consensus<T: NodeType> {
199199
node_id: KeyPrefix,
200200
upgrade_lock: UpgradeLock<T>,
201201

202-
garbage_collection_interval: BlockNumber,
203202
pub(crate) epoch_height: BlockNumber,
204203
}
205204

@@ -232,7 +231,6 @@ impl<T: NodeType> Consensus<T> {
232231
upgrade_lock: UpgradeLock<T>,
233232
genesis_leaf: Leaf2<T>,
234233
epoch_height: B,
235-
garbage_collection_interval: B,
236234
) -> Self
237235
where
238236
B: Into<BlockNumber>,
@@ -270,7 +268,6 @@ impl<T: NodeType> Consensus<T> {
270268
state_certs: BTreeMap::new(),
271269
upgrade_lock,
272270
vid_shares: BTreeMap::new(),
273-
garbage_collection_interval: garbage_collection_interval.into(),
274271
epoch_height: epoch_height.into(),
275272
}
276273
}
@@ -1180,10 +1177,8 @@ impl<T: NodeType> Consensus<T> {
11801177
}
11811178
let new_decided_view = max(self.last_decided_view, leaf.view_number());
11821179
let last_decided_leaf = leaf.clone();
1183-
let mut gc = None;
1184-
if leaf.block_header().block_number() % *self.garbage_collection_interval == 0 {
1185-
gc = Some((leaf.view_number(), leaf.justify_qc().epoch()));
1186-
}
1180+
// garbage collect everything strictly below the newly decided view.
1181+
let gc = Some((leaf.view_number(), leaf.justify_qc().epoch()));
11871182
let mut decided = vec![leaf];
11881183
let mut vid_shares = vec![self.signed_vid_share(view)];
11891184

@@ -1201,11 +1196,6 @@ impl<T: NodeType> Consensus<T> {
12011196
if let Some(payload) = self.blocks.get(&parent_view) {
12021197
leaf.fill_block_payload_unchecked(payload.clone());
12031198
}
1204-
if gc.is_none()
1205-
&& leaf.block_header().block_number() % *self.garbage_collection_interval == 0
1206-
{
1207-
gc = Some((leaf.view_number(), leaf.justify_qc().epoch()));
1208-
}
12091199
vid_shares.push(self.signed_vid_share(parent_view));
12101200
decided.push(leaf);
12111201
parent_view = proposal.justify_qc.view_number();

crates/hotshot/new-protocol/src/coordinator.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ where
118118
stake_table_capacity: usize,
119119
timeout_duration: Duration,
120120
storage: S,
121-
garbage_collection_interval: u64,
122121
) -> Self {
123122
let mut consensus = Consensus::new(
124123
membership_coordinator.clone(),
@@ -129,7 +128,6 @@ where
129128
upgrade_lock.clone(),
130129
initializer.anchor_leaf.clone(),
131130
initializer.epoch_height,
132-
garbage_collection_interval,
133131
);
134132

135133
let genesis_cert1 = initializer.high_qc.clone();

crates/hotshot/new-protocol/src/tests/common/coordinator_builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ pub async fn build_test_coordinator<N: Network<TestTypes>>(
7373
upgrade_lock.clone(),
7474
genesis_leaf.clone(),
7575
epoch_height,
76-
100,
7776
);
7877

7978
let vid_disperser = VidDisperser::new(membership.clone());

crates/hotshot/new-protocol/src/tests/common/harness.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ impl TestHarness {
8888
upgrade_lock.clone(),
8989
genesis_leaf.clone(),
9090
epoch_height,
91-
100,
9291
);
9392

9493
let vid_disperse_task = VidDisperser::new(membership.clone());

crates/hotshot/new-protocol/src/tests/common/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,6 @@ impl ConsensusHarness {
877877
test_upgrade_lock(),
878878
genesis_leaf,
879879
epoch_height,
880-
100,
881880
);
882881
Self {
883882
consensus,

0 commit comments

Comments
 (0)