Skip to content

Commit 55ba9e9

Browse files
authored
[CLI] cherry pick (#20977) Deprecation warnings for dependency verification (#21127)
## Description This adds a warning that source verification will become opt-in instead of opt-out in a future release, along with the `--verify-deps` flag that currently disables the warning. ## Test plan Several shell tests that cover the behavior with no flags, with both flags, and with each flag independently, on a package with source that has changed since publication. See the snapshot files for the tests and expected output. ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [X] CLI: publication and upgrade will now warn that source verification will become opt-in in a future release; the warning can be disabled with either `--skip-dependency-verification` or the new `--verify-deps` flags - [ ] Rust SDK:
1 parent 23424e7 commit 55ba9e9

19 files changed

+533
-10
lines changed

crates/sui-source-validation-service/tests/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ async fn run_publish(
181181
package_path: package_path.clone(),
182182
build_config,
183183
skip_dependency_verification: false,
184+
verify_deps: true,
184185
with_unpublished_dependencies: false,
185186
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
186187
}
@@ -208,6 +209,7 @@ async fn run_upgrade(
208209
upgrade_capability: cap.reference.object_id,
209210
build_config,
210211
skip_dependency_verification: false,
212+
verify_deps: true,
211213
with_unpublished_dependencies: false,
212214
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
213215
verify_compatibility: true,

crates/sui/src/client_commands.rs

+46-8
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,16 @@ pub enum SuiClientCommands {
360360
#[clap(flatten)]
361361
opts: OptsWithGas,
362362

363-
/// Publish the package without checking whether compiling dependencies from source results
364-
/// in bytecode matching the dependencies found on-chain.
363+
/// Publish the package without checking whether dependency source code compiles to the
364+
/// on-chain bytecode
365365
#[clap(long)]
366366
skip_dependency_verification: bool,
367367

368+
/// Check that the dependency source code compiles to the on-chain bytecode before
369+
/// publishing the package (currently the default behavior)
370+
#[clap(long, conflicts_with = "skip_dependency_verification")]
371+
verify_deps: bool,
372+
368373
/// Also publish transitive dependencies that have not already been published.
369374
#[clap(long)]
370375
with_unpublished_dependencies: bool,
@@ -465,11 +470,16 @@ pub enum SuiClientCommands {
465470
#[clap(long)]
466471
verify_compatibility: bool,
467472

468-
/// Publish the package without checking whether compiling dependencies from source results
469-
/// in bytecode matching the dependencies found on-chain.
473+
/// Upgrade the package without checking whether dependency source code compiles to the on-chain
474+
/// bytecode
470475
#[clap(long)]
471476
skip_dependency_verification: bool,
472477

478+
/// Check that the dependency source code compiles to the on-chain bytecode before
479+
/// upgrading the package (currently the default behavior)
480+
#[clap(long, conflicts_with = "skip_dependency_verification")]
481+
verify_deps: bool,
482+
473483
/// Also publish transitive dependencies that have not already been published.
474484
#[clap(long)]
475485
with_unpublished_dependencies: bool,
@@ -872,6 +882,7 @@ impl SuiClientCommands {
872882
upgrade_capability,
873883
build_config,
874884
skip_dependency_verification,
885+
verify_deps,
875886
verify_compatibility,
876887
with_unpublished_dependencies,
877888
opts,
@@ -897,7 +908,6 @@ impl SuiClientCommands {
897908
);
898909

899910
check_protocol_version_and_warn(&client).await?;
900-
901911
let package_path =
902912
package_path
903913
.canonicalize()
@@ -920,13 +930,16 @@ impl SuiClientCommands {
920930
.get_active_env()
921931
.map(|e| e.alias.clone())
922932
.ok();
933+
let verify =
934+
check_dep_verification_flags(skip_dependency_verification, verify_deps)?;
935+
923936
let upgrade_result = upgrade_package(
924937
client.read_api(),
925938
build_config.clone(),
926939
&package_path,
927940
upgrade_capability,
928941
with_unpublished_dependencies,
929-
skip_dependency_verification,
942+
!verify,
930943
env_alias,
931944
)
932945
.await;
@@ -1001,6 +1014,7 @@ impl SuiClientCommands {
10011014
package_path,
10021015
build_config,
10031016
skip_dependency_verification,
1017+
verify_deps,
10041018
with_unpublished_dependencies,
10051019
opts,
10061020
} => {
@@ -1025,7 +1039,6 @@ impl SuiClientCommands {
10251039
let chain_id = client.read_api().get_chain_identifier().await.ok();
10261040

10271041
check_protocol_version_and_warn(&client).await?;
1028-
10291042
let package_path =
10301043
package_path
10311044
.canonicalize()
@@ -1043,12 +1056,15 @@ impl SuiClientCommands {
10431056
} else {
10441057
None
10451058
};
1059+
let verify =
1060+
check_dep_verification_flags(skip_dependency_verification, verify_deps)?;
1061+
10461062
let compile_result = compile_package(
10471063
client.read_api(),
10481064
build_config.clone(),
10491065
&package_path,
10501066
with_unpublished_dependencies,
1051-
skip_dependency_verification,
1067+
!verify,
10521068
)
10531069
.await;
10541070
// Restore original ID, then check result.
@@ -1713,6 +1729,28 @@ impl SuiClientCommands {
17131729
}
17141730
}
17151731

1732+
/// Process the `--skip-dependency-verification` and `--verify-dependencies` flags for a publish or
1733+
/// upgrade command. Prints deprecation warnings as appropriate and returns true if the
1734+
/// dependencies should be verified
1735+
fn check_dep_verification_flags(
1736+
skip_dependency_verification: bool,
1737+
verify_dependencies: bool,
1738+
) -> anyhow::Result<bool> {
1739+
match (skip_dependency_verification, verify_dependencies) {
1740+
(true, true) => bail!("[error]: --skip_dependency_verification and --verify_dependencies are mutually exclusive"),
1741+
1742+
(false, false) => {
1743+
eprintln!("{}: In a future release, dependency source code will no longer be verified by default during publication and upgrade. \
1744+
You can opt in to source verification using `--verify-deps` or disable this warning using `--skip-dependency-verification`. \
1745+
You can also manually verify dependencies using `sui client verify-source`.",
1746+
"[warning]".bold().yellow());
1747+
Ok(true)
1748+
},
1749+
1750+
_ => Ok(verify_dependencies),
1751+
}
1752+
}
1753+
17161754
fn compile_package_simple(
17171755
build_config: MoveBuildConfig,
17181756
package_path: &Path,

crates/sui/tests/cli_tests.rs

+21
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ async fn test_ptb_publish_and_complex_arg_resolution() -> Result<(), anyhow::Err
245245
package_path: package_path.clone(),
246246
build_config,
247247
skip_dependency_verification: false,
248+
verify_deps: true,
248249
with_unpublished_dependencies: false,
249250
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
250251
}
@@ -524,6 +525,7 @@ async fn test_move_call_args_linter_command() -> Result<(), anyhow::Error> {
524525
build_config,
525526
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
526527
skip_dependency_verification: false,
528+
verify_deps: true,
527529
with_unpublished_dependencies: false,
528530
}
529531
.execute(context)
@@ -788,6 +790,7 @@ async fn test_package_publish_command() -> Result<(), anyhow::Error> {
788790
build_config,
789791
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
790792
skip_dependency_verification: false,
793+
verify_deps: true,
791794
with_unpublished_dependencies: false,
792795
}
793796
.execute(context)
@@ -858,6 +861,7 @@ async fn test_package_management_on_publish_command() -> Result<(), anyhow::Erro
858861
build_config: build_config.clone(),
859862
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
860863
skip_dependency_verification: false,
864+
verify_deps: true,
861865
with_unpublished_dependencies: false,
862866
}
863867
.execute(context)
@@ -928,6 +932,7 @@ async fn test_delete_shared_object() -> Result<(), anyhow::Error> {
928932
build_config,
929933
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
930934
skip_dependency_verification: false,
935+
verify_deps: true,
931936
with_unpublished_dependencies: false,
932937
}
933938
.execute(context)
@@ -1032,6 +1037,7 @@ async fn test_receive_argument() -> Result<(), anyhow::Error> {
10321037
build_config,
10331038
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
10341039
skip_dependency_verification: false,
1040+
verify_deps: true,
10351041
with_unpublished_dependencies: false,
10361042
}
10371043
.execute(context)
@@ -1156,6 +1162,7 @@ async fn test_receive_argument_by_immut_ref() -> Result<(), anyhow::Error> {
11561162
build_config,
11571163
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
11581164
skip_dependency_verification: false,
1165+
verify_deps: true,
11591166
with_unpublished_dependencies: false,
11601167
}
11611168
.execute(context)
@@ -1280,6 +1287,7 @@ async fn test_receive_argument_by_mut_ref() -> Result<(), anyhow::Error> {
12801287
build_config,
12811288
skip_dependency_verification: false,
12821289
with_unpublished_dependencies: false,
1290+
verify_deps: true,
12831291
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
12841292
}
12851293
.execute(context)
@@ -1406,6 +1414,7 @@ async fn test_package_publish_command_with_unpublished_dependency_succeeds(
14061414
build_config,
14071415
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
14081416
skip_dependency_verification: false,
1417+
verify_deps: true,
14091418
with_unpublished_dependencies,
14101419
}
14111420
.execute(context)
@@ -1475,6 +1484,7 @@ async fn test_package_publish_command_with_unpublished_dependency_fails(
14751484
build_config,
14761485
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
14771486
skip_dependency_verification: false,
1487+
verify_deps: true,
14781488
with_unpublished_dependencies,
14791489
}
14801490
.execute(context)
@@ -1518,6 +1528,7 @@ async fn test_package_publish_command_non_zero_unpublished_dep_fails() -> Result
15181528
build_config,
15191529
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
15201530
skip_dependency_verification: false,
1531+
verify_deps: true,
15211532
with_unpublished_dependencies,
15221533
}
15231534
.execute(context)
@@ -1570,6 +1581,7 @@ async fn test_package_publish_command_failure_invalid() -> Result<(), anyhow::Er
15701581
build_config,
15711582
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
15721583
skip_dependency_verification: false,
1584+
verify_deps: true,
15731585
with_unpublished_dependencies,
15741586
}
15751587
.execute(context)
@@ -1609,6 +1621,7 @@ async fn test_package_publish_nonexistent_dependency() -> Result<(), anyhow::Err
16091621
build_config,
16101622
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
16111623
skip_dependency_verification: false,
1624+
verify_deps: true,
16121625
with_unpublished_dependencies: false,
16131626
}
16141627
.execute(context)
@@ -1649,6 +1662,7 @@ async fn test_package_publish_test_flag() -> Result<(), anyhow::Error> {
16491662
build_config,
16501663
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
16511664
skip_dependency_verification: false,
1665+
verify_deps: true,
16521666
with_unpublished_dependencies: false,
16531667
}
16541668
.execute(context)
@@ -1701,6 +1715,7 @@ async fn test_package_upgrade_command() -> Result<(), anyhow::Error> {
17011715
build_config,
17021716
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
17031717
skip_dependency_verification: false,
1718+
verify_deps: true,
17041719
with_unpublished_dependencies: false,
17051720
}
17061721
.execute(context)
@@ -1772,6 +1787,7 @@ async fn test_package_upgrade_command() -> Result<(), anyhow::Error> {
17721787
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
17731788
verify_compatibility: true,
17741789
skip_dependency_verification: false,
1790+
verify_deps: true,
17751791
with_unpublished_dependencies: false,
17761792
}
17771793
.execute(context)
@@ -1837,6 +1853,7 @@ async fn test_package_management_on_upgrade_command() -> Result<(), anyhow::Erro
18371853
build_config: build_config.clone(),
18381854
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
18391855
skip_dependency_verification: false,
1856+
verify_deps: true,
18401857
with_unpublished_dependencies: false,
18411858
}
18421859
.execute(context)
@@ -1891,6 +1908,7 @@ async fn test_package_management_on_upgrade_command() -> Result<(), anyhow::Erro
18911908
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
18921909
verify_compatibility: true,
18931910
skip_dependency_verification: false,
1911+
verify_deps: true,
18941912
with_unpublished_dependencies: false,
18951913
}
18961914
.execute(context)
@@ -1971,6 +1989,7 @@ async fn test_package_management_on_upgrade_command_conflict() -> Result<(), any
19711989
build_config: build_config_publish.clone(),
19721990
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
19731991
skip_dependency_verification: false,
1992+
verify_deps: true,
19741993
with_unpublished_dependencies: false,
19751994
}
19761995
.execute(context)
@@ -2039,6 +2058,7 @@ async fn test_package_management_on_upgrade_command_conflict() -> Result<(), any
20392058
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
20402059
verify_compatibility: true,
20412060
skip_dependency_verification: false,
2061+
verify_deps: true,
20422062
with_unpublished_dependencies: false,
20432063
}
20442064
.execute(context)
@@ -3808,6 +3828,7 @@ async fn test_clever_errors() -> Result<(), anyhow::Error> {
38083828
package_path: package_path.clone(),
38093829
build_config,
38103830
skip_dependency_verification: false,
3831+
verify_deps: true,
38113832
with_unpublished_dependencies: false,
38123833
opts: OptsWithGas::for_testing(Some(gas_obj_id), rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
38133834
}

crates/sui/tests/shell_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async fn test_shell_snapshot(path: &Path) -> datatest_stable::Result<()> {
4848
"PATH",
4949
format!("{}:{}", get_sui_bin_path(), std::env::var("PATH")?),
5050
)
51+
.env("RUST_BACKTRACE", "0")
5152
.current_dir(sandbox)
5253
.arg(path.file_name().unwrap());
5354

crates/sui/tests/shell_tests/with_network/move_build_bytecode_with_address_resolution/move_build_bytecode_with_address_resolution.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
sui client --client.config $CONFIG \
5-
publish simple \
5+
publish simple --verify-deps \
66
--json | jq '.effects.status'
77

88
sui move --client.config $CONFIG \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This test suite checks that the deprecation warnings for dependency verification during publication and the
2+
associated flags `--skip-dependency-verification` and `--verify-deps` are working correctly.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Mysten Labs, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# test that we get an error if we supply both `--skip-dependency-verification` and `--verify-deps`
5+
6+
echo "=== publish ===" | tee /dev/stderr
7+
sui client --client.config $CONFIG publish example --skip-dependency-verification --verify-deps
8+
9+
echo "=== upgrade ===" | tee /dev/stderr
10+
sui client --client.config $CONFIG upgrade example --upgrade-capability 0x1234 --skip-dependency-verification --verify-deps
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "dependency"
3+
edition = "2024.beta"
4+
5+
[dependencies]
6+
# Sui = { local = "FRAMEWORK_DIR", override = true }
7+
8+
[addresses]
9+
dependency = "0x0"
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module dependency::dependency;
5+
6+
public fun f(): u64 { 0 }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "example"
3+
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
4+
5+
[dependencies]
6+
# Sui = { local = "FRAMEWORK_DIR" }
7+
dependency = { local = "../dependency" }
8+
9+
[addresses]
10+
example = "0x0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/// Module: example
5+
module example::example;
6+
7+
use dependency::dependency::f;
8+
9+
public fun g(): u64 { f() }

0 commit comments

Comments
 (0)