Skip to content

Commit

Permalink
chore: Add spellchecker (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray authored Feb 3, 2023
1 parent b0a9695 commit 126ca26
Show file tree
Hide file tree
Showing 57 changed files with 723 additions and 618 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,14 @@ jobs:
with:
command: fmt
args: --all -- --check

spellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: streetsidesoftware/cspell-action@v2
with:
files: |
**/*.{md,rs}
incremental_files_only : true # Run this action on files which have changed in PR
strict: false # Do not fail, if a spelling mistake is found (This can be annoying for contributors)
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Before you create a pull request, create an issue that thoroughly describes the

Noir is still very new and there are many cryptographic primitives that we have yet to build that will be useful for the community. If you have other ideas, please reach out on the [Aztec Discord](https://discord.gg/aztec) to discuss. You can find the current list of requested primitives in the [issues section](https://github.com/noir-lang/noir/labels/noir-stdlib) marked with the label `noir-stdlib`.

## Funding Opportunties
## Funding Opportunities

Aztec is offering grants to people and teams that want to use, test or build Noir. You can find more information about the grants program [here](https://aztec.network/grants).

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default-members = ["crates/nargo"]

[workspace.package]
version = "0.1.0"
authors = ["Kevaundray Wedderburn <[email protected]>"]
authors = ["The Noir Team <[email protected]>"]
edition = "2021"
rust-version = "1.64"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ The current focus is to gather as much feedback as possible while in the alpha p

Concretely the following items are on the road map:

- General code sanitisation and documentation (ongoing effort)
- Prover and Verifier Key logic. (Prover and Verifier preprocess per compile)
- General code sanitization and documentation (ongoing effort)
- Prover and Verifier Key logic. (Prover and Verifier pre-process per compile)
- Fallback mechanism for backend unsupported opcodes
- Visibility modifiers
- Signed integers
Expand Down
4 changes: 2 additions & 2 deletions crates/fm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl FileManager {
let source = file_reader::read_file_to_string(path_to_file).ok()?;

let file_id = self.file_map.add_file(path_to_file.to_path_buf().into(), source);
let path_to_file = virtualise_path(path_to_file, file_type);
let path_to_file = virtualize_path(path_to_file, file_type);
self.register_path(file_id, path_to_file);

Some(file_id)
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Default for FileManager {
/// Returns
/// For Normal filetypes, given "src/mod.nr" this method returns "src/mod"
/// For Root filetypes, given "src/mod.nr" this method returns "src"
fn virtualise_path(path: &Path, file_type: FileType) -> VirtualPath {
fn virtualize_path(path: &Path, file_type: FileType) -> VirtualPath {
let mut path = path.to_path_buf();
let path = match file_type {
FileType::Root => {
Expand Down
4 changes: 2 additions & 2 deletions crates/nargo/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> {
let witness = args.is_present("witness");
let allow_warnings = args.is_present("allow-warnings");

let curr_dir = std::env::current_dir().unwrap();
let current_dir = std::env::current_dir().unwrap();
let mut circuit_path = PathBuf::new();
circuit_path.push(TARGET_DIR);

let result = generate_circuit_and_witness_to_disk(
circuit_name,
curr_dir,
current_dir,
circuit_path,
witness,
allow_warnings,
Expand Down
4 changes: 2 additions & 2 deletions crates/nargo/src/cli/gates_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> {
}

pub fn count_gates(show_ssa: bool, allow_warnings: bool) -> Result<(), CliError> {
let curr_dir = std::env::current_dir().unwrap();
count_gates_with_path(curr_dir, show_ssa, allow_warnings)
let current_dir = std::env::current_dir().unwrap();
count_gates_with_path(current_dir, show_ssa, allow_warnings)
}

pub fn count_gates_with_path<P: AsRef<Path>>(
Expand Down
6 changes: 3 additions & 3 deletions crates/nargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn start_cli() {
let matches = App::new("nargo")
.about("Noir's package manager")
.version(VERSION_STRING)
.author("Kevaundray Wedderburn <[email protected]>")
.author("The Noir Team <[email protected]>")
.subcommand(
App::new("check")
.about("Checks the constraint system for errors")
Expand Down Expand Up @@ -89,7 +89,7 @@ pub fn start_cli() {
)
.subcommand(
App::new("gates")
.about("Counts the occurences of different gates in circuit")
.about("Counts the occurrences of different gates in circuit")
.arg(show_ssa)
.arg(allow_warnings),
)
Expand Down Expand Up @@ -170,7 +170,7 @@ fn write_inputs_to_file<P: AsRef<Path>>(
dir_path
};

let serialized_output = format.serialise(w_map)?;
let serialized_output = format.serialize(w_map)?;
write_to_file(serialized_output.as_bytes(), &file_path);

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/nargo/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> {
const WITNESS_OFFSET: u32 = 1;

fn prove(proof_name: Option<&str>, show_ssa: bool, allow_warnings: bool) -> Result<(), CliError> {
let curr_dir = std::env::current_dir().unwrap();
let current_dir = std::env::current_dir().unwrap();

let mut proof_dir = PathBuf::new();
proof_dir.push(PROOFS_DIR);

prove_with_path(proof_name, curr_dir, proof_dir, show_ssa, allow_warnings)?;
prove_with_path(proof_name, current_dir, proof_dir, show_ssa, allow_warnings)?;

Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/nargo/src/cli/verify_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> {
}

fn verify(proof_name: &str, allow_warnings: bool) -> Result<bool, CliError> {
let curr_dir = std::env::current_dir().unwrap();
let current_dir = std::env::current_dir().unwrap();
let mut proof_path = PathBuf::new(); //or cur_dir?
proof_path.push(PROOFS_DIR);
proof_path.push(Path::new(proof_name));
proof_path.set_extension(PROOF_EXT);
verify_with_path(&curr_dir, &proof_path, false, allow_warnings)
verify_with_path(&current_dir, &proof_path, false, allow_warnings)
}

pub fn verify_with_path<P: AsRef<Path>>(
Expand All @@ -50,9 +50,9 @@ pub fn verify_with_path<P: AsRef<Path>>(
let public_abi = compiled_program.abi.clone().unwrap().public_abi();
let num_pub_params = public_abi.num_parameters();
if num_pub_params != 0 {
let curr_dir = program_dir;
let current_dir = program_dir;
public_inputs =
read_inputs_from_file(curr_dir, VERIFIER_INPUT_FILE, Format::Toml, public_abi)?;
read_inputs_from_file(current_dir, VERIFIER_INPUT_FILE, Format::Toml, public_abi)?;
}

let valid_proof = verify_proof(compiled_program, public_inputs, load_proof(proof_path)?)?;
Expand Down
26 changes: 13 additions & 13 deletions crates/nargo/tests/prove_and_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@ mod tests {

#[test]
fn noir_integration() {
let mut cdir = std::env::current_dir().unwrap();
cdir.push(TEST_DIR);
cdir.push(TEST_DATA_DIR);
let mut current_dir = std::env::current_dir().unwrap();
current_dir.push(TEST_DIR);
current_dir.push(TEST_DATA_DIR);

//load config.tml file from test_data directory
cdir.push(CONFIG_FILE);
let config_path = std::fs::read_to_string(cdir).unwrap();
let conf_data: BTreeMap<String, Vec<String>> = load_conf(&config_path);
let mut cdir = std::env::current_dir().unwrap();
cdir.push(TEST_DIR);
cdir.push(TEST_DATA_DIR);
current_dir.push(CONFIG_FILE);
let config_path = std::fs::read_to_string(current_dir).unwrap();
let config_data: BTreeMap<String, Vec<String>> = load_conf(&config_path);
let mut current_dir = std::env::current_dir().unwrap();
current_dir.push(TEST_DIR);
current_dir.push(TEST_DATA_DIR);

for c in fs::read_dir(cdir.as_path()).unwrap().flatten() {
for c in fs::read_dir(current_dir.as_path()).unwrap().flatten() {
if let Ok(test_name) = c.file_name().into_string() {
println!("Running test {test_name:?}");
if c.path().is_dir() && !conf_data["exclude"].contains(&test_name) {
if c.path().is_dir() && !config_data["exclude"].contains(&test_name) {
let verified = std::panic::catch_unwind(|| {
nargo::cli::prove_and_verify("pp", &c.path(), false)
});

let r = match verified {
Ok(result) => result,
Err(_) => {
panic!("\n\n\nPanic occured while running test {:?} (ignore the following panic)", c.file_name());
panic!("\n\n\nPanic occurred while running test {:?} (ignore the following panic)", c.file_name());
}
};

if conf_data["fail"].contains(&test_name) {
if config_data["fail"].contains(&test_name) {
assert!(!r, "{:?} should not succeed", c.file_name());
} else {
assert!(r, "verification fail for {:?}", c.file_name());
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/tests/test_data/range_fail/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Multiple integers constraints.
//
// There is currently no range optimiser currently in ACIR :(
// There is currently no range optimizer currently in ACIR :(
//
fn main(x: u8, y: Field) {
let _z = x + (y as u8);
Expand Down
4 changes: 2 additions & 2 deletions crates/noirc_abi/src/input_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ impl Format {
}
}

pub fn serialise(
pub fn serialize(
&self,
w_map: &BTreeMap<String, InputValue>,
) -> Result<String, InputParserError> {
match self {
Format::Toml => toml::serialise_to_toml(w_map),
Format::Toml => toml::serialize_to_toml(w_map),
}
}
}
2 changes: 1 addition & 1 deletion crates/noirc_abi/src/input_parser/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn parse_toml(
})
}

pub(crate) fn serialise_to_toml(
pub(crate) fn serialize_to_toml(
w_map: &BTreeMap<String, InputValue>,
) -> Result<String, InputParserError> {
// Toml requires that values be emitted before tables. Thus, we must reorder our map in case a TomlTypes::Table comes before any other values in the toml map
Expand Down
12 changes: 6 additions & 6 deletions crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use noirc_evaluator::create_circuit;
use noirc_frontend::graph::{CrateId, CrateName, CrateType, LOCAL_CRATE};
use noirc_frontend::hir::def_map::CrateDefMap;
use noirc_frontend::hir::Context;
use noirc_frontend::monomorphisation::monomorphise;
use noirc_frontend::monomorphization::monomorphize;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -127,12 +127,12 @@ impl Driver {
}

// NOTE: Maybe build could be skipped given that now it is a pass through method.
/// Statically analyses the local crate
/// Statically analyzes the local crate
pub fn check(&mut self, allow_warnings: bool) {
self.analyse_crate(allow_warnings)
self.analyze_crate(allow_warnings)
}

fn analyse_crate(&mut self, allow_warnings: bool) {
fn analyze_crate(&mut self, allow_warnings: bool) {
let mut errs = vec![];
CrateDefMap::collect_defs(LOCAL_CRATE, &mut self.context, &mut errs);
let mut error_count = 0;
Expand Down Expand Up @@ -187,7 +187,7 @@ impl Driver {
let func_meta = self.context.def_interner.function_meta(&main_function);
let abi = func_meta.into_abi(&self.context.def_interner);

let program = monomorphise(main_function, self.context.def_interner);
let program = monomorphize(main_function, self.context.def_interner);

// Compile Program
let circuit = match create_circuit(
Expand All @@ -199,7 +199,7 @@ impl Driver {
Ok(circuit) => circuit,
Err(err) => {
// The FileId here will be the file id of the file with the main file
// Errors will be shown at the callsite without a stacktrace
// Errors will be shown at the call site without a stacktrace
let file_id = err.location.map(|loc| loc.file);
let error_count = Reporter::with_diagnostics(
file_id,
Expand Down
8 changes: 4 additions & 4 deletions crates/noirc_driver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ fn main() {
driver.create_local_crate(ROOT_DIR_MAIN, CrateType::Binary);

// Add libraries into Driver
let ncrate_id1 = driver.create_non_local_crate(EXTERNAL_DIR2, CrateType::Library);
let ncrate_id2 = driver.create_non_local_crate(EXTERNAL_DIR, CrateType::Library);
let crate_id1 = driver.create_non_local_crate(EXTERNAL_DIR2, CrateType::Library);
let crate_id2 = driver.create_non_local_crate(EXTERNAL_DIR, CrateType::Library);

// Add dependencies as package
driver.add_dep(LOCAL_CRATE, ncrate_id1, "coo4");
driver.add_dep(LOCAL_CRATE, ncrate_id2, "coo3");
driver.add_dep(LOCAL_CRATE, crate_id1, "coo4");
driver.add_dep(LOCAL_CRATE, crate_id2, "coo3");

driver.into_compiled_program(acvm::Language::R1CS, false, false);
}
Loading

0 comments on commit 126ca26

Please sign in to comment.