Skip to content

Commit fc9a707

Browse files
authored
add unreachable_pub lint and fix issues
2 parents a67ef95 + 3d28624 commit fc9a707

File tree

29 files changed

+133
-117
lines changed

29 files changed

+133
-117
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ exclude = [".github/"]
1818

1919
[workspace.lints.rust]
2020
type_alias_bounds = "allow"
21+
unreachable_pub = "warn"
2122

2223
[workspace.lints.clippy]
2324
tabs_in_doc_comments = "allow"

examples/custom-bundle-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct CustomBundleType {
131131
}
132132

133133
impl CustomBundleType {
134-
pub fn with_min_profit(min_profit: U256) -> Self {
134+
fn with_min_profit(min_profit: U256) -> Self {
135135
Self {
136136
txs: Vec::new(),
137137
reverting_txs: Vec::new(),

src/pipelines/events.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ use {
1313
/// - In a pipeline with nested pipelines, the top-level pipline's event bus is
1414
/// responsible for handling all events of all contained pipelines and steps.
1515
#[derive(Default, Debug)]
16-
pub struct EventsBus<P: Platform> {
16+
pub(super) struct EventsBus<P: Platform> {
1717
publishers: DashMap<TypeId, Sender<Arc<dyn Any + Send + Sync>>>,
1818
phantom: PhantomData<P>,
1919
}
2020

2121
impl<P: Platform> EventsBus<P> {
2222
/// Publishes an event of type `E` to all current subscribers.
2323
/// Each subscriber will receive a clone of the event.
24-
pub fn publish<E>(&self, event: E)
24+
pub(super) fn publish<E>(&self, event: E)
2525
where
2626
E: Clone + Any + Send + Sync + 'static,
2727
{
2828
let _ = self.sender::<E>().send(Arc::new(event));
2929
}
3030

3131
/// Returns a stream that yields events of type `E`.
32-
pub fn subscribe<E>(&self) -> impl Stream<Item = E> + Send + Sync + 'static
32+
pub(super) fn subscribe<E>(
33+
&self,
34+
) -> impl Stream<Item = E> + Send + Sync + 'static
3335
where
3436
E: Clone + Any + Send + Sync + 'static,
3537
{
@@ -63,7 +65,7 @@ impl<P: Platform> EventsBus<P> {
6365
}
6466

6567
/// System events emitted by the pipeline itself.
66-
pub mod system_events {
68+
pub(super) mod system_events {
6769
use {
6870
super::*,
6971
derive_more::{Deref, From, Into},

src/pipelines/exec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<P: Platform, Provider: traits::ProviderBounds<P>>
6464
PipelineExecutor<P, Provider>
6565
{
6666
/// Begins the execution of a pipeline for a new block/payload job.
67-
pub fn run(
67+
pub(super) fn run(
6868
pipeline: Arc<Pipeline<P>>,
6969
block: BlockContext<P>,
7070
service: Arc<ServiceContext<P, Provider>>,
@@ -114,7 +114,7 @@ impl<P: Platform, Provider: traits::ProviderBounds<P>>
114114
}
115115

116116
/// Returns the payload id for which we are building a payload.
117-
pub fn payload_id(&self) -> PayloadId {
117+
pub(super) fn payload_id(&self) -> PayloadId {
118118
self.block.payload_id()
119119
}
120120
}

src/pipelines/exec/navi.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl StepPath {
3434
/// If the step path points at a nested pipeline, this method will create a
3535
/// navigator that points to the first executable step starting from the
3636
/// nested pipeline.
37-
pub fn navigator<'a, P: Platform>(
37+
pub(crate) fn navigator<'a, P: Platform>(
3838
&self,
3939
root: &'a Pipeline<P>,
4040
) -> Option<StepNavigator<'a, P>> {
@@ -67,25 +67,25 @@ impl StepPath {
6767
///
6868
/// When this path points to an item, this value is the number of pipelines
6969
/// that contain the item starting from the top-level pipeline.
70-
pub fn depth(&self) -> usize {
70+
pub(crate) fn depth(&self) -> usize {
7171
self.0.len()
7272
}
7373

7474
/// Returns `true` if the path points to a step in a top-level pipeline.
7575
/// This means that this path is inside a pipeline that has no parents.
7676
///
7777
/// In other words, it checks if the path is a single element path.
78-
pub fn is_toplevel(&self) -> bool {
78+
pub(crate) fn is_toplevel(&self) -> bool {
7979
self.depth() == 1
8080
}
8181

8282
/// Returns `true` the the path is pointing to a prologue of a pipeline.
83-
pub fn is_prologue(&self) -> bool {
83+
pub(crate) fn is_prologue(&self) -> bool {
8484
self.leaf() == PROLOGUE_INDEX
8585
}
8686

8787
/// Returns `true` if the path is pointing to an epilogue of a pipeline.
88-
pub fn is_epilogue(&self) -> bool {
88+
pub(crate) fn is_epilogue(&self) -> bool {
8989
self.leaf() == EPILOGUE_INDEX
9090
}
9191
}
@@ -324,7 +324,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> {
324324
/// deeper into the nested pipeline to find the first executable item.
325325
///
326326
/// In empty pipelines, this will return None.
327-
pub fn entrypoint(pipeline: &'a Pipeline<P>) -> Option<Self> {
327+
pub(crate) fn entrypoint(pipeline: &'a Pipeline<P>) -> Option<Self> {
328328
if pipeline.is_empty() {
329329
return None;
330330
}
@@ -351,7 +351,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> {
351351

352352
/// Returns a reference to the instance of the step that this path is
353353
/// currently pointing to.
354-
pub fn instance(&self) -> &Arc<StepInstance<P>> {
354+
pub(crate) fn instance(&self) -> &Arc<StepInstance<P>> {
355355
let step_index = self.0.leaf();
356356
let enclosing_pipeline = self.pipeline();
357357

@@ -380,15 +380,15 @@ impl<'a, P: Platform> StepNavigator<'a, P> {
380380

381381
/// Returns a reference to the immediate enclosing pipeline that contains the
382382
/// current step.
383-
pub fn pipeline(&self) -> &'a Pipeline<P> {
383+
pub(crate) fn pipeline(&self) -> &'a Pipeline<P> {
384384
self.1.last().expect(
385385
"StepNavigator should always have at least one enclosing pipeline",
386386
)
387387
}
388388

389389
/// Returns a reference to the top-level pipeline that contains the
390390
/// current step.
391-
pub fn root_pipeline(&self) -> &'a Pipeline<P> {
391+
pub(crate) fn root_pipeline(&self) -> &'a Pipeline<P> {
392392
self.1.first().expect(
393393
"StepNavigator should always have at least one enclosing pipeline",
394394
)
@@ -398,7 +398,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> {
398398
/// step's execution returns `ControlFlow::Ok`.
399399
///
400400
/// Returns `None` if there are no more steps to execute in the pipeline.
401-
pub fn next_ok(self) -> Option<Self> {
401+
pub(crate) fn next_ok(self) -> Option<Self> {
402402
if self.is_epilogue() {
403403
// the loop is over.
404404
return self.next_in_parent();
@@ -447,7 +447,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> {
447447
/// step's execution returns `ControlFlow::Break`.
448448
///
449449
/// Returns `None` if there are no more steps to execute in the pipeline.
450-
pub fn next_break(self) -> Option<Self> {
450+
pub(crate) fn next_break(self) -> Option<Self> {
451451
if self.is_epilogue() {
452452
// the loop is over.
453453
return self.next_in_parent();

src/pipelines/exec/scope.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,17 @@ use {
6363
/// Scopes manage:
6464
/// - The metrics name for each pipeline and its nested pipelines
6565
/// - Limits calculation and renewal for pipeline steps.
66-
pub struct RootScope<P: Platform> {
66+
pub(crate) struct RootScope<P: Platform> {
6767
root: RwLock<Scope<P>>,
6868
current: RefCell<StepPath>,
6969
}
7070

7171
impl<P: Platform> RootScope<P> {
7272
/// Initialize all scopes in a given top-level pipeline.
73-
pub fn new(pipeline: &Pipeline<P>, init_checkpoint: &Checkpoint<P>) -> Self {
73+
pub(crate) fn new(
74+
pipeline: &Pipeline<P>,
75+
init_checkpoint: &Checkpoint<P>,
76+
) -> Self {
7477
let current = RefCell::new(StepPath::empty());
7578
let root = Scope::rooted_at(pipeline, init_checkpoint);
7679
let root = RwLock::new(root);
@@ -79,7 +82,7 @@ impl<P: Platform> RootScope<P> {
7982
}
8083

8184
/// Given a path to a step in the pipeline, returns its current limits.
82-
pub fn limits_of(&self, step_path: &StepPath) -> Option<Limits> {
85+
pub(crate) fn limits_of(&self, step_path: &StepPath) -> Option<Limits> {
8386
self
8487
.root
8588
.read()
@@ -88,7 +91,7 @@ impl<P: Platform> RootScope<P> {
8891
}
8992

9093
/// Returns the instant when the scope was last entered.
91-
pub fn entered_at(&self, step_path: &StepPath) -> Option<Instant> {
94+
pub(crate) fn entered_at(&self, step_path: &StepPath) -> Option<Instant> {
9295
self
9396
.root
9497
.read()
@@ -100,7 +103,7 @@ impl<P: Platform> RootScope<P> {
100103
/// It detects if the next step is in a different scope and enters and leaves
101104
/// scopes accordingly. This will leave and enter all intermediate scopes
102105
/// between the previous and next steps.
103-
pub fn switch_context(
106+
pub(crate) fn switch_context(
104107
&self,
105108
next_step: &StepPath,
106109
checkpoint: &Checkpoint<P>,
@@ -132,18 +135,18 @@ impl<P: Platform> RootScope<P> {
132135
}
133136
}
134137

135-
pub fn enter(&self, checkpoint: &Checkpoint<P>) {
138+
pub(crate) fn enter(&self, checkpoint: &Checkpoint<P>) {
136139
let mut root = self.root.write();
137140
let limits = root.limits;
138141
root.enter(checkpoint, &limits);
139142
}
140143

141-
pub fn leave(&self) {
144+
pub(crate) fn leave(&self) {
142145
let mut root = self.root.write();
143146
root.leave();
144147
}
145148

146-
pub fn is_active(&self) -> bool {
149+
pub(crate) fn is_active(&self) -> bool {
147150
self.root.read().is_active()
148151
}
149152
}
@@ -165,7 +168,7 @@ fn scope_of(step: &StepPath) -> StepPath {
165168
/// execution. All steps in a pipeline run within the scopes of the pipelines
166169
/// that contain it. When a scope is active, then all its parent scopes are
167170
/// active as well.
168-
pub struct Scope<P: Platform> {
171+
pub(crate) struct Scope<P: Platform> {
169172
limits: Limits,
170173
metrics: Metrics,
171174
limits_factory: Option<Arc<dyn ScopedLimits<P>>>,
@@ -178,23 +181,23 @@ pub struct Scope<P: Platform> {
178181
impl<P: Platform> Scope<P> {
179182
/// When a scope is active it means that one of its steps (or in its nested
180183
/// scopes) is currently being executed,
181-
pub const fn is_active(&self) -> bool {
184+
pub(crate) const fn is_active(&self) -> bool {
182185
self.entered_at.is_some()
183186
}
184187

185188
/// Returns the elapsed time since the scope was entered.
186189
/// This will only return a value if the scope is currently active.
187-
pub fn elapsed(&self) -> Option<Duration> {
190+
pub(crate) fn elapsed(&self) -> Option<Duration> {
188191
self.entered_at.map(|start| start.elapsed())
189192
}
190193

191194
/// Returns when the scope was entered most recently.
192-
pub fn started_at(&self) -> Option<Instant> {
195+
pub(crate) fn started_at(&self) -> Option<Instant> {
193196
self.entered_at
194197
}
195198

196199
/// Returns the payload limits for steps running within the current scope.
197-
pub const fn limits(&self) -> &Limits {
200+
pub(crate) const fn limits(&self) -> &Limits {
198201
&self.limits
199202
}
200203
}
@@ -353,7 +356,7 @@ unsafe impl<P: Platform> Send for Scope<P> {}
353356
unsafe impl<P: Platform> Sync for Scope<P> {}
354357

355358
#[derive(MetricsSet)]
356-
pub struct Metrics {
359+
pub(crate) struct Metrics {
357360
/// Histogram of the number of iterations.
358361
pub iter_count_histogram: Histogram,
359362

src/pipelines/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct Frame<'a, P: Platform> {
1515
}
1616

1717
impl<'a, P: Platform> StepPathIter<'a, P> {
18-
pub fn new(pipeline: &'a Pipeline<P>) -> Self {
18+
pub(crate) fn new(pipeline: &'a Pipeline<P>) -> Self {
1919
Self {
2020
stack: vec![Frame {
2121
pipeline,

src/pipelines/job.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use {
3131
/// This is a long-running job that will be polled by the CL node until it is
3232
/// resolved. The job future must resolve within 1 second from the moment
3333
/// [`PayloadJob::resolve_kind`] is called with [`PaylodKind::Earliest`].
34-
pub struct PayloadJob<P, Provider>
34+
pub(super) struct PayloadJob<P, Provider>
3535
where
3636
P: Platform,
3737
Provider: traits::ProviderBounds<P>,
@@ -45,7 +45,7 @@ where
4545
P: Platform,
4646
Provider: traits::ProviderBounds<P>,
4747
{
48-
pub fn new(
48+
pub(super) fn new(
4949
pipeline: &Arc<Pipeline<P>>,
5050
block: BlockContext<P>,
5151
service: &Arc<ServiceContext<P, Provider>>,
@@ -143,7 +143,7 @@ where
143143
/// This future wraps the `PipelineExecutor` and is used to poll the
144144
/// internal executor of the pipeline. Once this future is resolved, it
145145
/// can be polled again and will return copie of the resolved payload.
146-
pub struct ExecutorFuture<P, Provider>
146+
pub(super) struct ExecutorFuture<P, Provider>
147147
where
148148
P: Platform,
149149
Provider: traits::ProviderBounds<P>,
@@ -175,7 +175,7 @@ where
175175
P: Platform,
176176
Provider: traits::ProviderBounds<P>,
177177
{
178-
pub fn new(executor: PipelineExecutor<P, Provider>) -> Self {
178+
pub(super) fn new(executor: PipelineExecutor<P, Provider>) -> Self {
179179
Self {
180180
started_at: Instant::now(),
181181
payload_id: executor.payload_id(),

src/pipelines/limits.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,38 +317,38 @@ mod tests {
317317

318318
impl TestStep {
319319
#[allow(dead_code)]
320-
pub fn break_after(self, iterations: u32) -> Self {
320+
fn break_after(self, iterations: u32) -> Self {
321321
self.break_after.store(iterations, Ordering::Relaxed);
322322
self
323323
}
324324

325-
pub fn expect_gas_limit(mut self, gas_limit: u64) -> Self {
325+
fn expect_gas_limit(mut self, gas_limit: u64) -> Self {
326326
self.expected_gas_limit = Some(gas_limit);
327327
self
328328
}
329329

330-
pub fn expect_deadline(mut self, deadline: Duration) -> Self {
330+
fn expect_deadline(mut self, deadline: Duration) -> Self {
331331
self.expected_deadline = Some(deadline);
332332
self
333333
}
334334

335-
pub fn expect_minimum_iterations(mut self, iterations: u32) -> Self {
335+
fn expect_minimum_iterations(mut self, iterations: u32) -> Self {
336336
self.minimum_iterations = Some(iterations);
337337
self
338338
}
339339

340-
pub fn expect_maximum_iterations(mut self, iterations: u32) -> Self {
340+
fn expect_maximum_iterations(mut self, iterations: u32) -> Self {
341341
self.maximum_iterations = Some(iterations);
342342
self
343343
}
344344

345-
pub fn sleep_on_step(mut self, duration: Duration) -> Self {
345+
fn sleep_on_step(mut self, duration: Duration) -> Self {
346346
self.sleep_on_step = Some(duration);
347347
self
348348
}
349349

350350
#[track_caller]
351-
pub fn must_run(mut self) -> Self {
351+
fn must_run(mut self) -> Self {
352352
self.must_run = true;
353353
self
354354
}

src/pipelines/macros/src/metrics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod set;
22

3-
pub use set::metrics_set_derive;
3+
pub(crate) use set::metrics_set_derive;
44

55
fn rblib_path() -> proc_macro2::TokenStream {
66
use {

0 commit comments

Comments
 (0)