Skip to content

Commit 1fa2d4a

Browse files
authored
Merge pull request #27 from flashbots/msozin/clippy-and-fmt-nightly
Use nightly for clippy and fmt
2 parents 907b06e + 28feb36 commit 1fa2d4a

File tree

8 files changed

+59
-57
lines changed

8 files changed

+59
-57
lines changed

.github/workflows/checks.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
toolchain:
23-
- stable
23+
- nightly
2424
features:
2525
- ""
2626
steps:
@@ -32,6 +32,7 @@ jobs:
3232
uses: dtolnay/rust-toolchain@stable
3333
with:
3434
toolchain: ${{ matrix.toolchain }}
35+
components: "rustfmt,clippy"
3536

3637
# https://github.com/swatinem/rust-cache
3738
- name: Run Swatinem/rust-cache@v2

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ build: ## Build (debug version)
2828
cargo build --features "$(FEATURES)"
2929

3030
.PHONY: docker-image-rbuilder
31-
docker-image-rubilder: ## Build a rbuilder Docker image
31+
docker-image-rbuilder: ## Build a rbuilder Docker image
3232
docker build --platform linux/amd64 --target rbuilder-runtime --build-arg FEATURES="$(FEATURES)" . -t rbuilder
3333

3434
##@ Dev
3535

3636
.PHONY: lint
3737
lint: ## Run the linters
38-
cargo fmt -- --check
39-
cargo clippy --features "$(FEATURES)" -- -D warnings
40-
cargo clippy -p op-rbuilder --features "$(FEATURES)" -- -D warnings
38+
cargo +nightly fmt -- --check
39+
cargo +nightly clippy --features "$(FEATURES)" -- -D warnings
40+
cargo +nightly clippy -p op-rbuilder --features "$(FEATURES)" -- -D warnings
4141

4242
.PHONY: test
4343
test: ## Run the tests for rbuilder and op-rbuilder
@@ -50,10 +50,10 @@ lt: lint test ## Run "lint" and "test"
5050

5151
.PHONY: fmt
5252
fmt: ## Format the code
53-
cargo fmt
54-
cargo fix --allow-staged
55-
cargo clippy --features "$(FEATURES)" --fix --allow-staged
56-
cargo clippy -p op-rbuilder --features "$(FEATURES)" --fix --allow-staged
53+
cargo +nightly fmt
54+
cargo +nightly fix --allow-staged
55+
cargo +nightly clippy --features "$(FEATURES)" --fix --allow-staged
56+
cargo +nightly clippy -p op-rbuilder --features "$(FEATURES)" --fix --allow-staged
5757

5858
.PHONY: bench
5959
bench: ## Run benchmarks

crates/op-rbuilder/src/generator.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
use futures_util::Future;
2-
use futures_util::FutureExt;
3-
use reth::providers::BlockReaderIdExt;
4-
use reth::{providers::StateProviderFactory, tasks::TaskSpawner};
5-
use reth_basic_payload_builder::HeaderForPayload;
6-
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, PayloadConfig};
7-
use reth_node_api::PayloadBuilderAttributes;
8-
use reth_node_api::PayloadKind;
9-
use reth_payload_builder::PayloadJobGenerator;
10-
use reth_payload_builder::{KeepPayloadJobAlive, PayloadBuilderError, PayloadJob};
1+
use futures_util::{Future, FutureExt};
2+
use reth::{
3+
providers::{BlockReaderIdExt, StateProviderFactory},
4+
tasks::TaskSpawner,
5+
};
6+
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, HeaderForPayload, PayloadConfig};
7+
use reth_node_api::{PayloadBuilderAttributes, PayloadKind};
8+
use reth_payload_builder::{
9+
KeepPayloadJobAlive, PayloadBuilderError, PayloadJob, PayloadJobGenerator,
10+
};
1111
use reth_payload_primitives::BuiltPayload;
1212
use reth_primitives_traits::HeaderTy;
1313
use reth_revm::cached::CachedReads;
14-
use std::sync::{Arc, Mutex};
15-
use std::time::SystemTime;
16-
use std::time::UNIX_EPOCH;
17-
use tokio::sync::oneshot;
18-
use tokio::sync::Notify;
19-
use tokio::time::Duration;
20-
use tokio::time::Sleep;
14+
use std::{
15+
sync::{Arc, Mutex},
16+
time::{SystemTime, UNIX_EPOCH},
17+
};
18+
use tokio::{
19+
sync::{oneshot, Notify},
20+
time::{Duration, Sleep},
21+
};
2122
use tokio_util::sync::CancellationToken;
2223
use tracing::info;
2324

