mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add and fix more lints, improve docs (#4765)
This commit is contained in:
@ -1,16 +1,3 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
|
||||
//! A [Consensus] implementation for local testing purposes
|
||||
//! that automatically seals blocks.
|
||||
//!
|
||||
@ -20,6 +7,15 @@
|
||||
//! These downloaders poll the miner, assemble the block, and return transactions that are ready to
|
||||
//! be mined.
|
||||
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use reth_beacon_consensus::BeaconEngineMessage;
|
||||
use reth_interfaces::{
|
||||
consensus::{Consensus, ConsensusError},
|
||||
@ -98,6 +94,7 @@ impl Consensus for AutoSealConsensus {
|
||||
}
|
||||
|
||||
/// Builder type for configuring the setup
|
||||
#[derive(Debug)]
|
||||
pub struct AutoSealBuilder<Client, Pool> {
|
||||
client: Client,
|
||||
consensus: AutoSealConsensus,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use reth_interfaces::RethError;
|
||||
use reth_primitives::BlockNumber;
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
fmt,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
@ -9,7 +10,6 @@ pub(crate) use controller::{EngineHooksController, PolledHook};
|
||||
|
||||
mod prune;
|
||||
pub use prune::PruneHook;
|
||||
use reth_interfaces::RethError;
|
||||
|
||||
/// Collection of [engine hooks][`EngineHook`].
|
||||
#[derive(Default)]
|
||||
@ -17,6 +17,12 @@ pub struct EngineHooks {
|
||||
inner: Vec<Box<dyn EngineHook>>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for EngineHooks {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("EngineHooks").field("inner", &self.inner.len()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl EngineHooks {
|
||||
/// Creates a new empty collection of [engine hooks][`EngineHook`].
|
||||
pub fn new() -> Self {
|
||||
|
||||
@ -13,7 +13,10 @@ use reth_interfaces::RethError;
|
||||
use reth_primitives::BlockNumber;
|
||||
use reth_prune::{Pruner, PrunerError, PrunerWithResult};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use std::task::{ready, Context, Poll};
|
||||
use std::{
|
||||
fmt,
|
||||
task::{ready, Context, Poll},
|
||||
};
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
/// Manages pruning under the control of the engine.
|
||||
@ -27,6 +30,15 @@ pub struct PruneHook<DB> {
|
||||
metrics: Metrics,
|
||||
}
|
||||
|
||||
impl<DB: fmt::Debug> fmt::Debug for PruneHook<DB> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("PruneHook")
|
||||
.field("pruner_state", &self.pruner_state)
|
||||
.field("metrics", &self.metrics)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB: Database + 'static> PruneHook<DB> {
|
||||
/// Create a new instance
|
||||
pub fn new(pruner: Pruner<DB>, pruner_task_spawner: Box<dyn TaskSpawner>) -> Self {
|
||||
@ -150,6 +162,7 @@ impl<DB: Database + 'static> EngineHook for PruneHook<DB> {
|
||||
/// running, it acquires the write lock over the database. This means that we cannot forward to the
|
||||
/// blockchain tree any messages that would result in database writes, since it would result in a
|
||||
/// deadlock.
|
||||
#[derive(Debug)]
|
||||
enum PrunerState<DB> {
|
||||
/// Pruner is idle.
|
||||
Idle(Option<Pruner<DB>>),
|
||||
|
||||
@ -160,6 +160,7 @@ pub const MIN_BLOCKS_FOR_PIPELINE_RUN: u64 = EPOCH_SLOTS;
|
||||
///
|
||||
/// If the future is polled more than once. Leads to undefined state.
|
||||
#[must_use = "Future does nothing unless polled"]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct BeaconConsensusEngine<DB, BT, Client>
|
||||
where
|
||||
DB: Database,
|
||||
|
||||
@ -50,6 +50,7 @@ type TestBeaconConsensusEngine<Client> = BeaconConsensusEngine<
|
||||
Arc<EitherDownloader<Client, NoopFullBlockClient>>,
|
||||
>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TestEnv<DB> {
|
||||
pub db: DB,
|
||||
// Keep the tip receiver around, so it's not dropped.
|
||||
@ -116,7 +117,7 @@ impl<DB> TestEnv<DB> {
|
||||
// TODO: add with_consensus in case we want to use the TestConsensus purposeful failure - this
|
||||
// would require similar patterns to how we use with_client and the EitherDownloader
|
||||
/// Represents either a real consensus engine, or a test consensus engine.
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
enum TestConsensusConfig {
|
||||
/// Test consensus engine
|
||||
#[default]
|
||||
@ -126,6 +127,7 @@ enum TestConsensusConfig {
|
||||
}
|
||||
|
||||
/// Represents either test pipeline outputs, or real pipeline configuration.
|
||||
#[derive(Debug)]
|
||||
enum TestPipelineConfig {
|
||||
/// Test pipeline outputs.
|
||||
Test(VecDeque<Result<ExecOutput, StageError>>),
|
||||
@ -140,6 +142,7 @@ impl Default for TestPipelineConfig {
|
||||
}
|
||||
|
||||
/// Represents either test executor results, or real executor configuration.
|
||||
#[derive(Debug)]
|
||||
enum TestExecutorConfig {
|
||||
/// Test executor results.
|
||||
Test(Vec<BundleStateWithReceipts>),
|
||||
@ -271,6 +274,7 @@ where
|
||||
|
||||
/// The basic configuration for a `TestConsensusEngine`, without generics for the client or
|
||||
/// consensus engine.
|
||||
#[derive(Debug)]
|
||||
pub struct TestConsensusEngineBuilder {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
pipeline_config: TestPipelineConfig,
|
||||
@ -362,6 +366,7 @@ impl TestConsensusEngineBuilder {
|
||||
/// mocked executor results.
|
||||
///
|
||||
/// This optionally includes a client for network operations.
|
||||
#[derive(Debug)]
|
||||
pub struct NetworkedTestConsensusEngineBuilder<Client> {
|
||||
base_config: TestConsensusEngineBuilder,
|
||||
client: Option<Client>,
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
//! Beacon consensus implementation.
|
||||
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)]
|
||||
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
//! Beacon consensus implementation.
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
mod beacon_consensus;
|
||||
pub use beacon_consensus::BeaconConsensus;
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
//! Commonly used consensus methods.
|
||||
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)]
|
||||
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
|
||||
//! Commonly used consensus methods.
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
/// Collection of consensus validation methods.
|
||||
pub mod validation;
|
||||
|
||||
Reference in New Issue
Block a user