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

feat!: Support workspaces and package selection on every nargo command #1992

Merged
merged 13 commits into from
Aug 1, 2023

Conversation

phated
Copy link
Contributor

@phated phated commented Jul 21, 2023

Description

Problem*

Closes #794
Closes #1201 (we might want a follow-up issue for the caching vs rebuilding a package)
Towards #1838

Summary*

This replaces the originally merged workspace logic by unifying the various ways you can configure a project (top-level package, workspace, etc) into a single Workspace type that can contain one of more Package and optionally a selected Package. It also separates these concepts from the serde logic when parsing toml and adds functions that resolve a Workspace completely. It adds an iterator implementation on Workspace that iterates the correct Packages where each package can be prepared with it's own Context so we don't leak any compilation details.

Note: This PR is breaking as it removes circuit_name, proof_name and proof positional arguments for various commands and replaces them with --package CLI argument. This means that each Package is expected to contain exactly one "named circuit" and users will be expected to setup a workspace to achieve the old behavior.

Below is a diagram of the pipeline between Nargo.toml files, the --package CLI flag, and Workspace struct.

nargo-workspace

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

We need to update each command that now accepts the --package argument, remove the circuit_name positional argument, and we need to document workspaces thoroughly.

Additional Context

PR Checklist*

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

@phated phated requested a review from TomAFrench July 21, 2023 00:39
Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

This lines up with a lot of my thinking on workspaces from looking at how Cargo handles them. I've made a couple of notes but I don't think that they'll be anything you don't already know. Don't want to raise too many nits while this is draft so let me know when you make this PR ready for review.

crates/nargo_cli/src/manifest.rs Outdated Show resolved Hide resolved
crates/nargo_cli/src/manifest.rs Outdated Show resolved Hide resolved
crates/nargo_cli/src/manifest.rs Outdated Show resolved Hide resolved
crates/nargo/src/workspace.rs Outdated Show resolved Hide resolved
@phated phated force-pushed the phated/normalize-workspace branch from cd11b28 to b18483f Compare July 26, 2023 19:52
@phated phated changed the base branch from master to phated/package-name July 26, 2023 19:52
@phated phated changed the title chore: Redo workspace logic to unify resolved project structure feat!: Support workspaces and package selection on every nargo command Jul 26, 2023
Base automatically changed from phated/package-name to master July 27, 2023 16:29
@phated phated force-pushed the phated/normalize-workspace branch from 4963946 to 3e58f37 Compare July 27, 2023 17:18
@phated phated marked this pull request as ready for review July 27, 2023 20:41
@phated phated force-pushed the phated/normalize-workspace branch from 48028aa to 6e9ac11 Compare July 28, 2023 16:32
Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

We're getting collisions due to not namespacing proofs/witnesses/etc. I've updated the integration tests to ensure that the workspace packages are distinct so we get test failures.

crates/nargo_cli/src/git.rs Outdated Show resolved Hide resolved
crates/nargo_cli/src/manifest.rs Outdated Show resolved Hide resolved
crates/nargo_cli/src/cli/prove_cmd.rs Outdated Show resolved Hide resolved
crates/nargo_cli/src/cli/verify_cmd.rs Show resolved Hide resolved
@TomAFrench
Copy link
Member

I'd be ok with just restricting prove/verify/execute to run on a single package and error if no default is set.

@phated
Copy link
Contributor Author

phated commented Aug 1, 2023

I'd be ok with just restricting prove/verify/execute to run on a single package and error if no default is set.

I think we should prefix the package name as a directory, or use the package name as the proof name by default.

