diff --git a/.github/workflows/ci-core-lint-reusable.yml b/.github/workflows/ci-core-lint-reusable.yml index 0babbd1c9db7..0d4db601c467 100644 --- a/.github/workflows/ci-core-lint-reusable.yml +++ b/.github/workflows/ci-core-lint-reusable.yml @@ -50,6 +50,7 @@ jobs: ci_run zkstack dev lint -t ts --check ci_run zkstack dev lint -t rs --check ci_run zkstack dev lint -t autocompletion --check + ci_run zkstack dev lint -t rust-toolchain - name: Check Database run: | diff --git a/rust-toolchain b/rust-toolchain index 03c040b91f1f..bc5d1d6bbd8e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,2 @@ -nightly-2024-08-01 +[toolchain] +channel = "nightly-2024-08-01" diff --git a/zkstack_cli/Cargo.lock b/zkstack_cli/Cargo.lock index 0f0657c60278..a9089719714d 100644 --- a/zkstack_cli/Cargo.lock +++ b/zkstack_cli/Cargo.lock @@ -1097,7 +1097,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -6808,11 +6807,6 @@ dependencies = [ "rand", "secrecy", "serde", - "strum", - "strum_macros", - "time", - "url", - "vise", "zksync_basic_types", "zksync_concurrency", "zksync_consensus_utils", @@ -6962,7 +6956,6 @@ dependencies = [ "secrecy", "serde_json", "serde_yaml", - "time", "tracing", "zksync_basic_types", "zksync_config", diff --git a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh index f1cfc9946731..825fc967e6d7 100644 --- a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh +++ b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh @@ -1255,8 +1255,8 @@ esac ;; (lint) _arguments "${_arguments_options[@]}" : \ -'*-t+[]:TARGETS:(md sol js ts rs contracts autocompletion)' \ -'*--targets=[]:TARGETS:(md sol js ts rs contracts autocompletion)' \ +'*-t+[]:TARGETS:(md sol js ts rs contracts autocompletion rust-toolchain)' \ +'*--targets=[]:TARGETS:(md sol js ts rs contracts autocompletion rust-toolchain)' \ '--chain=[Chain to use]:CHAIN:_default' \ '-c[]' \ '--check[]' \ @@ -1309,8 +1309,8 @@ _arguments "${_arguments_options[@]}" : \ ;; (prettier) _arguments "${_arguments_options[@]}" : \ -'*-t+[]:TARGETS:(md sol js ts rs contracts autocompletion)' \ -'*--targets=[]:TARGETS:(md sol js ts rs contracts autocompletion)' \ +'*-t+[]:TARGETS:(md sol js ts rs contracts autocompletion rust-toolchain)' \ +'*--targets=[]:TARGETS:(md sol js ts rs contracts autocompletion rust-toolchain)' \ '--chain=[Chain to use]:CHAIN:_default' \ '-v[Verbose mode]' \ '--verbose[Verbose mode]' \ diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.fish b/zkstack_cli/crates/zkstack/completion/zkstack.fish index a1261082e6f0..7ad4e6959f90 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.fish +++ b/zkstack_cli/crates/zkstack/completion/zkstack.fish @@ -368,7 +368,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_sub complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from snapshot" -s h -l help -d 'Print help' complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from snapshot" -f -a "create" complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from snapshot" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' -complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from lint" -s t -l targets -r -f -a "{md\t'',sol\t'',js\t'',ts\t'',rs\t'',contracts\t'',autocompletion\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from lint" -s t -l targets -r -f -a "{md\t'',sol\t'',js\t'',ts\t'',rs\t'',contracts\t'',autocompletion\t'',rust-toolchain\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from lint" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from lint" -s c -l check complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and __fish_seen_subcommand_from lint" -s v -l verbose -d 'Verbose mode' diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.sh b/zkstack_cli/crates/zkstack/completion/zkstack.sh index 7cdb20ae9aa7..ff351ebd79ed 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.sh +++ b/zkstack_cli/crates/zkstack/completion/zkstack.sh @@ -3104,11 +3104,11 @@ _zkstack() { fi case "${prev}" in --targets) - COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion" -- "${cur}")) + COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion rust-toolchain" -- "${cur}")) return 0 ;; -t) - COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion" -- "${cur}")) + COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion rust-toolchain" -- "${cur}")) return 0 ;; --chain) @@ -3768,11 +3768,11 @@ _zkstack() { fi case "${prev}" in --targets) - COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion" -- "${cur}")) + COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion rust-toolchain" -- "${cur}")) return 0 ;; -t) - COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion" -- "${cur}")) + COMPREPLY=($(compgen -W "md sol js ts rs contracts autocompletion rust-toolchain" -- "${cur}")) return 0 ;; --chain) diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs index d018859a8fff..04955726706f 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs @@ -41,6 +41,7 @@ pub fn run(shell: &Shell, args: LintArgs) -> anyhow::Result<()> { Target::Ts, Target::Contracts, Target::Autocompletion, + Target::RustToolchain, ] } else { args.targets.clone() @@ -55,6 +56,7 @@ pub fn run(shell: &Shell, args: LintArgs) -> anyhow::Result<()> { Target::Rs => lint_rs(shell, &ecosystem, args.check)?, Target::Contracts => lint_contracts(shell, &ecosystem, args.check)?, Target::Autocompletion => lint_autocompletion_files(shell, args.check)?, + Target::RustToolchain => check_rust_toolchain(shell)?, ext => lint(shell, &ecosystem, &ext, args.check)?, } } @@ -70,13 +72,18 @@ fn lint_rs(shell: &Shell, ecosystem: &EcosystemConfig, check: bool) -> anyhow::R let link_to_code = &ecosystem.link_to_code; let lint_to_prover = &ecosystem.link_to_code.join("prover"); let link_to_zkstack = &ecosystem.link_to_code.join("zkstack_cli"); - let paths = vec![link_to_code, lint_to_prover, link_to_zkstack]; spinner.freeze(); - for path in paths { + for path in [link_to_code, lint_to_prover, link_to_zkstack] { let _dir_guard = shell.push_dir(path); let mut cmd = cmd!(shell, "cargo clippy"); - let common_args = &["--locked", "--", "-D", "warnings"]; + let mut common_args = vec!["--locked", "--", "-D", "warnings"]; + + if !path.ends_with("prover") { + common_args.push("-D"); + common_args.push("unstable-features"); + } + if !check { cmd = cmd.args(&["--fix", "--allow-dirty"]); } @@ -87,6 +94,34 @@ fn lint_rs(shell: &Shell, ecosystem: &EcosystemConfig, check: bool) -> anyhow::R Ok(()) } +fn check_rust_toolchain(shell: &Shell) -> anyhow::Result<()> { + // deserialize /zkstack_cli/rust-toolchain as TOML + let path = Path::new("zkstack_cli/rust-toolchain"); + if !path.exists() { + logger::info("WARNING: Please run this command from the project's root folder"); + return Ok(()); + } + let contents = shell.read_file(path)?; + let zkstack_cli_toolchain: toml::Value = toml::from_str(&contents)?; + + // deserialize /rust-toolchain as TOML + let path = Path::new("rust-toolchain"); + let contents = shell.read_file(path)?; + let zksync_era_toolchain: toml::Value = toml::from_str(&contents)?; + + // check if the toolchains are the same + if zksync_era_toolchain["toolchain"]["channel"] != zkstack_cli_toolchain["toolchain"]["channel"] + { + bail!( + "The Rust toolchains are not the same: ZKsync Era: {} - ZK Stack CLI: {}", + zksync_era_toolchain["toolchain"]["channel"], + zkstack_cli_toolchain["toolchain"]["channel"] + ); + } + + Ok(()) +} + fn get_linter(target: &Target) -> Vec { match target { Target::Rs => vec!["cargo".to_string(), "clippy".to_string()], @@ -96,6 +131,7 @@ fn get_linter(target: &Target) -> Vec { Target::Ts => vec!["eslint".to_string(), "--ext".to_string(), "ts".to_string()], Target::Contracts => vec![], Target::Autocompletion => vec![], + Target::RustToolchain => vec![], } } diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint_utils.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint_utils.rs index 11a325047104..93184de76561 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint_utils.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint_utils.rs @@ -15,6 +15,7 @@ pub enum Target { Rs, Contracts, Autocompletion, + RustToolchain, } #[derive(Deserialize, Serialize, Debug)] diff --git a/zkstack_cli/rust-toolchain b/zkstack_cli/rust-toolchain index 03c040b91f1f..bc5d1d6bbd8e 100644 --- a/zkstack_cli/rust-toolchain +++ b/zkstack_cli/rust-toolchain @@ -1 +1,2 @@ -nightly-2024-08-01 +[toolchain] +channel = "nightly-2024-08-01"