Skip to content

fix: replace deprecated #[clap(...)] with #[command(...)] and #[arg #3224

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 9 commits into
base: main
Choose a base branch
from

Conversation

Himess
Copy link

@Himess Himess commented May 7, 2025

Closes #2826
Ref : #2827 (comment)

This PR:

-Replaces deprecated #[clap(...)] attributes with the updated #[arg(...)], #[command(...)], and #[arg(value_name = ...)] formats throughout the codebase.

-Cleans up redundant/default attributes such as:

#[arg(action)] → removed, since action is now the default in clap v4

#[arg(value_parser)] → removed, also default now

Replaces all #[arg(name = "...")] with #[arg(value_name = "...")] as per current best practices

This PR does not:

-Introduce any logic changes beyond the attribute replacements
-Refactor surrounding CLI parsing logic

Key places to review:

-All CLI argument definitions using #[arg(...)]

-Replacements of name = "...“ with value_name = "..."

-Removed empty or default action and value_parser usages

Things tested

cargo check

Pasted Graphic 13

cargo check --features clap/deprecated

Pasted Graphic 2

cargo build

Pasted Graphic 3

✅ All tests passed successfully.

@Himess Himess changed the title fix: replace deprecated #[clap(...)] with #[command(...)] and #[arg(.… fix: replace deprecated #[clap(...)] with #[command(...)] and #[arg May 7, 2025
@Himess
Copy link
Author

Himess commented May 7, 2025

@sveitser Could you check this ? There are no conflicts now.

@@ -20,40 +20,40 @@ use vbs::version::StaticVersionType;
#[derive(Clone, Debug, Parser)]
struct Options {
/// Start counting from block FROM.
#[clap(long, name = "FROM")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why change name to id?

Copy link
Author

Choose a reason for hiding this comment

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

Pasted Graphic 1
For this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we use value_name then?

Copy link
Author

Choose a reason for hiding this comment

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

@sveitser Yes, you're right. I updated name to value_name as you suggested.

@Himess Himess force-pushed the fix/deprecated-clap-v2 branch 2 times, most recently from abc9968 to 61e2cf7 Compare May 7, 2025 14:20
@Himess
Copy link
Author

Himess commented May 7, 2025

@sveitser Could you run CI again ? I force pushed branch for fmt.

@Himess Himess force-pushed the fix/deprecated-clap-v2 branch from 61e2cf7 to 6a41254 Compare May 7, 2025 22:12
@sveitser
Copy link
Collaborator

sveitser commented May 8, 2025

Please never force push to a branch after having received a review. We need to review everything again.

@sveitser
Copy link
Collaborator

sveitser commented May 8, 2025

Also there is more to fix on your branch now, since code has been added recently:

cargo check --features clap/deprecated                                                                                   0.024s  pr/3224  ❄  09:34:39
   Compiling sequencer v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/sequencer)
    Checking sequencer-utils v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/utils)
    Checking espresso-types v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/types)
    Checking espresso-contract-deployer v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/contracts/rust/deployer)
    Checking marketplace-solver v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/marketplace-solver)
    Checking client v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/client)
    Checking node-metrics v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/node-metrics)
warning: use of deprecated function `<DeployedContracts as clap::Args>::augment_args::old_attribute`: Attribute `#[clap(...)]` has been deprecated in favor of `#[arg(...)]`
  --> contracts/rust/deployer/src/lib.rs:72:7
   |
72 |     #[clap(long, env = Contract::Timelock)]
   |       ^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: `espresso-contract-deployer` (lib) generated 1 warning
    Checking hotshot-state-prover v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/hotshot-state-prover)
    Checking staking-cli v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/staking-cli)
    Checking diff-test-hotshot v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/contracts/rust/diff-test)
    Checking gen-vk-contract v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/contracts/rust/gen-vk-contract)
    Checking builder v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/builder)
    Checking marketplace-builder v0.1.0 (/home/lulu/r/EspressoSystems/espresso-network/marketplace-builder)
warning: use of deprecated function `<ns_aggregator::Options as clap::Args>::augment_args::old_attribute`: Attribute `#[clap(...)]` has been deprecated in favor of `#[arg(...)]`
  --> sequencer/src/bin/utils/ns_aggregator.rs:14:7
   |
