Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: recompile artefacts from a different noir version #3248

Merged
merged 19 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,12 @@ pub fn compile_no_check(

let file_map = filter_relevant_files(&[debug.clone()], &context.file_manager);

Ok(CompiledProgram { hash, circuit, debug, abi, file_map })
Ok(CompiledProgram {
hash,
circuit,
debug,
abi,
file_map,
noir_version: env!("CARGO_PKG_VERSION").to_string(),
})
}
1 change: 1 addition & 0 deletions compiler/noirc_driver/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct CompiledProgram {
#[serde(serialize_with = "serialize_circuit", deserialize_with = "deserialize_circuit")]
pub circuit: Circuit,
pub abi: noirc_abi::Abi,
pub noir_version: String,
pub debug: DebugInfo,
pub file_map: BTreeMap<FileId, DebugFile>,
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/wasm/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use crate::errors::JsCompileError;

const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg";

const NOIR_ARTIFACT_VERSION_STRING: &str =
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
concat!(env!("CARGO_PKG_VERSION"), "-", env!("GIT_COMMIT"));

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Array, js_name = "StringArray", typescript_type = "string[]")]
Expand Down Expand Up @@ -118,6 +121,7 @@ fn preprocess_program(program: CompiledProgram) -> PreprocessedProgram {
hash: program.hash,
backend: String::from(BACKEND_IDENTIFIER),
abi: program.abi,
noir_version: String::from(NOIR_ARTIFACT_VERSION_STRING),
bytecode: program.circuit,
}
}
Expand All @@ -136,6 +140,7 @@ fn preprocess_contract(contract: CompiledContract) -> PreprocessedContract {
.collect();

PreprocessedContract {
noir_version: String::from(NOIR_ARTIFACT_VERSION_STRING),
name: contract.name,
backend: String::from(BACKEND_IDENTIFIER),
functions: preprocessed_functions,
Expand Down
1 change: 1 addition & 0 deletions ex/noir-trie-proofs
guipublic marked this conversation as resolved.
Show resolved Hide resolved
Submodule noir-trie-proofs added at ef66f4
2 changes: 2 additions & 0 deletions tooling/nargo/src/artifacts/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize};
/// - Proving and verification keys have been pregenerated based on this ACIR.
#[derive(Serialize, Deserialize)]
pub struct PreprocessedContract {
/// Version of noir used to compile this contract
pub noir_version: String,
/// The name of the contract.
pub name: String,
/// The identifier of the proving backend which this contract has been compiled for.
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo/src/artifacts/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct PreprocessedProgram {

pub backend: String,
pub abi: Abi,
pub noir_version: String,

#[serde(
serialize_with = "super::serialize_circuit",
Expand Down
9 changes: 8 additions & 1 deletion tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use super::fs::program::{
save_debug_artifact_to_file, save_program_to_file,
};
use super::NargoConfig;
use super::NOIR_ARTIFACT_VERSION_STRING;
use rayon::prelude::*;

// TODO(#1388): pull this from backend.
Expand Down Expand Up @@ -183,19 +184,23 @@ fn compile_program(
hash: preprocessed_program.hash,
circuit: preprocessed_program.bytecode,
abi: preprocessed_program.abi,
noir_version: preprocessed_program.noir_version,
debug: debug_artifact.debug_symbols.remove(0),
file_map: debug_artifact.file_map,
})
} else {
None
};

// If we want to output the debug information then we need to perform a full recompilation of the ACIR.
let force_recompile =
cached_program.as_ref().map_or(false, |p| p.noir_version != NOIR_ARTIFACT_VERSION_STRING);
let (program, warnings) = match noirc_driver::compile_main(
&mut context,
crate_id,
compile_options,
cached_program,
false,
force_recompile,
) {
Ok(program_and_warnings) => program_and_warnings,
Err(errors) => {
Expand Down Expand Up @@ -241,6 +246,7 @@ fn save_program(program: CompiledProgram, package: &Package, circuit_dir: &Path)
hash: program.hash,
backend: String::from(BACKEND_IDENTIFIER),
abi: program.abi,
noir_version: String::from(NOIR_ARTIFACT_VERSION_STRING),
bytecode: program.circuit,
};

Expand Down Expand Up @@ -271,6 +277,7 @@ fn save_contract(contract: CompiledContract, package: &Package, circuit_dir: &Pa
});

let preprocessed_contract = PreprocessedContract {
noir_version: String::from(NOIR_ARTIFACT_VERSION_STRING),
name: contract.name,
backend: String::from(BACKEND_IDENTIFIER),
functions: preprocessed_functions,
Expand Down
4 changes: 4 additions & 0 deletions tooling/nargo_cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const GIT_HASH: &str = env!("GIT_COMMIT");
const IS_DIRTY: &str = env!("GIT_DIRTY");
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

/// Version string that gets placed in artifacts that Noir builds
pub(crate) const NOIR_ARTIFACT_VERSION_STRING: &str =
concat!(env!("CARGO_PKG_VERSION"), "-", env!("GIT_COMMIT"));

static VERSION_STRING: &str =
formatcp!("{} (git version hash: {}, is dirty: {})", CARGO_PKG_VERSION, GIT_HASH, IS_DIRTY);

Expand Down
Loading