Skip to content

Commit faa517a

Browse files
committed
chore(starfish-core): fix clippy lints surfaced by ci-clippy
- Gate `DagState::new` behind `#[cfg(test)]` (production uses `new_with_misbehavior_store` to share the misbehavior store). - Drop the unused test-only `MisbehaviorStore::dummy_for_test` and `DagState::evicted_rounds` helpers. - Remove redundant `use bcs;` in `scoring_metrics_store::tests`. - Use `BTreeMap::keys()` instead of `iter().map(|(k, _)| ..)` in DagState's flush trace log. - Drop redundant clones at `DagState::new` / `RegularCommitSyncer::new` call sites where the source values are dropped without further use.
1 parent 0a6abc9 commit faa517a

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

crates/starfish/core/src/commit_syncer/regular.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ mod tests {
10201020
commit_consumer_monitor.clone(),
10211021
network_client,
10221022
block_verifier,
1023-
dag_state.clone(),
1023+
dag_state,
10241024
header_synchronizer,
10251025
Arc::new(MisbehaviorStore::new(4)),
10261026
None,

crates/starfish/core/src/dag_state.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ pub(crate) struct DagState {
236236
}
237237

238238
impl DagState {
239-
/// Initializes DagState from storage.
239+
/// Initializes DagState from storage with a freshly constructed
240+
/// `MisbehaviorStore`. Production code uses `new_with_misbehavior_store`
241+
/// to share the store with other components; this constructor exists
242+
/// for tests that don't need the shared instance.
243+
#[cfg(test)]
240244
pub(crate) fn new(context: Arc<Context>, store: Arc<dyn Store>) -> Self {
241245
let misbehavior_store = Arc::new(MisbehaviorStore::new(context.committee.size()));
242246
Self::new_with_misbehavior_store(context, store, misbehavior_store)
@@ -2504,11 +2508,6 @@ impl DagState {
25042508
pub(crate) fn misbehavior_store(&self) -> &MisbehaviorStore {
25052509
&self.misbehavior_store
25062510
}
2507-
2508-
#[cfg(test)]
2509-
pub(crate) fn evicted_rounds(&self) -> Vec<Round> {
2510-
self.evicted_rounds.clone()
2511-
}
25122511
}
25132512
#[cfg(test)]
25142513
mod test {

crates/starfish/core/src/scoring_metrics_store.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,6 @@ pub(crate) struct MisbehaviorCountsV1 {
481481

482482
#[cfg(test)]
483483
impl MisbehaviorStore {
484-
pub(crate) fn dummy_for_test(committee_size: usize) -> Self {
485-
Self::new(committee_size)
486-
}
487-
488484
pub(crate) fn persisted_missing_proposals(&self) -> Vec<u64> {
489485
self.persisted.collect(|c| c.missing_proposals)
490486
}
@@ -523,7 +519,6 @@ impl MisbehaviorCounts {
523519
mod tests {
524520
use std::sync::Arc;
525521

526-
use bcs;
527522
use starfish_config::Parameters;
528523

529524
use super::*;
@@ -741,7 +736,7 @@ mod tests {
741736
let persisted_missing_before = scoring.persisted_missing_proposals();
742737
let in_memory_missing_before_drop = scoring.in_memory_missing_proposals();
743738
drop(dag_state);
744-
let mut dag_state = DagState::new(context.clone(), store.clone());
739+
let mut dag_state = DagState::new(context, store);
745740

746741
// Persisted metrics should be restored, and in-memory recomputed from
747742
// the cached block refs loaded during recovery.
@@ -811,7 +806,7 @@ mod tests {
811806
drop(dag_state);
812807

813808
// Recover from storage and flush again without new blocks
814-
let mut dag_state = DagState::new(context.clone(), store.clone());
809+
let mut dag_state = DagState::new(context, store);
815810
dag_state.flush();
816811

817812
// Persisted counts must NOT have doubled

0 commit comments

Comments
 (0)