@@ -428,14 +429,15 @@ mod tests {
428429
use reth::tasks::TokioTaskExecutor;
429430
use reth_chain_state::ExecutedBlockWithTrieUpdates;
430431
use reth_node_api::NodePrimitives;
431-
use reth_optimism_payload_builder::payload::OpPayloadBuilderAttributes;
432-
use reth_optimism_payload_builder::OpPayloadPrimitives;
432+
use reth_optimism_payload_builder::{payload::OpPayloadBuilderAttributes, OpPayloadPrimitives};
433433
use reth_optimism_primitives::OpPrimitives;
434434
use reth_primitives::SealedBlock;
435435
use reth_provider::test_utils::MockEthProvider;
436436
use reth_testing_utils::generators::{random_block_range, BlockRangeParams};
437-
use tokio::task;
438-
use tokio::time::{sleep, Duration};
437+
use tokio::{
438+
task,
439+
time::{sleep, Duration},
440+
};
439441

440442
#[tokio::test]
441443
async fn test_block_cell_wait_for_value() {

crates/op-rbuilder/src/integration/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
use alloy_consensus::TxEip1559;
2-
use alloy_eips::BlockNumberOrTag;
3-
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718};
2+
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, BlockNumberOrTag};
43
use alloy_provider::{Identity, Provider, ProviderBuilder};
54
use op_alloy_consensus::OpTypedTransaction;
65
use op_alloy_network::Optimism;
76
use op_rbuilder::OpRbuilderConfig;
87
use op_reth::OpRethConfig;
98
use parking_lot::Mutex;
10-
use std::cmp::max;
11-
use std::collections::HashSet;
12-
use std::future::Future;
13-
use std::net::TcpListener;
14-
use std::path::Path;
15-
use std::sync::LazyLock;
169
use std::{
10+
cmp::max,
11+
collections::HashSet,
1712
fs::{File, OpenOptions},
13+
future::Future,
1814
io,
1915
io::prelude::*,
20-
path::PathBuf,
16+
net::TcpListener,
17+
path::{Path, PathBuf},
2118
process::{Child, Command},
19+
sync::LazyLock,
2220
time::{Duration, SystemTime},
2321
};
2422
use time::{format_description, OffsetDateTime};
2523
use tokio::time::sleep;
2624
use uuid::Uuid;
2725

28-
use crate::tester::{BlockGenerator, EngineApi};
29-
use crate::tx_signer::Signer;
26+
use crate::{
27+
tester::{BlockGenerator, EngineApi},
28+
tx_signer::Signer,
29+
};
3030

