Skip to content

Commit ade7797

Browse files
emhaneonbjerg
andauthored
Add commands from CONTRIBUTING.md to Makefile and update ci (paradigmxyz#6141)
Co-authored-by: Oliver Nordbjerg <[email protected]>
1 parent ea36b58 commit ade7797

File tree

7 files changed

+77
-26
lines changed

7 files changed

+77
-26
lines changed

.github/workflows/lint.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
clippy:
13+
clippy-binaries:
1414
name: clippy / ${{ matrix.network }}
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 30
@@ -28,7 +28,22 @@ jobs:
2828
with:
2929
cache-on-failure: true
3030
- run:
31-
cargo clippy --bin "${{ matrix.binary }}" --workspace --features "${{ matrix.network }}" --lib --tests --benches --examples
31+
cargo clippy --bin "${{ matrix.binary }}" --workspace --features "${{ matrix.network }} asm-keccak jemalloc jemalloc-prof min-error-logs min-warn-logs min-info-logs min-debug-logs min-trace-logs"
32+
env:
33+
RUSTFLAGS: -D warnings
34+
35+
clippy:
36+
name: clippy
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 30
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: dtolnay/rust-toolchain@clippy
42+
- uses: Swatinem/rust-cache@v2
43+
with:
44+
cache-on-failure: true
45+
- run:
46+
cargo clippy --workspace --lib --examples --tests --benches --all-features
3247
env:
3348
RUSTFLAGS: -D warnings
3449

@@ -98,7 +113,7 @@ jobs:
98113
name: lint success
99114
runs-on: ubuntu-latest
100115
if: always()
101-
needs: [clippy, docs, fmt, grafana]
116+
needs: [clippy-binaries, clippy, docs, fmt, grafana]
102117
timeout-minutes: 30
103118
steps:
104119
- name: Decide whether the needed jobs succeeded or failed

CONTRIBUTING.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ likelihood of the PR getting merged.
9898
Please also make sure that the following commands pass if you have changed the code:
9999

100100
```sh
101-
cargo check --all
102-
cargo test --all --all-features
103-
cargo +nightly fmt -- --check
104-
cargo clippy --bin "reth" --workspace --features "ethereum" --lib --tests --benches --examples -- -D warnings
105-
cargo clippy --bin "op-reth" --workspace --features "optimism" --lib --tests --benches --examples -- -D warnings
101+
make pr
106102
```
107103

108104
If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension,
@@ -111,14 +107,6 @@ and use the following VSCode user settings:
111107
```json
112108
"editor.formatOnSave": true,
113109
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
114-
"rust-analyzer.check.overrideCommand": [
115-
"cargo",
116-
"+nightly",
117-
"clippy",
118-
"--all",
119-
"--all-features",
120-
"--message-format=json"
121-
],
122110
"[rust]": {
123111
"editor.defaultFormatter": "rust-lang.rust-analyzer"
124112
}

Makefile

+44
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ EF_TESTS_DIR := ./testing/ef-tests/ethereum-tests
3232
# The docker image name
3333
DOCKER_IMAGE_NAME ?= ghcr.io/paradigmxyz/reth
3434

35+
# Features in reth/op-reth binary crate other than "ethereum" and "optimism"
36+
BIN_OTHER_FEATURES := asm-keccak jemalloc jemalloc-prof min-error-logs min-warn-logs min-info-logs min-debug-logs min-trace-logs
37+
3538
##@ Help
3639

3740
.PHONY: help
@@ -239,3 +242,44 @@ maxperf: ## Builds `reth` with the most aggressive optimisations.
239242
.PHONY: maxperf-no-asm
240243
maxperf-no-asm: ## Builds `reth` with the most aggressive optimisations, minus the "asm-keccak" feature.
241244
RUSTFLAGS="-C target-cpu=native" cargo build --profile maxperf --features jemalloc
245+
246+
247+
fmt:
248+
cargo +nightly fmt
249+
250+
lint-reth:
251+
cargo +nightly clippy --workspace --bin "reth" --lib --examples --tests --benches --features "ethereum $(BIN_OTHER_FEATURES)" -- -D warnings
252+
253+
lint-op-reth:
254+
cargo +nightly clippy --workspace --bin "op-reth" --lib --examples --tests --benches --features "optimism $(BIN_OTHER_FEATURES)" -- -D warnings
255+
256+
lint-other-targets:
257+
cargo +nightly clippy --workspace --lib --examples --tests --benches --all-features -- -D warnings
258+
259+
lint:
260+
make lint-reth && \
261+
make lint-op-reth && \
262+
make lint-other-targets
263+
264+
docs:
265+
RUSTDOCFLAGS="--cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options -D warnings" cargo +nightly docs --document-private-items
266+
267+
test-reth:
268+
cargo test --workspace --bin "reth" --lib --examples --tests --benches --features "ethereum $(BIN_OTHER_FEATURES)"
269+
270+
test-op-reth:
271+
cargo test --workspace --bin "op-reth" --lib --examples --tests --benches --features "optimism $(BIN_OTHER_FEATURES)"
272+
273+
test-other-targets:
274+
cargo test --workspace --lib --examples --tests --benches --all-features
275+
276+
test:
277+
make test-reth && \
278+
make test-op-reth && \
279+
make test-other-targets
280+
281+
pr:
282+
make fmt && \
283+
make lint && \
284+
make docs && \
285+
make test

crates/net/eth-wire/tests/fuzz_roundtrip.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ where
3737
macro_rules! fuzz_type_and_name {
3838
( $x:ty, $fuzzname:ident ) => {
3939
/// Fuzzes the round-trip encoding of the type.
40+
#[allow(non_snake_case)]
4041
#[test_fuzz]
4142
fn $fuzzname(thing: $x) {
4243
crate::roundtrip_fuzz::<$x>(thing)
@@ -130,7 +131,7 @@ pub mod fuzz_rlp {
130131
RlpEncodableWrapper,
131132
RlpDecodableWrapper,
132133
)]
133-
struct GetBlockHeadersWrapper(pub GetBlockHeaders);
134+
struct GetBlockHeadersWrapper(GetBlockHeaders);
134135

135136
impl Default for GetBlockHeadersWrapper {
136137
fn default() -> Self {

crates/transaction-pool/benches/priority.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(missing_docs)]
12
use criterion::{
23
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
34
};
@@ -21,7 +22,7 @@ fn generate_test_data_priority() -> (u128, u128, u128, u128) {
2122
}
2223

2324
fn priority_bench(
24-
group: &mut BenchmarkGroup<WallTime>,
25+
group: &mut BenchmarkGroup<'_, WallTime>,
2526
description: &str,
2627
input_data: (u128, u128, u128, u128),
2728
) {
@@ -40,7 +41,7 @@ fn priority_bench(
4041
}
4142

4243
fn fee_jump_bench(
43-
group: &mut BenchmarkGroup<WallTime>,
44+
group: &mut BenchmarkGroup<'_, WallTime>,
4445
description: &str,
4546
input_data: (u128, u128),
4647
) {
@@ -53,7 +54,7 @@ fn fee_jump_bench(
5354
});
5455
}
5556

56-
pub fn blob_priority_calculation(c: &mut Criterion) {
57+
fn blob_priority_calculation(c: &mut Criterion) {
5758
let mut group = c.benchmark_group("Blob priority calculation");
5859
let fee_jump_input = generate_test_data_fee_delta();
5960

crates/transaction-pool/benches/reorder.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(missing_docs)]
12
use criterion::{
23
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
34
};
@@ -9,12 +10,12 @@ use proptest::{
910
use reth_transaction_pool::test_utils::MockTransaction;
1011

1112
/// Transaction Pool trait for benching.
12-
pub trait BenchTxPool: Default {
13+
trait BenchTxPool: Default {
1314
fn add_transaction(&mut self, tx: MockTransaction);
1415
fn reorder(&mut self, base_fee: u64);
1516
}
1617

17-
pub fn txpool_reordering(c: &mut Criterion) {
18+
fn txpool_reordering(c: &mut Criterion) {
1819
let mut group = c.benchmark_group("Transaction Pool Reordering");
1920

2021
for seed_size in [1_000, 10_000, 50_000, 100_000] {
@@ -54,7 +55,7 @@ pub fn txpool_reordering(c: &mut Criterion) {
5455
}
5556

5657
fn txpool_reordering_bench<T: BenchTxPool>(
57-
group: &mut BenchmarkGroup<WallTime>,
58+
group: &mut BenchmarkGroup<'_, WallTime>,
5859
description: &str,
5960
seed: Vec<MockTransaction>,
6061
new_txs: Vec<MockTransaction>,
@@ -170,7 +171,7 @@ mod implementations {
170171

171172
impl PartialEq for MockTransactionWithPriority {
172173
fn eq(&self, other: &Self) -> bool {
173-
self.priority.eq(&other.priority)
174+
self.priority == other.priority
174175
}
175176
}
176177

crates/transaction-pool/benches/truncate.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(missing_docs)]
12
use criterion::{
23
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
34
};
@@ -124,7 +125,7 @@ fn txpool_truncate(c: &mut Criterion) {
124125
}
125126

126127
fn truncate_pending(
127-
group: &mut BenchmarkGroup<WallTime>,
128+
group: &mut BenchmarkGroup<'_, WallTime>,
128129
description: &str,
129130
seed: Vec<MockTransaction>,
130131
senders: usize,
@@ -159,7 +160,7 @@ fn truncate_pending(
159160
}
160161

161162
fn truncate_parked(
162-
group: &mut BenchmarkGroup<WallTime>,
163+
group: &mut BenchmarkGroup<'_, WallTime>,
163164
description: &str,
164165
seed: Vec<MockTransaction>,
165166
senders: usize,

0 commit comments

Comments
 (0)