@phated phated requested a review from TomAFrench August 1, 2023 18:14
@phated phated added this pull request to the merge queue Aug 1, 2023
Merged via the queue into master with commit 940b189 Aug 1, 2023
6 checks passed
@phated phated deleted the phated/normalize-workspace branch August 1, 2023 22:13
TomAFrench added a commit that referenced this pull request Aug 2, 2023
* master:
  feat!: Support workspaces and package selection on every nargo command (#1992)
  chore: Make a more clear error for slices passed to std::println (#2113)
  feat: Implement type aliases (#2112)
  feat: Add `Option<T>` to noir stdlib (#1781)
  feat: Format strings for prints  (#1952)
  feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097)
  fix: Mutating a variable no longer mutates its copy (#2057)
  fix: Implement `.len()` in Acir-Gen (#2077)
  chore: clippy fixes (#2101)
TomAFrench added a commit that referenced this pull request Aug 2, 2023
* master: (50 commits)
  fix(globals): Accurately filter literals for resolving globals (#2126)
  feat: Optimize away constant calls to black box functions (#1981)
  fix: Rename `Option::value` to `Option::_value` (#2127)
  feat: replace boolean `AND`s with multiplication (#1954)
  chore: create a `const` to hold the panic message (#2122)
  feat: Add support for bitshifts by distances known at runtime (#2072)
  feat: Add additional `BinaryOp` simplifications (#2124)
  fix: flattening pass no longer overwrites previously mapped condition values (#2117)
  chore(noirc_driver): Unify crate preparation (#2119)
  feat!: Support workspaces and package selection on every nargo command (#1992)
  chore: Make a more clear error for slices passed to std::println (#2113)
  feat: Implement type aliases (#2112)
  feat: Add `Option<T>` to noir stdlib (#1781)
  feat: Format strings for prints  (#1952)
  feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097)
  fix: Mutating a variable no longer mutates its copy (#2057)
  fix: Implement `.len()` in Acir-Gen (#2077)
  chore: clippy fixes (#2101)
  chore: Update `noir-source-resolver` to v1.1.3 (#1912)
  chore: Document `GeneratedAcir::more_than_eq_comparison` (#2085)
  ...
TomAFrench added a commit that referenced this pull request Aug 2, 2023
* master:
  chore: rename `ssa_refactor` module to `ssa` (#2129)
  chore: Use `--show-output` flag on execution rather than compilation  (#2116)
  fix(globals): Accurately filter literals for resolving globals (#2126)
  feat: Optimize away constant calls to black box functions (#1981)
  fix: Rename `Option::value` to `Option::_value` (#2127)
  feat: replace boolean `AND`s with multiplication (#1954)
  chore: create a `const` to hold the panic message (#2122)
  feat: Add support for bitshifts by distances known at runtime (#2072)
  feat: Add additional `BinaryOp` simplifications (#2124)
  fix: flattening pass no longer overwrites previously mapped condition values (#2117)
  chore(noirc_driver): Unify crate preparation (#2119)
  feat!: Support workspaces and package selection on every nargo command (#1992)
  chore: Make a more clear error for slices passed to std::println (#2113)
  feat: Implement type aliases (#2112)
  feat: Add `Option<T>` to noir stdlib (#1781)
  feat: Format strings for prints  (#1952)
  feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097)
  fix: Mutating a variable no longer mutates its copy (#2057)
  fix: Implement `.len()` in Acir-Gen (#2077)
TomAFrench added a commit that referenced this pull request Aug 2, 2023
* master:
  chore: rename `ssa_refactor` module to `ssa` (#2129)
  chore: Use `--show-output` flag on execution rather than compilation  (#2116)
  fix(globals): Accurately filter literals for resolving globals (#2126)
  feat: Optimize away constant calls to black box functions (#1981)
  fix: Rename `Option::value` to `Option::_value` (#2127)
  feat: replace boolean `AND`s with multiplication (#1954)
  chore: create a `const` to hold the panic message (#2122)
  feat: Add support for bitshifts by distances known at runtime (#2072)
  feat: Add additional `BinaryOp` simplifications (#2124)
  fix: flattening pass no longer overwrites previously mapped condition values (#2117)
  chore(noirc_driver): Unify crate preparation (#2119)
  feat!: Support workspaces and package selection on every nargo command (#1992)
  chore: Make a more clear error for slices passed to std::println (#2113)
  feat: Implement type aliases (#2112)
  feat: Add `Option<T>` to noir stdlib (#1781)
  feat: Format strings for prints  (#1952)
  feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097)
  fix: Mutating a variable no longer mutates its copy (#2057)
  fix: Implement `.len()` in Acir-Gen (#2077)
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.

Refactor circuit_build_path logic Add some simple form of workspace file
3 participants