Skip to content

Commit abc154c

Browse files
committed
fix(deploy): detect edition mismatch in workspace remote dep dedup
Change remote dep dedup from HashSet to HashMap<ProgramID, Option<u16>> so that if two workspace members reference the same remote dependency with different editions, an error is raised instead of silently keeping the first. Add a comment on `already_deployed` explaining why ProgramID-only dedup is safe there (local programs have no edition).
1 parent 38687ec commit abc154c

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

crates/leo/src/cli/commands/deploy.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ use snarkvm::{
5454

5555
use colored::*;
5656
use itertools::Itertools;
57-
use std::{collections::HashSet, fs, path::PathBuf};
57+
use std::{
58+
collections::{HashMap, HashSet},
59+
fs,
60+
path::PathBuf,
61+
};
5862

5963
/// Deploys an Aleo program.
6064
#[derive(Parser, Debug)]
@@ -676,13 +680,28 @@ fn handle_workspace_deploy_inner<N: Network, A: Aleo<Network = N>>(
676680
// Prepare tasks for all members, deduplicating remote deps.
677681
let mut member_tasks: Vec<MemberTasks<N>> = Vec::new();
678682
let mut all_remote: Vec<Task<N>> = Vec::new();
679-
let mut seen_remote_ids: HashSet<ProgramID<N>> = HashSet::new();
683+
let mut seen_remote: HashMap<ProgramID<N>, Option<u16>> = HashMap::new();
680684

681685
for (name, package) in &packages {
682686
let (local, remote, skipped) = prepare_package_tasks::<N>(command, &setup, package)?;
683687
for task in remote {
684-
if seen_remote_ids.insert(task.id) {
685-
all_remote.push(task);
688+
match seen_remote.entry(task.id) {
689+
std::collections::hash_map::Entry::Vacant(e) => {
690+
e.insert(task.edition);
691+
all_remote.push(task);
692+
}
693+
std::collections::hash_map::Entry::Occupied(e) => {
694+
if *e.get() != task.edition {
695+
return Err(crate::errors::custom(format!(
696+
"Workspace members disagree on edition for remote dependency '{}': \
697+
{:?} vs {:?}. Ensure all members specify the same edition.",
698+
task.id,
699+
e.get(),
700+
task.edition,
701+
))
702+
.into());
703+
}
704+
}
686705
}
687706
}
688707
member_tasks.push((name.clone(), local, skipped));
@@ -713,6 +732,8 @@ fn handle_workspace_deploy_inner<N: Network, A: Aleo<Network = N>>(
713732
load_remote_deps(command, &setup, all_remote)?;
714733

715734
// Deploy each member's programs in dependency order with shared VM.
735+
// Edition mismatch is not a concern here: `already_deployed` only tracks
736+
// local programs, which all have `edition: None`.
716737
let mut already_deployed: HashSet<ProgramID<N>> = HashSet::new();
717738
let mut all_transactions = Vec::new();
718739
let mut all_stats = Vec::new();

0 commit comments

Comments
 (0)