Skip to content

Conversation

@iovoid
Copy link
Contributor

@iovoid iovoid commented Nov 27, 2025

Motivation

Dead code in pub functions is not found by clippy, so they can easily accumulate.

Description

Using a tool, several functions that are never used are found.

@github-actions github-actions bot added L1 Ethereum client L2 Rollup client levm Lambda EVM implementation labels Nov 27, 2025
@github-actions
Copy link

github-actions bot commented Nov 27, 2025

Lines of code report

Total lines added: 0
Total lines removed: 268
Total lines changed: 268

Detailed view
+-------------------------------------------------------+-------+------+
| File                                                  | Lines | Diff |
+-------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/utils.rs                            | 156   | -7   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/common/serde_utils.rs                   | 610   | -23  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/common/types/block_execution_witness.rs | 350   | -56  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/common/types/l2/fee_config.rs           | 196   | -36  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/common/types/transaction.rs             | 3203  | -5   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/l2/common/src/l1_messages.rs            | 57    | -6   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/peer_handler.rs          | 1708  | -37  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection/codec.rs | 242   | -12  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/sync.rs                  | 1360  | -20  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/types.rs                 | 500   | -5   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/gas_cost.rs                 | 822   | -8   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/memory.rs                   | 279   | -9   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/utils.rs                    | 432   | -44  |
+-------------------------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

Benchmark Results Comparison

Benchmark Results: Push

Command Mean [s] Min [s] Max [s] Relative
main_revm_Push 293.3 ± 1.7 290.9 296.2 1.00 ± 0.01
main_levm_Push 346.6 ± 134.6 303.0 729.6 1.18 ± 0.46
pr_levm_Push 313.4 ± 33.5 300.9 408.6 1.07 ± 0.11
Detailed Results

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
main_revm_BubbleSort 2.978 ± 0.044 2.940 3.064 1.00 ± 0.02
main_levm_BubbleSort 3.091 ± 0.021 3.072 3.135 1.04 ± 0.02
pr_revm_BubbleSort 2.973 ± 0.049 2.934 3.090 1.00
pr_levm_BubbleSort 3.083 ± 0.013 3.062 3.102 1.04 ± 0.02

Benchmark Results: ERC20Approval

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Approval 961.8 ± 7.1 955.3 977.1 1.00
main_levm_ERC20Approval 1077.9 ± 9.8 1071.6 1104.0 1.12 ± 0.01
pr_revm_ERC20Approval 970.2 ± 11.1 956.8 992.3 1.01 ± 0.01
pr_levm_ERC20Approval 1083.0 ± 8.7 1070.0 1097.3 1.13 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 132.0 ± 0.9 130.2 133.2 1.00 ± 0.02
main_levm_ERC20Mint 164.2 ± 5.6 160.9 180.0 1.25 ± 0.05
pr_revm_ERC20Mint 131.7 ± 1.9 129.9 136.8 1.00
pr_levm_ERC20Mint 161.6 ± 1.9 159.9 166.4 1.23 ± 0.02

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 229.8 ± 1.7 226.5 232.7 1.00
main_levm_ERC20Transfer 274.9 ± 2.8 270.8 280.0 1.20 ± 0.02
pr_revm_ERC20Transfer 230.2 ± 2.1 227.1 233.7 1.00 ± 0.01
pr_levm_ERC20Transfer 275.6 ± 2.3 272.8 279.0 1.20 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 225.0 ± 1.2 223.7 227.9 1.00
main_levm_Factorial 270.6 ± 8.4 263.1 289.9 1.20 ± 0.04
pr_revm_Factorial 226.4 ± 6.0 222.9 243.1 1.01 ± 0.03
pr_levm_Factorial 267.7 ± 2.0 265.0 272.2 1.19 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.661 ± 0.032 1.619 1.705 1.01 ± 0.04
main_levm_FactorialRecursive 8.292 ± 0.044 8.248 8.384 5.04 ± 0.17
pr_revm_FactorialRecursive 1.646 ± 0.055 1.554 1.711 1.00
pr_levm_FactorialRecursive 8.301 ± 0.038 8.251 8.371 5.04 ± 0.17

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 205.5 ± 0.9 204.8 207.8 1.00
main_levm_Fibonacci 261.8 ± 1.8 259.3 264.6 1.27 ± 0.01
pr_revm_Fibonacci 205.6 ± 1.7 204.1 210.1 1.00 ± 0.01
pr_levm_Fibonacci 262.5 ± 3.2 258.8 269.2 1.28 ± 0.02

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 875.6 ± 10.7 855.3 890.2 1.16 ± 0.03
main_levm_FibonacciRecursive 757.4 ± 22.9 745.2 820.2 1.00 ± 0.04
pr_revm_FibonacciRecursive 874.7 ± 4.6 866.4 881.5 1.16 ± 0.03
pr_levm_FibonacciRecursive 754.4 ± 17.1 740.5 798.6 1.00

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.2 ± 0.1 8.1 8.4 1.01 ± 0.01
main_levm_ManyHashes 8.9 ± 0.1 8.9 9.2 1.10 ± 0.02
pr_revm_ManyHashes 8.2 ± 0.0 8.1 8.2 1.00
pr_levm_ManyHashes 8.9 ± 0.1 8.8 9.1 1.09 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 261.3 ± 2.0 259.3 265.5 1.07 ± 0.01
main_levm_MstoreBench 244.1 ± 2.4 241.7 248.1 1.00
pr_revm_MstoreBench 261.9 ± 1.0 260.5 263.3 1.07 ± 0.01
pr_levm_MstoreBench 245.1 ± 5.1 240.4 257.6 1.00 ± 0.02

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 293.3 ± 1.7 290.9 296.2 1.00 ± 0.01
main_levm_Push 346.6 ± 134.6 303.0 729.6 1.18 ± 0.46
pr_revm_Push 292.8 ± 2.0 290.6 297.0 1.00
pr_levm_Push 313.4 ± 33.5 300.9 408.6 1.07 ± 0.11

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 166.0 ± 3.1 161.0 169.7 1.86 ± 0.05
main_levm_SstoreBench_no_opt 89.4 ± 2.0 86.6 92.3 1.00
pr_revm_SstoreBench_no_opt 167.1 ± 4.6 160.7 177.3 1.87 ± 0.07
pr_levm_SstoreBench_no_opt 90.5 ± 2.8 88.1 95.8 1.01 ± 0.04