3131
/// Default JWT token for testing purposes
3232
pub const DEFAULT_JWT_TOKEN: &str =
@@ -92,7 +92,7 @@ pub async fn poll_logs(
9292

9393
impl ServiceInstance {
9494
pub fn new(name: String, test_dir: PathBuf) -> Self {
95-
let log_path = test_dir.join(format!("{}.log", name));
95+
let log_path = test_dir.join(format!("{name}.log"));
9696
Self {
9797
process: None,
9898
log_path,
@@ -167,7 +167,7 @@ impl IntegrationFramework {
167167

168168
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
169169
test_dir.push("../../integration_logs");
170-
test_dir.push(format!("{}_{}", date_format, test_name));
170+
test_dir.push(format!("{date_format}_{test_name}"));
171171

172172
std::fs::create_dir_all(&test_dir).map_err(|_| IntegrationError::SetupError)?;
173173

crates/op-rbuilder/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clap::Parser;
22
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
3-
use reth_optimism_node::node::OpAddOnsBuilder;
4-
use reth_optimism_node::OpNode;
3+
use reth_optimism_node::{node::OpAddOnsBuilder, OpNode};
54

65
#[cfg(feature = "flashblocks")]
76
use payload_builder::CustomOpPayloadBuilder;

crates/op-rbuilder/src/metrics.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use reth_metrics::{metrics::Counter, metrics::Histogram, Metrics};
1+
use reth_metrics::{
2+
metrics::{Counter, Histogram},
3+
Metrics,
4+
};
25

36
/// op-rbuilder metrics
47
#[derive(Metrics, Clone)]

crates/op-rbuilder/src/tester/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async fn main() -> eyre::Result<()> {
6767
generator.init().await?;
6868

6969
let block_hash = generator.deposit(address, amount).await?;
70-
println!("Deposit transaction included in block: {}", block_hash);
70+
println!("Deposit transaction included in block: {block_hash}");
7171
Ok(())
7272
}
7373
}

crates/op-rbuilder/src/tester/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl EngineApi {
8282

8383
pub fn new_with_port(port: u16) -> Result<Self, Box<dyn std::error::Error>> {
8484
Self::builder()
85-
.with_url(&format!("http://localhost:{}", port))
85+
.with_url(&format!("http://localhost:{port}"))
8686
.build()
8787
}
8888

@@ -179,13 +179,13 @@ pub async fn generate_genesis(output: Option<String>) -> eyre::Result<()> {
179179
let timestamp = chrono::Utc::now().timestamp();
180180
if let Some(config) = genesis.as_object_mut() {
181181
// Assuming timestamp is at the root level - adjust path as needed
182-
config["timestamp"] = Value::String(format!("0x{:x}", timestamp));
182+
config["timestamp"] = Value::String(format!("0x{timestamp:x}"));
183183
}
184184

185185
// Write the result to the output file
186186
if let Some(output) = output {
187187
std::fs::write(&output, serde_json::to_string_pretty(&genesis)?)?;
188-
println!("Generated genesis file at: {}", output);
188+
println!("Generated genesis file at: {output}");
189189
} else {
190190
println!("{}", serde_json::to_string_pretty(&genesis)?);
191191
}
@@ -241,10 +241,7 @@ impl BlockGenerator {
241241

242242
// Initialize flashblocks service
243243
if let Some(flashblocks_endpoint) = &self.flashblocks_endpoint {
244-
println!(
245-
"Initializing flashblocks service at {}",
246-
flashblocks_endpoint
247-
);
244+
println!("Initializing flashblocks service at {flashblocks_endpoint}");
248245

249246
self.flashblocks_service = Some(Flashblocks::run(
250247
flashblocks_endpoint.to_string(),
@@ -273,7 +270,7 @@ impl BlockGenerator {
273270
let mut latest_hash = latest_validation_block.header.hash;
274271

275272
for i in (latest_validation_block.header.number + 1)..=latest_block.header.number {
276-
println!("syncing block {}", i);
273+
println!("syncing block {i}");
277274

278275
let block = self
279276
.engine_api
@@ -512,7 +509,7 @@ pub async fn run_system(
512509
block_time_secs: u64,
513510
flashblocks_endpoint: Option<String>,
514511
) -> eyre::Result<()> {
515-
println!("Validation: {}", validation);
512+
println!("Validation: {validation}");
516513

517514
let engine_api = EngineApi::new("http://localhost:4444").unwrap();
518515
let validation_api = if validation {
@@ -535,6 +532,6 @@ pub async fn run_system(
535532
loop {
536533
println!("Generating new block...");
537534
let block_hash = generator.generate_block().await?;
538-
println!("Generated block: {}", block_hash);
535+
println!("Generated block: {block_hash}");
539536
}
540537
}

0 commit comments

Comments
 (0)