Skip to content

Commit

Permalink
chore: version mismatch warnings for artifacts (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto authored Jan 6, 2025
1 parent e86caca commit 03aefb8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@ impl GraphWitness {
})?;

let reader = std::io::BufReader::with_capacity(*EZKL_BUF_CAPACITY, file);
serde_json::from_reader(reader).map_err(|e| e.into())
let witness: GraphWitness =
serde_json::from_reader(reader).map_err(|e| Into::<GraphError>::into(e))?;

// check versions match
crate::check_version_string_matches(witness.version.as_deref().unwrap_or(""));

Ok(witness)
}

/// Save the model input to a file
Expand Down Expand Up @@ -572,10 +578,14 @@ impl GraphSettings {
// buf reader
let reader =
std::io::BufReader::with_capacity(*EZKL_BUF_CAPACITY, std::fs::File::open(path)?);
serde_json::from_reader(reader).map_err(|e| {
let settings: GraphSettings = serde_json::from_reader(reader).map_err(|e| {
error!("failed to load settings file at {}", e);
std::io::Error::new(std::io::ErrorKind::Other, e)
})
})?;

crate::check_version_string_matches(&settings.version);

Ok(settings)
}

/// Export the ezkl configuration as json
Expand Down Expand Up @@ -697,6 +707,9 @@ impl GraphCircuit {
let reader = std::io::BufReader::with_capacity(*EZKL_BUF_CAPACITY, f);
let result: GraphCircuit = bincode::deserialize_from(reader)?;

// check the versions matche
crate::check_version_string_matches(&result.core.settings.version);

Ok(result)
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,30 @@ where
let b = s[pos + 2..].parse()?;
Ok((a, b))
}

/// Check if the version string matches the artifact version
/// If the version string does not match the artifact version, log a warning
pub fn check_version_string_matches(artifact_version: &str) {
if artifact_version == "0.0.0"
|| artifact_version == "source - no compatibility guaranteed"
|| artifact_version.is_empty()
{
log::warn!("Artifact version is 0.0.0, skipping version check");
return;
}

let version = crate::version();

if version == "source - no compatibility guaranteed" {
log::warn!("Compiled source version is not guaranteed to match artifact version");
return;
}

if version != artifact_version {
log::warn!(
"Version mismatch: CLI version is {} but artifact version is {}",
version,
artifact_version
);
}
}

0 comments on commit 03aefb8

Please sign in to comment.