mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
Add commands from CONTRIBUTING.md to Makefile and update ci (#6141)
Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
This commit is contained in:
21
.github/workflows/lint.yml
vendored
21
.github/workflows/lint.yml
vendored
@ -10,7 +10,7 @@ env:
|
|||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
clippy:
|
clippy-binaries:
|
||||||
name: clippy / ${{ matrix.network }}
|
name: clippy / ${{ matrix.network }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
@ -28,7 +28,22 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
cache-on-failure: true
|
cache-on-failure: true
|
||||||
- run:
|
- 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:
|
env:
|
||||||
RUSTFLAGS: -D warnings
|
RUSTFLAGS: -D warnings
|
||||||
|
|
||||||
@ -98,7 +113,7 @@ jobs:
|
|||||||
name: lint success
|
name: lint success
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: always()
|
if: always()
|
||||||
needs: [clippy, docs, fmt, grafana]
|
needs: [clippy-binaries, clippy, docs, fmt, grafana]
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- name: Decide whether the needed jobs succeeded or failed
|
- name: Decide whether the needed jobs succeeded or failed
|
||||||
|
|||||||
@ -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:
|
Please also make sure that the following commands pass if you have changed the code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo check --all
|
make pr
|
||||||
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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension,
|
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:
|
|||||||
```json
|
```json
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
|
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
|
||||||
"rust-analyzer.check.overrideCommand": [
|
|
||||||
"cargo",
|
|
||||||
"+nightly",
|
|
||||||
"clippy",
|
|
||||||
"--all",
|
|
||||||
"--all-features",
|
|
||||||
"--message-format=json"
|
|
||||||
],
|
|
||||||
"[rust]": {
|
"[rust]": {
|
||||||
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
||||||
}
|
}
|
||||||
|
|||||||
44
Makefile
44
Makefile
@ -32,6 +32,9 @@ EF_TESTS_DIR := ./testing/ef-tests/ethereum-tests
|
|||||||
# The docker image name
|
# The docker image name
|
||||||
DOCKER_IMAGE_NAME ?= ghcr.io/paradigmxyz/reth
|
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
|
##@ Help
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
@ -239,3 +242,44 @@ maxperf: ## Builds `reth` with the most aggressive optimisations.
|
|||||||
.PHONY: maxperf-no-asm
|
.PHONY: maxperf-no-asm
|
||||||
maxperf-no-asm: ## Builds `reth` with the most aggressive optimisations, minus the "asm-keccak" feature.
|
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
|
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
|
||||||
|
|||||||
@ -37,6 +37,7 @@ where
|
|||||||
macro_rules! fuzz_type_and_name {
|
macro_rules! fuzz_type_and_name {
|
||||||
( $x:ty, $fuzzname:ident ) => {
|
( $x:ty, $fuzzname:ident ) => {
|
||||||
/// Fuzzes the round-trip encoding of the type.
|
/// Fuzzes the round-trip encoding of the type.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
#[test_fuzz]
|
#[test_fuzz]
|
||||||
fn $fuzzname(thing: $x) {
|
fn $fuzzname(thing: $x) {
|
||||||
crate::roundtrip_fuzz::<$x>(thing)
|
crate::roundtrip_fuzz::<$x>(thing)
|
||||||
@ -130,7 +131,7 @@ pub mod fuzz_rlp {
|
|||||||
RlpEncodableWrapper,
|
RlpEncodableWrapper,
|
||||||
RlpDecodableWrapper,
|
RlpDecodableWrapper,
|
||||||
)]
|
)]
|
||||||
struct GetBlockHeadersWrapper(pub GetBlockHeaders);
|
struct GetBlockHeadersWrapper(GetBlockHeaders);
|
||||||
|
|
||||||
impl Default for GetBlockHeadersWrapper {
|
impl Default for GetBlockHeadersWrapper {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(missing_docs)]
|
||||||
use criterion::{
|
use criterion::{
|
||||||
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
||||||
};
|
};
|
||||||
@ -21,7 +22,7 @@ fn generate_test_data_priority() -> (u128, u128, u128, u128) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn priority_bench(
|
fn priority_bench(
|
||||||
group: &mut BenchmarkGroup<WallTime>,
|
group: &mut BenchmarkGroup<'_, WallTime>,
|
||||||
description: &str,
|
description: &str,
|
||||||
input_data: (u128, u128, u128, u128),
|
input_data: (u128, u128, u128, u128),
|
||||||
) {
|
) {
|
||||||
@ -40,7 +41,7 @@ fn priority_bench(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fee_jump_bench(
|
fn fee_jump_bench(
|
||||||
group: &mut BenchmarkGroup<WallTime>,
|
group: &mut BenchmarkGroup<'_, WallTime>,
|
||||||
description: &str,
|
description: &str,
|
||||||
input_data: (u128, u128),
|
input_data: (u128, u128),
|
||||||
) {
|
) {
|
||||||
@ -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 mut group = c.benchmark_group("Blob priority calculation");
|
||||||
let fee_jump_input = generate_test_data_fee_delta();
|
let fee_jump_input = generate_test_data_fee_delta();
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(missing_docs)]
|
||||||
use criterion::{
|
use criterion::{
|
||||||
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
||||||
};
|
};
|
||||||
@ -9,12 +10,12 @@ use proptest::{
|
|||||||
use reth_transaction_pool::test_utils::MockTransaction;
|
use reth_transaction_pool::test_utils::MockTransaction;
|
||||||
|
|
||||||
/// Transaction Pool trait for benching.
|
/// Transaction Pool trait for benching.
|
||||||
pub trait BenchTxPool: Default {
|
trait BenchTxPool: Default {
|
||||||
fn add_transaction(&mut self, tx: MockTransaction);
|
fn add_transaction(&mut self, tx: MockTransaction);
|
||||||
fn reorder(&mut self, base_fee: u64);
|
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");
|
let mut group = c.benchmark_group("Transaction Pool Reordering");
|
||||||
|
|
||||||
for seed_size in [1_000, 10_000, 50_000, 100_000] {
|
for seed_size in [1_000, 10_000, 50_000, 100_000] {
|
||||||
@ -54,7 +55,7 @@ pub fn txpool_reordering(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn txpool_reordering_bench<T: BenchTxPool>(
|
fn txpool_reordering_bench<T: BenchTxPool>(
|
||||||
group: &mut BenchmarkGroup<WallTime>,
|
group: &mut BenchmarkGroup<'_, WallTime>,
|
||||||
description: &str,
|
description: &str,
|
||||||
seed: Vec<MockTransaction>,
|
seed: Vec<MockTransaction>,
|
||||||
new_txs: Vec<MockTransaction>,
|
new_txs: Vec<MockTransaction>,
|
||||||
@ -170,7 +171,7 @@ mod implementations {
|
|||||||
|
|
||||||
impl PartialEq for MockTransactionWithPriority {
|
impl PartialEq for MockTransactionWithPriority {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.priority.eq(&other.priority)
|
self.priority == other.priority
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(missing_docs)]
|
||||||
use criterion::{
|
use criterion::{
|
||||||
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
|
||||||
};
|
};
|
||||||
@ -124,7 +125,7 @@ fn txpool_truncate(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn truncate_pending(
|
fn truncate_pending(
|
||||||
group: &mut BenchmarkGroup<WallTime>,
|
group: &mut BenchmarkGroup<'_, WallTime>,
|
||||||
description: &str,
|
description: &str,
|
||||||
seed: Vec<MockTransaction>,
|
seed: Vec<MockTransaction>,
|
||||||
senders: usize,
|
senders: usize,
|
||||||
@ -159,7 +160,7 @@ fn truncate_pending(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn truncate_parked(
|
fn truncate_parked(
|
||||||
group: &mut BenchmarkGroup<WallTime>,
|
group: &mut BenchmarkGroup<'_, WallTime>,
|
||||||
description: &str,
|
description: &str,
|
||||||
seed: Vec<MockTransaction>,
|
seed: Vec<MockTransaction>,
|
||||||
senders: usize,
|
senders: usize,
|
||||||
|
|||||||
Reference in New Issue
Block a user