From a0a19cd989cdb36d3cb895a678c2cfc2987e2fca Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 11 Feb 2026 13:08:26 -0500 Subject: [PATCH 1/3] fix(contract build): Add `--frozen` to ensure deterministic builds --- cmd/soroban-cli/src/commands/contract/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soroban-cli/src/commands/contract/build.rs b/cmd/soroban-cli/src/commands/contract/build.rs index e588258e3..264ad1f1a 100644 --- a/cmd/soroban-cli/src/commands/contract/build.rs +++ b/cmd/soroban-cli/src/commands/contract/build.rs @@ -233,6 +233,7 @@ impl Cmd { let mut cmd = Command::new("cargo"); cmd.stdout(Stdio::piped()); cmd.arg("rustc"); + cmd.arg("--frozen"); let manifest_path = pathdiff::diff_paths(&p.manifest_path, &working_dir) .unwrap_or(p.manifest_path.clone().into()); cmd.arg(format!( From ab35ab27b4ad97dd57f97055cff4fafa340f058d Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 11 Feb 2026 13:16:31 -0500 Subject: [PATCH 2/3] fix: use locked instead Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmd/soroban-cli/src/commands/contract/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/build.rs b/cmd/soroban-cli/src/commands/contract/build.rs index 264ad1f1a..01870bea2 100644 --- a/cmd/soroban-cli/src/commands/contract/build.rs +++ b/cmd/soroban-cli/src/commands/contract/build.rs @@ -233,7 +233,7 @@ impl Cmd { let mut cmd = Command::new("cargo"); cmd.stdout(Stdio::piped()); cmd.arg("rustc"); - cmd.arg("--frozen"); + cmd.arg("--locked"); let manifest_path = pathdiff::diff_paths(&p.manifest_path, &working_dir) .unwrap_or(p.manifest_path.clone().into()); cmd.arg(format!( From 2508e12208122020711bafe2c77e600938cc204d Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 11 Feb 2026 15:12:57 -0500 Subject: [PATCH 3/3] feat(contract-build): add `--locked` arg --- cmd/crates/soroban-test/tests/it/build.rs | 18 ++++++++++++++++++ cmd/soroban-cli/src/commands/contract/build.rs | 9 ++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cmd/crates/soroban-test/tests/it/build.rs b/cmd/crates/soroban-test/tests/it/build.rs index f9046615d..5f29c008f 100644 --- a/cmd/crates/soroban-test/tests/it/build.rs +++ b/cmd/crates/soroban-test/tests/it/build.rs @@ -69,6 +69,24 @@ fn build_package_by_current_dir() { )); } +#[test] +fn build_with_locked() { + let sandbox = TestEnv::default(); + let cargo_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let fixture_path = cargo_dir.join("tests/fixtures/workspace/contracts/add"); + sandbox + .new_assert_cmd("contract") + .current_dir(fixture_path) + .arg("build") + .arg("--print-commands-only") + .arg("--locked") + .assert() + .success() + .stdout(predicate::eq( + with_flags("cargo rustc --locked --manifest-path=Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release"), + )); +} + #[test] fn build_no_package_found() { let sandbox = TestEnv::default(); diff --git a/cmd/soroban-cli/src/commands/contract/build.rs b/cmd/soroban-cli/src/commands/contract/build.rs index 01870bea2..27df7e140 100644 --- a/cmd/soroban-cli/src/commands/contract/build.rs +++ b/cmd/soroban-cli/src/commands/contract/build.rs @@ -88,6 +88,10 @@ pub struct Cmd { #[arg(long)] pub out_dir: Option, + /// Assert that `Cargo.lock` will remain unchanged + #[arg(long)] + pub locked: bool, + /// Print commands to build without executing them #[arg(long, conflicts_with = "out_dir", help_heading = "Other")] pub print_commands_only: bool, @@ -197,6 +201,7 @@ impl Default for Cmd { all_features: false, no_default_features: false, out_dir: None, + locked: false, print_commands_only: false, build_args: BuildArgs::default(), } @@ -233,7 +238,9 @@ impl Cmd { let mut cmd = Command::new("cargo"); cmd.stdout(Stdio::piped()); cmd.arg("rustc"); - cmd.arg("--locked"); + if self.locked { + cmd.arg("--locked"); + } let manifest_path = pathdiff::diff_paths(&p.manifest_path, &working_dir) .unwrap_or(p.manifest_path.clone().into()); cmd.arg(format!(