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!: Allow lowercase field type #3631

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

kevaundray
Copy link
Contributor

Description

Related to #3535 . This is breaking for users who were using field as a variable or strruct name previously.

This is not breaking for all users because we still allow the uppercase variant. The formatter should rename this to lower case variant and overtime, I expect we can whean out the uppercase variant.

Problem*

Resolves

Summary*

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@kevaundray
Copy link
Contributor Author

This is also breaking for files named field.nr since to import them you need to do something like crate::field

kevaundray and others added 6 commits November 29, 2023 15:24
* master:
  chore(docs): address visibility issues in docs (#3643)
  chore: type formatting (#3618)
  fix: Restrict fill_internal_slices pass to acir functions (#3634)
  chore(docs): docs for v0.19.4 (#3601)
  feat: aztec-packages (#3626)
  chore: Move tests to the correct root (#3633)
  feat: Implement integer printing (#3577)
  fix: corrected the formatting of error message parameters in index out of bounds error (#3630)
  chore: Update ACIR artifacts (#3619)
  chore(debugger): Run debugger REPL in thread (#3611)
  chore: remove deprecated method (#3625)
@kevaundray
Copy link
Contributor Author

@TomAFrench given that we can see the changes needed and its potential ramifications, what are your thoughts on this?

@TomAFrench
Copy link
Member

TomAFrench commented Nov 30, 2023

I think it's an ok change from the user's perspective. It's very unlikely that people are directly importing dep::std::field as that's only necessary for the field modulus functions, not the to_be_bytes, etc. That's the main breaking change imo.

I'm good with merging this and just having Field get autoformatted into field over time. Although there's a bunch of remaining instances of Field which we would want to change in the compiler before merging this.

I think we can let this PR sit for a little bit as there's no rush.

@kevaundray
Copy link
Contributor Author

I think it's an ok change from the user's perspective. It's very unlikely that people are directly importing dep::std::field as that's only necessary for the field modulus functions, not the to_be_bytes, etc. That's the main breaking change imo.

I'm good with merging this and just having Field get autoformatted into field over time. Although there's a bunch of remaining instances of Field which we would want to change in the compiler before merging this.

I think we can let this PR sit for a little bit as there's no rush.

That sounds reasonable and good to me!

@kevaundray
Copy link
Contributor Author

@TomAFrench should we rip this bandaid off?

@TomAFrench
Copy link
Member

Yeah, I think so.

* master: (440 commits)
  chore: remove duplicate `parse_all` function in wasm compiler (#4411)
  chore(ci): prevent msrv checks from blocking PRs (#4414)
  feat: expose separate functions to compile programs vs contracts in `noir_wasm` (#4413)
  chore: do not panic when dividing by zero (#4424)
  chore: remove unwanted prints (#4419)
  fix: remove print from monomorphization pass (#4417)
  chore(ssa): Remove mem2reg run before flattening (#4415)
  feat: Add HashMap to the stdlib (#4242)
  fix!: Ban Fields in for loop indices and bitwise ops (#4376)
  chore: Add #[recursive] Explainer to Documentation (#4399)
  feat(ci): Use wasm-opt when compiling wasm packages (#4334)
  fix: add handling to `noir_wasm` for projects without dependencies (#4344)
  chore: rename parameter 'filter' to 'level' in 'init_log_level' (#4403)
  chore!: bump msrv to 1.73.0 (#4406)
  chore: fix docker test workflows (#4308)
  chore: Update Vec docs (#4400)
  feat: update error message when trying to load workspace as dependency (#4393)
  chore: bump webpack dependencies (#4346)
  fix: correct invalid brillig codegen for `EmbeddedCurvePoint.add` (#4382)
  chore: remove dependency on generational-arena (#4207)
  ...
@TomAFrench
Copy link
Member

Let's do this after #4422 however so we can switch this repo over to using lowercase fields consistently though.

kevaundray and others added 6 commits February 26, 2024 16:30
* master:
  feat: add poseidon2 opcode implementation for acvm/brillig, and Noir (#4398)
  fix: remove panic when generic array length is not resolvable (#4408)
  chore(ci): enforce formatting of noir code in CI (#4422)
* master:
  feat: Sync from aztec-packages (#4438)
  chore(docs): correct 'Edit this page' URL for dev docs (#4433)
  feat: Sync from aztec-packages (#4390)
  chore(docs): fix external contributor force push workflow (#4437)
  chore!: Remove empty value from bounded vec (#4431)
  chore: nargo fmt (#4434)
* master: (144 commits)
  fix: correct ICE panic messages in brillig `convert_black_box_call` (#4761)
  chore(docs): Fix link in the Data Types page (#4527)
  chore(doc): Fix broken docs links (#4606)
  chore: Remove the old Value struct from the oracle docs (#4738)
  feat(nargo): Multiple circuits info for binary programs (#4719)
  chore: update condition for clearing warning comment on release PRs (#4739)
  chore(ci): fix cutting new versions of the docs (#4737)
  chore(ci): replace `yarn build:js:only` script (#4735)
  chore: update JS publish workflow to upload build artifacts correctly. (#4734)
  feat: add `remove_enable_side_effects` SSA pass (#4224)
  chore: update from vulnerable version of h2 (#4714)
  chore(ci): stop updating version list before cutting new docs version (#4726)
  chore: remove `FunctionInput::dummy` (#4723)
  chore: remove docker CI flow (#4724)
  fix: unknown slice lengths coming from as_slice (#4725)
  chore: remove unused env vars from `Cross.toml` (#4717)
  feat: improve nargo check cli with --override flag and feedback for existing files (#4575)
  feat: Allow slices to brillig entry points (#4713)
  chore: simplify how `acvm_backend.wasm` is embedded (#4703)
  fix(acvm): Mark outputs of Opcode::Call solvable (#4708)
  ...
* master: (39 commits)
  feat(experimental): Add `comptime` keyword (#4840)
  feat: add `min` and `max` functions to the stdlib (#4839)
  feat: Allow numeric generics to non inlined ACIR functions (#4834)
  chore!: Add `as_array` and remove `_slice` variants of hash functions (#4675)
  feat!: reserve keyword `super` (#4836)
  feat: simplify `BoundedVec::eq` (#4838)
  feat: Add comptime Interpreter (#4821)
  feat: Sync from aztec-packages (#4833)
  feat: implement `Eq` trait on `BoundedVec` (#4830)
  chore: add benchmarks for serializing a dummy program (#4813)
  chore: remove unnecessary casts in `BoundedVec` (#4831)
  fix: issue 4682 and add solver for unconstrained bigintegers (#4729)
  chore(docs): fix wrong Nargo.toml workspace examples (#4822)
  chore: delete unnecessary Prover.toml file (#4829)
  chore: fix alerts on rust msrv (#4817)
  chore(ci): fix alerts on msrv issues (#4816)
  chore: run clippy (#4810)
  chore: optimize poseidon2 implementation (#4807)
  fix: catch panics from EC point creation (e.g. the point is at infinity) (#4790)
  feat: Sync from aztec-packages (#4792)
  ...
@TomAFrench
Copy link
Member

We're not fully converting Field into field if it's in a struct definition, etc. currently. I don't think this is a blocker however.

Copy link
Contributor

Changes to circuit sizes

Generated at commit: 7dfeb7b7be01e66563f908645f74784a18294e40, compared to commit: 4dfd7f03bc1b9cf57f5829c435a560bed53b7f46

🧾 Summary (10% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
main +11 ❌ +1100.00% +2,754 ❌ +39342.86%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
main 12 (+11) +1100.00% 2,761 (+2,754) +39342.86%

Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking making "field" a reserved word would also help avoid errors from users using "field" as a variable name.

Or maybe we're fine with this breaking change? Not sure - we're still before 1.0 at least

@@ -220,6 +220,8 @@ impl super::FmtVisitor<'_> {
self.push_rewrite(use_tree, span);
self.last_position = span.end();
}

// TODO: rewrite instances of "Field" into "field" in these items.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make an issue for this once this PR is merged?

@@ -1,38 +1,38 @@
mod bn254; // Instantiations of Poseidon for prime field of the same order as BN254
use crate::field::modulus_num_bits;
use crate::field_element::modulus_num_bits;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the import paths is my main worry in this PR.

Maybe we can make "field" just a reserved word / pseudo-keyword like "self" instead? That way we can still allow it in import paths. Alternatively I suppose it can stay a keyword but we'd have to change the parser to allow paths with field in them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants