Skip to content

Commit

Permalink
Add commands from CONTRIBUTING.md to Makefile and update ci (paradigm…
Browse files Browse the repository at this point in the history
…xyz#6141)

Co-authored-by: Oliver Nordbjerg <[email protected]>
  • Loading branch information
emhane and onbjerg authored Jan 22, 2024
1 parent ea36b58 commit ade7797
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 26 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
clippy:
clippy-binaries:
name: clippy / ${{ matrix.network }}
runs-on: ubuntu-latest
timeout-minutes: 30
Expand All @@ -28,7 +28,22 @@ jobs:
with:
cache-on-failure: true
- run:
cargo clippy --bin "${{ matrix.binary }}" --workspace --features "${{ matrix.network }}" --lib --tests --benches --examples
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"
env:
RUSTFLAGS: -D warnings

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run:
cargo clippy --workspace --lib --examples --tests --benches --all-features
env:
RUSTFLAGS: -D warnings

Expand Down Expand Up @@ -98,7 +113,7 @@ jobs:
name: lint success
runs-on: ubuntu-latest
if: always()
needs: [clippy, docs, fmt, grafana]
needs: [clippy-binaries, clippy, docs, fmt, grafana]
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
14 changes: 1 addition & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ likelihood of the PR getting merged.
Please also make sure that the following commands pass if you have changed the code:

```sh
cargo check --all
cargo test --all --all-features
cargo +nightly fmt -- --check
cargo clippy --bin "reth" --workspace --features "ethereum" --lib --tests --benches --examples -- -D warnings
cargo clippy --bin "op-reth" --workspace --features "optimism" --lib --tests --benches --examples -- -D warnings
make pr
```

If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension,
Expand All @@ -111,14 +107,6 @@ and use the following VSCode user settings:
```json
"editor.formatOnSave": true,
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
"rust-analyzer.check.overrideCommand": [
"cargo",
"+nightly",
"clippy",
"--all",
"--all-features",
"--message-format=json"
],
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
Expand Down
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ EF_TESTS_DIR := ./testing/ef-tests/ethereum-tests
# The docker image name
DOCKER_IMAGE_NAME ?= ghcr.io/paradigmxyz/reth

# Features in reth/op-reth binary crate other than "ethereum" and "optimism"
BIN_OTHER_FEATURES := asm-keccak jemalloc jemalloc-prof min-error-logs min-warn-logs min-info-logs min-debug-logs min-trace-logs

##@ Help

.PHONY: help
Expand Down Expand Up @@ -239,3 +242,44 @@ maxperf: ## Builds `reth` with the most aggressive optimisations.
.PHONY: maxperf-no-asm
maxperf-no-asm: ## Builds `reth` with the most aggressive optimisations, minus the "asm-keccak" feature.
RUSTFLAGS="-C target-cpu=native" cargo build --profile maxperf --features jemalloc


fmt:
cargo +nightly fmt

lint-reth:
cargo +nightly clippy --workspace --bin "reth" --lib --examples --tests --benches --features "ethereum $(BIN_OTHER_FEATURES)" -- -D warnings

lint-op-reth:
cargo +nightly clippy --workspace --bin "op-reth" --lib --examples --tests --benches --features "optimism $(BIN_OTHER_FEATURES)" -- -D warnings

lint-other-targets:
cargo +nightly clippy --workspace --lib --examples --tests --benches --all-features -- -D warnings

lint:
make lint-reth && \
make lint-op-reth && \
make lint-other-targets

docs:
RUSTDOCFLAGS="--cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options -D warnings" cargo +nightly docs --document-private-items

test-reth:
cargo test --workspace --bin "reth" --lib --examples --tests --benches --features "ethereum $(BIN_OTHER_FEATURES)"

test-op-reth:
cargo test --workspace --bin "op-reth" --lib --examples --tests --benches --features "optimism $(BIN_OTHER_FEATURES)"

test-other-targets:
cargo test --workspace --lib --examples --tests --benches --all-features

test:
make test-reth && \
make test-op-reth && \
make test-other-targets

pr:
make fmt && \
make lint && \
make docs && \
make test
3 changes: 2 additions & 1 deletion crates/net/eth-wire/tests/fuzz_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ where
macro_rules! fuzz_type_and_name {
( $x:ty, $fuzzname:ident ) => {
/// Fuzzes the round-trip encoding of the type.
#[allow(non_snake_case)]
#[test_fuzz]
fn $fuzzname(thing: $x) {
crate::roundtrip_fuzz::<$x>(thing)
Expand Down Expand Up @@ -130,7 +131,7 @@ pub mod fuzz_rlp {
RlpEncodableWrapper,
RlpDecodableWrapper,
)]
struct GetBlockHeadersWrapper(pub GetBlockHeaders);
struct GetBlockHeadersWrapper(GetBlockHeaders);

impl Default for GetBlockHeadersWrapper {
fn default() -> Self {
Expand Down
7 changes: 4 additions & 3 deletions crates/transaction-pool/benches/priority.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
use criterion::{
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
Expand All @@ -21,7 +22,7 @@ fn generate_test_data_priority() -> (u128, u128, u128, u128) {
}

fn priority_bench(
group: &mut BenchmarkGroup<WallTime>,
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
input_data: (u128, u128, u128, u128),
) {
Expand All @@ -40,7 +41,7 @@ fn priority_bench(
}

fn fee_jump_bench(
group: &mut BenchmarkGroup<WallTime>,
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
input_data: (u128, u128),
) {
Expand All @@ -53,7 +54,7 @@ fn fee_jump_bench(
});
}

pub fn blob_priority_calculation(c: &mut Criterion) {
fn blob_priority_calculation(c: &mut Criterion) {
let mut group = c.benchmark_group("Blob priority calculation");
let fee_jump_input = generate_test_data_fee_delta();

Expand Down
9 changes: 5 additions & 4 deletions crates/transaction-pool/benches/reorder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
Expand All @@ -9,12 +10,12 @@ use proptest::{
use reth_transaction_pool::test_utils::MockTransaction;

/// Transaction Pool trait for benching.
pub trait BenchTxPool: Default {
trait BenchTxPool: Default {
fn add_transaction(&mut self, tx: MockTransaction);
fn reorder(&mut self, base_fee: u64);
}

pub fn txpool_reordering(c: &mut Criterion) {
fn txpool_reordering(c: &mut Criterion) {
let mut group = c.benchmark_group("Transaction Pool Reordering");

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

fn txpool_reordering_bench<T: BenchTxPool>(
group: &mut BenchmarkGroup<WallTime>,
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
seed: Vec<MockTransaction>,
new_txs: Vec<MockTransaction>,
Expand Down Expand Up @@ -170,7 +171,7 @@ mod implementations {

impl PartialEq for MockTransactionWithPriority {
fn eq(&self, other: &Self) -> bool {
self.priority.eq(&other.priority)
self.priority == other.priority
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/transaction-pool/benches/truncate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
Expand Down Expand Up @@ -124,7 +125,7 @@ fn txpool_truncate(c: &mut Criterion) {
}

fn truncate_pending(
group: &mut BenchmarkGroup<WallTime>,
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
seed: Vec<MockTransaction>,
senders: usize,
Expand Down Expand Up @@ -159,7 +160,7 @@ fn truncate_pending(
}

fn truncate_parked(
group: &mut BenchmarkGroup<WallTime>,
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
seed: Vec<MockTransaction>,
senders: usize,
Expand Down

0 comments on commit ade7797

Please sign in to comment.