Skip to content

Conversation

@MegaRedHand
Copy link
Collaborator

@MegaRedHand MegaRedHand commented Nov 10, 2025

Motivation

We had a useless Arc in the layering module.

Description

This PR removes the Arc, which also lets us remove a clone we had in the commit function.

Copilot AI review requested due to automatic review settings November 10, 2025 18:03
@MegaRedHand MegaRedHand requested a review from a team as a code owner November 10, 2025 18:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes redundant Arc wrapping from the nodes field in TrieLayer, simplifying the data structure since TrieLayer instances are already wrapped in Arc at the cache level.

  • Removed nested Arc wrapper from TrieLayer::nodes field
  • Updated constructor to directly assign the HashMap without wrapping
  • Simplified iterator chain to use the HashMap directly
Comments suppressed due to low confidence (1)

crates/storage/trie_db/layering.rs:181

  • With the removal of Arc from the nodes field, cloning TrieLayer at line 180 now performs a deep clone of the entire FxHashMap, which could be expensive for large maps. Consider if this fallback case (when Arc::try_unwrap fails) is frequent enough to warrant keeping the Arc<FxHashMap> for cheaper clones, or document this trade-off.
        let layer = match Arc::try_unwrap(self.layers.remove(&state_root)?) {
            Ok(layer) => layer,
            Err(layer) => TrieLayer::clone(&layer),
        };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MegaRedHand MegaRedHand changed the title refactor: remove unneeded clone and Arc refactor(l1): remove unneeded clone and Arc Nov 10, 2025
@github-actions github-actions bot added the L1 Ethereum client label Nov 10, 2025
@github-project-automation github-project-automation bot moved this to In Review in ethrex_l1 Nov 10, 2025
@MegaRedHand MegaRedHand added this pull request to the merge queue Nov 10, 2025
Merged via the queue into main with commit 1438c81 Nov 10, 2025
56 of 58 checks passed
@MegaRedHand MegaRedHand deleted the remove-layer-nodes-clone branch November 10, 2025 21:24
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 10, 2025
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

We had a useless `Arc` in the layering module.

**Description**

This PR removes the `Arc`, which also lets us remove a clone we had in
the `commit` function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants