Skip to content
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

clippy: add collection_is_never_read clippy lint #10703

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

tcoratger
Copy link
Contributor

No description provided.

@@ -695,7 +695,7 @@ impl From<Genesis> for ChainSpec {
chain: genesis.config.chain_id.into(),
genesis,
genesis_hash: None,
hardforks: ChainHardforks::new(hardforks),
hardforks: ChainHardforks::new(ordered_hardforks),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm not 100% sure but the ordered_hardforks collection was never read before and I have the impression that we are setting up on the few previous lines an ordering mechanism to use the ordered_hardforks here otherwise it has no interest right?

Copy link
Collaborator

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

smol nit, otherwise lgtm

@@ -695,7 +695,7 @@ impl From<Genesis> for ChainSpec {
chain: genesis.config.chain_id.into(),
genesis,
genesis_hash: None,
hardforks: ChainHardforks::new(hardforks),
hardforks: ChainHardforks::new(ordered_hardforks),
Copy link
Collaborator

Choose a reason for hiding this comment

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

im not too sure what this is even used for, cc @joshieDo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any difference between using it or not but maybe there are exceptions that I don't have in mind.

If this is not used, we can simply delete the whole block of code before:

// Uses ethereum or optimism main chains to find proper order
        #[cfg(not(feature = "optimism"))]
        let mainnet_hardforks: ChainHardforks = EthereumHardfork::mainnet().into();
        #[cfg(not(feature = "optimism"))]
        let mainnet_order = mainnet_hardforks.forks_iter();
        #[cfg(feature = "optimism")]
        let mainnet_hardforks = OptimismHardfork::op_mainnet();
        #[cfg(feature = "optimism")]
        let mainnet_order = mainnet_hardforks.forks_iter();

        let mut ordered_hardforks = Vec::with_capacity(hardforks.len());
        for (hardfork, _) in mainnet_order {
            if let Some(pos) = hardforks.iter().position(|(e, _)| **e == *hardfork) {
                ordered_hardforks.push(hardforks[pos].clone());
            }
        }

Copy link
Collaborator

@joshieDo joshieDo Sep 4, 2024

Choose a reason for hiding this comment

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

actually this is a bug, and it should be hardforks: ChainHardforks::new(ordered_hardforks) as suggested, mb

lint already doing work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We love lints :)

@onbjerg onbjerg added the C-enhancement New feature or request label Sep 4, 2024
@onbjerg onbjerg added this pull request to the merge queue Sep 4, 2024
Merged via the queue into paradigmxyz:main with commit 1ef4d6d Sep 4, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants