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

chore: create separate crate just for noir artifacts #5162

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
21 changes: 19 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"tooling/nargo_fmt",
"tooling/nargo_cli",
"tooling/nargo_toml",
"tooling/noirc_artifacts",
"tooling/noirc_abi",
"tooling/noirc_abi_wasm",
"tooling/acvm_cli",
Expand Down Expand Up @@ -74,6 +75,7 @@ nargo_toml = { path = "tooling/nargo_toml" }
noir_lsp = { path = "tooling/lsp" }
noir_debugger = { path = "tooling/debugger" }
noirc_abi = { path = "tooling/noirc_abi" }
noirc_artifacts = { path = "tooling/noirc_artifacts" }
bb_abstraction_leaks = { path = "tooling/bb_abstraction_leaks" }
acvm_cli = { path = "tooling/acvm_cli" }

Expand Down
1 change: 1 addition & 0 deletions compiler/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ noirc_driver.workspace = true
noirc_frontend = { workspace = true, features = ["bn254"] }
noirc_errors.workspace = true
noirc_evaluator.workspace = true
noirc_artifacts.workspace = true
wasm-bindgen.workspace = true
serde.workspace = true
js-sys.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions compiler/wasm/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use acvm::acir::circuit::ExpressionWidth;
use fm::FileManager;
use gloo_utils::format::JsValueSerdeExt;
use js_sys::{JsString, Object};
use nargo::{
artifacts::{contract::ContractArtifact, program::ProgramArtifact},
parse_all,
};
use nargo::parse_all;
use noirc_artifacts::{contract::ContractArtifact, program::ProgramArtifact};
use noirc_driver::{
add_dep, file_manager_with_stdlib, prepare_crate, prepare_dependency, CompileOptions,
};
Expand Down
1 change: 1 addition & 0 deletions tooling/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ noirc_frontend.workspace = true
noirc_printable_type.workspace = true
noirc_errors.workspace = true
noirc_driver.workspace = true
noirc_artifacts.workspace = true
thiserror.workspace = true
codespan-reporting.workspace = true
dap.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tooling/debugger/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use acvm::{BlackBoxFunctionSolver, FieldElement};

use codespan_reporting::files::{Files, SimpleFile};
use fm::FileId;
use nargo::artifacts::debug::{DebugArtifact, StackFrame};
use nargo::errors::{ExecutionError, Location};
use nargo::NargoError;
use noirc_artifacts::debug::{DebugArtifact, StackFrame};
use noirc_driver::DebugFile;

use std::collections::BTreeMap;
Expand Down
2 changes: 1 addition & 1 deletion tooling/debugger/src/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use dap::types::{
Breakpoint, DisassembledInstruction, Scope, Source, StackFrame, SteppingGranularity,
StoppedEventReason, Thread, Variable,
};
use nargo::artifacts::debug::DebugArtifact;
use noirc_artifacts::debug::DebugArtifact;

use fm::FileId;
use noirc_driver::CompiledProgram;
Expand Down
6 changes: 2 additions & 4 deletions tooling/debugger/src/foreign_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use acvm::{
pwg::ForeignCallWaitInfo,
AcirField, FieldElement,
};
use nargo::{
artifacts::debug::{DebugArtifact, DebugVars, StackFrame},
ops::{DefaultForeignCallExecutor, ForeignCallExecutor},
};
use nargo::ops::{DefaultForeignCallExecutor, ForeignCallExecutor};
use noirc_artifacts::debug::{DebugArtifact, DebugVars, StackFrame};
use noirc_errors::debug_info::{DebugFnId, DebugVarId};
use noirc_printable_type::ForeignCallError;

Expand Down
2 changes: 1 addition & 1 deletion tooling/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use acvm::acir::circuit::brillig::BrilligBytecode;
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap};
use acvm::{BlackBoxFunctionSolver, FieldElement};

use nargo::artifacts::debug::DebugArtifact;
use noirc_artifacts::debug::DebugArtifact;

use nargo::NargoError;
use noirc_driver::CompiledProgram;
Expand Down
3 changes: 2 additions & 1 deletion tooling/debugger/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use acvm::acir::circuit::{Circuit, Opcode, OpcodeLocation};
use acvm::acir::native_types::{Witness, WitnessMap};
use acvm::brillig_vm::brillig::Opcode as BrilligOpcode;
use acvm::{BlackBoxFunctionSolver, FieldElement};
use nargo::NargoError;

use crate::foreign_calls::DefaultDebugForeignCallExecutor;
use nargo::{artifacts::debug::DebugArtifact, NargoError};
use noirc_artifacts::debug::DebugArtifact;

use easy_repl::{command, CommandStatus, Repl};
use noirc_printable_type::PrintableValueDisplay;
Expand Down
4 changes: 2 additions & 2 deletions tooling/debugger/src/source_code_printer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use codespan_reporting::files::Files;
use nargo::artifacts::debug::DebugArtifact;
use noirc_artifacts::debug::DebugArtifact;
use noirc_errors::Location;
use owo_colors::OwoColorize;
use std::ops::Range;
Expand Down Expand Up @@ -224,7 +224,7 @@ mod tests {
use crate::source_code_printer::PrintedLine::Content;
use acvm::acir::circuit::OpcodeLocation;
use fm::FileManager;
use nargo::artifacts::debug::DebugArtifact;
use noirc_artifacts::debug::DebugArtifact;
use noirc_errors::{debug_info::DebugInfo, Location, Span};
use std::collections::BTreeMap;
use std::ops::Range;
Expand Down
1 change: 1 addition & 0 deletions tooling/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ nargo_toml.workspace = true
noirc_driver.workspace = true
noirc_errors.workspace = true
noirc_frontend.workspace = true
noirc_artifacts.workspace = true
serde.workspace = true
serde_json.workspace = true
tower.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions tooling/lsp/src/requests/profile_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ use std::{

use acvm::acir::circuit::ExpressionWidth;
use async_lsp::{ErrorCode, ResponseError};
use nargo::{
artifacts::debug::DebugArtifact, insert_all_files_for_workspace_into_file_manager,
ops::report_errors,
};
use nargo::{insert_all_files_for_workspace_into_file_manager, ops::report_errors};
use nargo_toml::{find_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_artifacts::debug::DebugArtifact;
use noirc_driver::{
file_manager_with_stdlib, CompileOptions, DebugFile, NOIR_ARTIFACT_VERSION_STRING,
};
Expand Down
2 changes: 0 additions & 2 deletions tooling/nargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ noirc_errors.workspace = true
noirc_frontend.workspace = true
noirc_printable_type.workspace = true
iter-extended.workspace = true
serde.workspace = true
thiserror.workspace = true
codespan-reporting.workspace = true
tracing.workspace = true
rayon = "1.8.0"
jsonrpc.workspace = true
Expand Down
1 change: 0 additions & 1 deletion tooling/nargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//! This name was used because it sounds like `cargo` and
//! Noir Package Manager abbreviated is npm, which is already taken.

pub mod artifacts;
pub mod constants;
pub mod errors;
pub mod ops;
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ noirc_driver.workspace = true
noirc_frontend = { workspace = true, features = ["bn254"] }
noirc_abi.workspace = true
noirc_errors.workspace = true
noirc_artifacts.workspace = true
acvm = { workspace = true, features = ["bn254"] }
bn254_blackbox_solver.workspace = true
toml.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::path::Path;
use std::time::Duration;

use fm::FileManager;
use nargo::artifacts::program::ProgramArtifact;
use nargo::ops::{collect_errors, compile_contract, compile_program, report_errors};
use nargo::package::Package;
use nargo::workspace::Workspace;
use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_artifacts::program::ProgramArtifact;
use noirc_driver::file_manager_with_stdlib;
use noirc_driver::NOIR_ARTIFACT_VERSION_STRING;
use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, CompiledProgram};
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/debug_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;

use fm::FileManager;
use nargo::artifacts::debug::DebugArtifact;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::errors::CompileError;
use nargo::ops::{compile_program, compile_program_with_debug_instrumenter, report_errors};
Expand All @@ -16,6 +15,7 @@ use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::input_parser::{Format, InputValue};
use noirc_abi::InputMap;
use noirc_artifacts::debug::DebugArtifact;
use noirc_driver::{
file_manager_with_stdlib, CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING,
};
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use acvm::FieldElement;
use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;

use nargo::artifacts::debug::DebugArtifact;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::errors::try_to_diagnose_runtime_error;
use nargo::ops::DefaultForeignCallExecutor;
use nargo::package::Package;
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::input_parser::{Format, InputValue};
use noirc_abi::InputMap;
use noirc_artifacts::debug::DebugArtifact;
use noirc_driver::{CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING};
use noirc_frontend::graph::CrateName;

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/fs/program.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};

use nargo::artifacts::{contract::ContractArtifact, program::ProgramArtifact};
use noirc_artifacts::{contract::ContractArtifact, program::ProgramArtifact};
use noirc_frontend::graph::CrateName;

use crate::errors::FilesystemError;
Expand Down
6 changes: 2 additions & 4 deletions tooling/nargo_cli/src/cli/info_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use std::collections::HashMap;
use acvm::acir::circuit::ExpressionWidth;
use clap::Args;
use iter_extended::vecmap;
use nargo::{
artifacts::{debug::DebugArtifact, program::ProgramArtifact},
package::Package,
};
use nargo::package::Package;
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_artifacts::{debug::DebugArtifact, program::ProgramArtifact};
use noirc_driver::{CompileOptions, NOIR_ARTIFACT_VERSION_STRING};
use noirc_errors::{debug_info::OpCodesCount, Location};
use noirc_frontend::graph::CrateName;
Expand Down
24 changes: 24 additions & 0 deletions tooling/noirc_artifacts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "noirc_artifacts"
description = "Definitions of Nargo's build artifacts"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
acvm.workspace = true
fm.workspace = true
noirc_abi.workspace = true
noirc_driver.workspace = true
noirc_errors.workspace = true
noirc_printable_type.workspace = true
serde.workspace = true
codespan-reporting.workspace = true


[dev-dependencies]
tempfile.workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<'a> Files<'a> for DebugArtifact {

#[cfg(test)]
mod tests {
use crate::artifacts::debug::DebugArtifact;
use crate::debug::DebugArtifact;
use acvm::acir::circuit::OpcodeLocation;
use fm::FileManager;
use noirc_errors::{debug_info::DebugInfo, Location, Span};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#![forbid(unsafe_code)]
#![warn(unused_crate_dependencies, unused_extern_crates)]
#![warn(unreachable_pub)]
#![warn(clippy::semicolon_if_nothing_returned)]

//! This module defines the structure of Nargo's different compilation artifacts.
//!
//! These artifacts are intended to remain independent of any applications being built on top of Noir.
//! Should any projects require/desire a different artifact format, it's expected that they will write a transformer
//! to generate them using these artifacts as a starting point.

pub mod contract;
pub mod debug;
mod debug_vars;
Expand Down
Loading