Skip to content

refactor(l1): remove lazy_static dependency in favor of std::sync::LazyLock #4047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sumitvekariya
Copy link

Description

This PR removes the lazy_static dependency in favor of the standard library's std::sync::LazyLock, which has been available since Rust 1.80.0.

Changes Made

  • Remove lazy_static = "1.5.0" from workspace dependencies
  • Replace all lazy_static! macro usages with std::sync::LazyLock
  • Update imports from lazy_static::lazy_static to std::sync::LazyLock
  • Remove lazy_static.workspace = true from all individual crate Cargo.toml files

Benefits

  • Eliminates external dependency
  • Uses modern Rust standard library functionality
  • Maintains identical functionality and performance
  • Modernizes codebase

Testing

  • ✅ All existing tests pass
  • ✅ Code compiles successfully in debug and release modes
  • ✅ No functionality changes - statics work identically

Closes #3383

- Remove lazy_static = "1.5.0" from workspace dependencies
- Replace all lazy_static! macro usages with std::sync::LazyLock
- Update imports from lazy_static::lazy_static to std::sync::LazyLock
- Remove lazy_static.workspace = true from all individual crate Cargo.toml files

This modernizes the codebase to use the standard library's LazyLock
available since Rust 1.80.0, eliminating the external dependency
while maintaining identical functionality.

Fixes lambdaclass#3383
@Copilot Copilot AI review requested due to automatic review settings August 14, 2025 13:38
@sumitvekariya sumitvekariya requested a review from a team as a code owner August 14, 2025 13:38
Copy link
Contributor

@Copilot 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 modernizes the codebase by replacing the external lazy_static dependency with Rust's standard library std::sync::LazyLock, which has been available since Rust 1.80.0.

  • Remove lazy_static = "1.5.0" from workspace dependencies
  • Replace all lazy_static! macro usages with std::sync::LazyLock
  • Update imports and remove dependency references from individual crate Cargo.toml files

Reviewed Changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Cargo.toml Remove lazy_static from workspace dependencies
tooling/archive_sync/src/main.rs Convert CLIENT static to LazyLock
crates/vm/levm/src/l2_precompiles.rs Convert P256_B static to LazyLock
crates/networking/p2p/sync.rs Convert multiple state trie statics to LazyLock
crates/networking/p2p/snap.rs Convert test hash constants to LazyLock
crates/l2/common/src/state_diff.rs Convert length calculation statics to LazyLock
crates/common/trie/trie.rs Convert EMPTY_TRIE_HASH static to LazyLock
cmd/ethrex/l2/deployer.rs Convert SALT static to LazyLock
cmd/ef_tests/blockchain/network.rs Convert chain config statics to LazyLock
Multiple Cargo.toml files Remove lazy_static dependency references

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@sumitvekariya sumitvekariya changed the title Remove lazy_static dependency in favor of std::sync::LazyLock refactor: remove lazy_static dependency in favor of std::sync::LazyLock Aug 14, 2025
@sumitvekariya sumitvekariya changed the title refactor: remove lazy_static dependency in favor of std::sync::LazyLock refactor(l1): remove lazy_static dependency in favor of std::sync::LazyLock Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove lazy_static dep in favour of std::sync::LazyLock
1 participant