14 |     #[clap(short, long, default_value = "0")]
   |       ^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated function `<ns_aggregator::Options as clap::Args>::augment_args::old_attribute`: Attribute `#[clap(...)]` has been deprecated in favor of `#[arg(...)]`
  --> sequencer/src/bin/utils/ns_aggregator.rs:21:7
   |
21 |     #[clap(short, long)]
   |       ^^^^

warning: use of deprecated function `<ns_aggregator::Options as clap::Args>::augment_args::old_attribute`: Attribute `#[clap(...)]` has been deprecated in favor of `#[arg(...)]`
  --> sequencer/src/bin/utils/ns_aggregator.rs:25:7
   |
25 |     #[clap(short, long)]
   |       ^^^^

warning: use of deprecated function `<ns_aggregator::Options as clap::Args>::augment_args::old_attribute`: Attribute `#[clap(...)]` has been deprecated in favor of `#[arg(...)]`
  --> sequencer/src/bin/utils/ns_aggregator.rs:32:7
   |
32 |     #[clap(short, long, default_value = "1")]
   |       ^^^^

warning: `sequencer` (bin "utils") generated 4 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.70s

Why not enable the deprecated feature by default so everyone gets warnings if they use deprecated features? At least as dev dependency? Otherwise we will just see deprecated features being added again.

@Himess
Copy link
Author

Himess commented May 9, 2025

Hi @sveitser , I will force pushed (because so mony conflicts here.) branch. After that i can open other PR to solve if you accepted.
Why not enable the deprecated feature by default so everyone gets warnings if they use deprecated features? At least as dev dependency? Otherwise we will just see deprecated features being added again.

@Himess Himess force-pushed the fix/deprecated-clap-v2 branch 2 times, most recently from 10ebfae to 877a7c4 Compare May 9, 2025 23:17
@Himess Himess marked this pull request as draft May 10, 2025 23:14
@Himess Himess closed this May 12, 2025
@Himess Himess force-pushed the fix/deprecated-clap-v2 branch from 877a7c4 to 031a09e Compare May 12, 2025 20:28
@Himess Himess reopened this May 12, 2025
@Himess Himess marked this pull request as ready for review May 12, 2025 20:49
@Himess Himess requested a review from sveitser May 12, 2025 20:49
@Himess Himess force-pushed the fix/deprecated-clap-v2 branch from f0d85cb to 8d61889 Compare May 12, 2025 21:04
@Himess
Copy link
Author

Himess commented May 12, 2025

Hi @sveitser, It's ready for review now.
Also, I added a CI check for clap deprecation warnings:

- name: Check if deprecated clap feature triggers warnings
        run: |
          cargo clippy --workspace --all-targets --no-default-features --features clap/deprecated \
          -- -D warnings

@Himess Himess force-pushed the fix/deprecated-clap-v2 branch from 8d61889 to 71de056 Compare May 12, 2025 21:11
@Himess
Copy link
Author

Himess commented May 15, 2025

@sveitser Could you check again ?

@Himess
Copy link
Author

Himess commented May 20, 2025

@sveitser Could you check ?

@@ -45,6 +45,11 @@ jobs:
cargo clippy --workspace --features testing --all-targets --keep-going \
-- -D warnings

- name: Check if deprecated clap feature triggers warnings
Copy link
Collaborator

@sveitser sveitser May 22, 2025

Choose a reason for hiding this comment

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

I don't think it's necessary to run clippy twice with different features, please remove this.

Copy link
Author

Choose a reason for hiding this comment

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

Done sir.

@@ -4509,7 +4509,7 @@ pub mod LightClientArbitrumV2 {
#[rustfmt::skip]
#[allow(clippy::all)]
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your PR unexpectedly changes the contract bytecode.

Copy link
Author

Choose a reason for hiding this comment

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

I believe this change isn't part of my PR — I haven’t touched lightclientarbitrumv2.rs, and it also doesn’t appear under “Files changed”. Most likely, this was introduced by a previous merge from main.

@Himess
Copy link
Author

Himess commented May 26, 2025

@sveitser Ready for review sir.

@Himess Himess requested a review from sveitser May 26, 2025 21:41
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.

Update deprecated #[clap(...)] and #[arg(name = ...)] usages to clap 4.x standards
2 participants