Copy link
Contributor

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test these changes in our tooling https://github.com/lambdaclass/ethrex-replay and https://github.com/lambdaclass/rex

@github-project-automation github-project-automation bot moved this to In Progress in ethrex_l1 Nov 27, 2025
@github-project-automation github-project-automation bot moved this to Requires Changes in ethrex_l2 Nov 27, 2025
Copy link
Contributor

@pablodeymo pablodeymo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to review external dependencies

@iovoid
Copy link
Contributor Author

iovoid commented Nov 28, 2025

  • rex seems to work after fixing unrelated incompatibilities (compile_contract and get_address_from_secret_key changed their interface), the changes are left in the branch test_remove_dead_pub if you want to reproduce

  • ethrex-replay block execution tested

@fedacking fedacking requested a review from ilitteri November 28, 2025 17:15
Comment on lines -585 to -612
/// Fetches all receipts for the given block hashes via p2p and stores them
// TODO: remove allow when used again
#[allow(unused)]
async fn store_receipts(
mut block_hashes: Vec<BlockHash>,
mut peers: PeerHandler,
store: Store,
) -> Result<(), SyncError> {
loop {
debug!("Requesting Receipts ");
if let Some(receipts) = peers.request_receipts(block_hashes.clone()).await? {
debug!(" Received {} Receipts", receipts.len());
// Track which blocks we have already fetched receipts for
for (block_hash, receipts) in block_hashes.drain(0..receipts.len()).zip(receipts) {
store.add_receipts(block_hash, receipts).await?;
}
// Check if we need to ask for another batch
if block_hashes.is_empty() {
break;
}
}
}
Ok(())
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be used when we address #1766 , maybe we should leave it and link the issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is #1766 going to be addressed soon? While that issue is not being addressed, I'd prefer to mention this thread in the issue and remove the code for now.

Comment on lines -68 to -73
pub fn read_block_file(block_file_path: &str) -> Block {
let encoded_block = std::fs::read(block_file_path)
.unwrap_or_else(|_| panic!("Failed to read block file with path {block_file_path}"));
Block::decode(&encoded_block)
.unwrap_or_else(|_| panic!("Failed to decode block file {block_file_path}"))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though the import command used this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done by read_chain_file, which is almost identical.

### 2025-10-17

- Replaces incremental iteration with a one-time precompute method that scans the entire bytecode, building a `BitVec<u8, Msb0>` where bits mark valid `JUMPDEST` positions, skipping `PUSH1..PUSH32` data bytes.
- Updates `is_blacklisted` to O(1) bit lookup.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog shouldn't change. If anything, log that it was recently removed in a new entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_blacklisted's case is particular since it was already dead when that change happened, but I see why we might not want to pretend it never happened

Maybe adding a note or a strikethrough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's first send this one as a separate PR as this is surely unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate PR?

@ilitteri ilitteri requested a review from pablodeymo November 28, 2025 19:31
@iovoid iovoid marked this pull request as ready for review November 28, 2025 20:58
@iovoid iovoid requested review from a team, ManuelBilbao and avilagaston9 as code owners November 28, 2025 20:58
@ethrex-project-sync ethrex-project-sync bot moved this from In Progress to In Review in ethrex_l1 Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client L2 Rollup client levm Lambda EVM implementation

Projects

Status: In Review
Status: Requires Changes

Development

Successfully merging this pull request may close these issues.

8 participants