Skip to content

Commit

Permalink
chore(docs): Update install script (AztecProtocol#3847)
Browse files Browse the repository at this point in the history
Updates the docker install script to get the sandbox, cli and nargo.

~~just verify that the LSP works with aztec-nargo. suggestions to
install nargo have been removed.~~
EDIT: I added the recommendation to install nargo back in for the LSP.

Closes: AztecProtocol#3846 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [x] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [x] Every change is related to the PR description.
- [x] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
critesjosh authored Jan 9, 2024
1 parent a2b267b commit 7003853
Show file tree
Hide file tree
Showing 21 changed files with 230 additions and 128 deletions.
2 changes: 1 addition & 1 deletion docs/docs/concepts/advanced/contract_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ The `deployedContracts` array has a maximum size `MAX_NUM_DEPLOYED_CONTRACTS`. I

Excluding these steps, constructor function call is executed identically to a regular private function.

> Under this design, if a public constructor is desired, one must create a private constructor function that then calls a public function. This could be abstracted away by the Noir++ compiler.
> Under this design, if a public constructor is desired, one must create a private constructor function that then calls a public function. This could be abstracted away by the aztec-nargo compiler.
**Q: why can't deployments be part of the public fn callstack?**

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/cli/blank_box.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See the Quickstart page for [requirements](../getting_started/quickstart.md#requ

Aztec Boxes use [yarn](https://classic.yarnpkg.com/) for package management, so if you want to follow along exactly, make sure you have it [installed](https://classic.yarnpkg.com/en/docs/install).

You will also need to install Noir to compile contracts. You can find instructions for installing the latest version of Noir that is compatible with the Sandbox on the [Aztec.nr Contracts](../contracts/main.md#install-noir) page.
You will also need to install Aztec tooling to compile contracts. You can find instructions for installing the latest version [here](../cli/sandbox-reference.md).

## Getting the Box

Expand Down
1 change: 1 addition & 0 deletions docs/docs/dev_docs/cli/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This command does a few things to manage updates:
- It looks for `Nargo.toml` at the `--contract` paths specified and updates all `aztec.nr` dependencies to the versions the sandbox expects.
- It outputs the changes.

You can specify a version to update to with the `--aztec-version` flag, but it defaults to `latest` so this is typically not necessary.

:::info

Expand Down
8 changes: 5 additions & 3 deletions docs/docs/dev_docs/cli/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ These provide a self contained environment which deploys Aztec on a local (empty

The current sandbox does not generate or verify proofs, but provides a working end to end developer flow for writing and interacting with Aztec.nr smart contracts.

## Aztec CLI
## Aztec CLI and aztec-nargo

The Aztec CLI is a command-line tool allowing the user to interact directly with the Aztec network and sandbox.
The Aztec CLI is a command-line tool allowing you to interact directly with the Aztec network and sandbox.

It aims to provide all of the functionality required to deploy, compile, and invoke contracts and query system state such as contract data, transactions and emitted logs.
It aims to provide all of the functionality required to deploy, and invoke contracts and query system state such as contract data, transactions and emitted logs.

Use `aztec-nargo` for compiling contracts. See the [compiling contracts](../contracts/compiling.md) page for more information.
42 changes: 33 additions & 9 deletions docs/docs/dev_docs/cli/sandbox-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,44 @@ You can run the Sandbox using Docker. See the [Quickstart](../getting_started/qu
### With Docker

```bash
/bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"
bash -i <(curl -s install.aztec.network)
```

This will attempt to run the Sandbox on ` localhost:8080`. You can change the port defined in `./.aztec/docker-compose.yml`. Running the command again will overwrite any changes made to the `docker-compose.yml`.
This will install the following:

This command also installs or updates the CLI. If you have previously installed the CLI via a node package manager, you will need to uninstall it and remove it from your project dependencies and install it via Docker.
- **aztec** - launches various infrastructure subsystems (sequencer, prover, pxe, etc).
- **aztec-cli** - a command line tool for interfacing and experimenting with infrastructure.
- **aztec-nargo** - aztec's build of nargo, the noir compiler toolchain.
- **aztec-sandbox** - a wrapper around docker-compose that launches services needed for sandbox testing.
- **aztec-up** - a tool to upgrade the aztec toolchain to the latest, or specific versions.

Once these have been installed, to start the sandbox, run:

```bash
aztec-sandbox
```

This will attempt to run the Sandbox with the PXE listening on ` localhost:8080`. You can change the port defined in `./.aztec/docker-compose.yml` or by setting the `PXE_PORT` environment variable. Running the install command again will overwrite any changes made to the `docker-compose.yml`.

See the full list of configurable environment variables [here](#environment-variables).

If you have previously installed the CLI via a node package manager, you will need to uninstall it and remove it from your project dependencies and install it via Docker.

To install a specific version of the sandbox, you can set the environment variable `SANDBOX_VERSION`

```bash
SANDBOX_VERSION=<version> /bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"
VERSION=<version> bash -i <(curl -s install.aztec.network)
```

## Running

The installation command will run the sandbox, and once installed you can run like so:
Once the installed, you can run the sandbox with:

```bash
aztec-sandbox
```

Alternatively, you can run like so:

```bash
cd ~/.aztec && docker-compose up
Expand All @@ -37,12 +59,10 @@ cd ~/.aztec && docker-compose up
If you wish to run components of the Aztec network stack separately, you can still use the Sandbox by including a `MODE` variable.
The values for `MODE` can be:

```
- sandbox (default)
- node
- pxe
- p2p-bootstrap
```

## Environment Variables

Expand Down Expand Up @@ -152,21 +172,25 @@ We have shipped a number of example contracts in the `@aztec/noir-contracts` [np
BenchmarkingContractArtifact
CardGameContractArtifact
ChildContractArtifact
CounterContractArtifact
DocsExampleContractArtifact
EasyPrivateTokenContractArtifact
EasyPrivateVotingContractArtifact
EcdsaAccountContractArtifact
EscrowContractArtifact
ImportTestContractArtifact
InclusionProofsContractArtifact
LendingContractArtifact
ParentContractArtifact
PendingCommitmentsContractArtifact
PokeableTokenContractArtifact
PriceFeedContractArtifact
SchnorrAccountContractArtifact
SchnorrHardcodedAccountContractArtifact
SchnorrSingleKeyAccountContractArtifact
SlowTreeContractArtifact
StatefulTestContractArtifact
TestContractArtifact
TokenBlacklistContractArtifact
TokenBridgeContractArtifact
TokenContractArtifact
UniswapContractArtifact
Expand All @@ -180,4 +204,4 @@ You can see all of our example contracts in the monorepo [here](https://github.c

The sandbox is shipped with full-stack Aztec project templates, with example Aztec.nr contracts, testing scripts, and web interfaces.

You can read more information about how to use boxes [here](./blank_box.md)
You can read more information about how to use boxes [here](./blank_box.md).
14 changes: 11 additions & 3 deletions docs/docs/dev_docs/contracts/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Once you have [compiled](./compiling.md) your contracts you can proceed to deplo

## Prerequisites

- `aztec-cli` installed (go to [CLI main section](../cli/main.md) for installation instructions)
- `aztec-cli` and `aztec-nargo` installed (go to [CLI main section](../cli/main.md) for installation instructions)
- contract artifacts ready (go to [Compiling contracts section](./compiling.md) for instructions on how to compile contracts)
- aztec-sandbox running (go to [Sandbox section](../getting_started/quickstart.md) for instructions on how to install and run the sandbox)

Expand All @@ -27,11 +27,19 @@ aztec-cli deploy /path/to/contract/artifact.json

Pre-requisite - Compile the contract and generate a type-safe typescript class for it.

Compile the contract:

```bash
aztec-nargo compile
```

Generate the ABI and typescript class:

```bash
aztec-cli compile /path/to/contract -o target/ -ts target/
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts --ts
```

This would create a typescript file like `Example.ts` in the path specified. More details in the [compiling page](./compiling.md)
This would create a typescript file like `Example.ts` in `./src/artifacts`. Read more on the [compiling page](./compiling.md).

Now you can import it to easily deploy and interact with the contract.

Expand Down
12 changes: 5 additions & 7 deletions docs/docs/dev_docs/contracts/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,25 @@ An **Aztec smart contract** is a smart contract with **private** state variables

# Getting started

## Install Noir
## Install aztec-nargo

To write an Aztec.nr contract, you need to write Noir, [aztec-cli](../cli/cli-commands) comes with a built-in compiler for Noir contracts.
To write an Aztec.nr contract, you need to write Noir, `aztec-nargo` comes with a built-in compiler for Aztec contracts written in Noir. See install instructions [here](../cli/sandbox-reference.md).

:::info
For those coming from vanilla Noir, the version used for aztec.nr is tracked separately to nargo for vanilla noir, so be sure to use the nargo version shown above
For those coming from vanilla Noir, the version used for aztec.nr is tracked separately to nargo for vanilla Noir. Be sure to use `aztec-nargo` to compile your contracts.
:::

## Install `nargo` (recommended)

The CLI comes with the Noir compiler, so installing `nargo` is not required, however it is recommended as it provides a better developer experience for writing contracts. You will need nargo installed to take advantage of the [Noir Language Server](https://noir-lang.org/nargo/language_server), which provides syntax highlighting and formatting for your Aztec contracts.

You will also need `nargo` if you want to run unit tests in Noir.
`aztec-nargo` comes with the Noir compiler, so installing `nargo` is not required, however it is recommended as it provides a better developer experience for writing contracts. You will need nargo installed to take advantage of the [Noir Language Server](https://noir-lang.org/nargo/language_server), which provides syntax highlighting and formatting for your Aztec contracts.

You can install `nargo` with the following commands:

<InstallNargoInstructions />

## Install Noir tooling

There are a number of tools to make writing Aztec.nr contracts more pleasant. See [here](https://github.com/noir-lang/awesome-noir#get-coding).
There are a number of tools to make writing Aztec.nr contracts in Noir more pleasant. See [here](https://github.com/noir-lang/awesome-noir#get-coding).

## Tutorials

Expand Down
14 changes: 8 additions & 6 deletions docs/docs/dev_docs/contracts/resources/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ This allows you to use authentication witnesses in your contract. Find more abou
address_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/address-note" }
```

## Assets

```toml
assets = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/assets" }
```

This is a library for utilizing notes that hold addresses. Find it on [GitHub](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec-nr/address-note/src).

## Easy private state
Expand All @@ -42,6 +36,14 @@ easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages/", t

This is an abstraction library for using private variables like [`EasyPrivateUint`](https://github.com/AztecProtocol/aztec-packages/blob/6c20b45993ee9cbd319ab8351e2722e0c912f427/yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr#L17).

## Protocol Types

```toml
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

This library contains types that are used in the Aztec protocol. Find it on [GitHub](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-protocol-circuits/src/crates/types/src).

## Safe math

```toml
Expand Down
15 changes: 5 additions & 10 deletions docs/docs/dev_docs/contracts/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ If you haven't read about [Aztec.nr](./main.md), we recommend going there first.

### Dependencies

#### `nargo`

Nargo is Noir's build tool. On your terminal, run:

<InstallNargoInstructions />

#### Aztec Sandbox

You need to setup the [Aztec sandbox](../getting_started/quickstart.md).

<!-- TODO([#1056](https://github.com/AztecProtocol/aztec-packages/issues/1056)): Add a step for the starter kit -->

## Set up for aztec.nr contracts
## Setup for Aztec.nr contracts

1. Inside the yarn project you created from the [Sandbox page](../getting_started/quickstart.md), create a sub-folder where the contracts will reside.

Expand All @@ -36,14 +30,14 @@ mkdir contracts

All contract projects will reside within this folder. Note that contracts don't actually have to live here and this is just a style choice.

2. Next, create a noir project using nargo by running the following in the terminal from the `contracts` folder
1. Next, create an Aztec contract project using aztec-nargo by running the following in the terminal from the `contracts` folder

```bash
cd contracts
nargo new --contract example_contract
aztec-nargo new --contract example_contract
```

This creates `example_contract` directory within contracts which is a noir project with:
This creates `example_contract` directory within contracts which is a Noir project with:

- a Nargo.toml (which is the manifest file of the project) at `example_contract/Nargo.toml`.
- a main.nr file (the file where our contract will reside) at `example_contract/src/main.nr`.
Expand Down Expand Up @@ -77,6 +71,7 @@ type = "contract"
[dependencies]
# Framework import
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}

# Utility dependencies
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
Expand Down
19 changes: 13 additions & 6 deletions docs/docs/dev_docs/getting_started/aztecnr-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ authors = [""]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/easy-private-state"}
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/easy-private-state"}
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

## Define the functions
Expand Down Expand Up @@ -148,14 +149,20 @@ Now we've written a simple Aztec.nr smart contract, it's time to ensure everythi

### Compile the smart contract

In the root of the `nargo` project, run this:
In `./contracts/counter/` directory, run this:

```bash
aztec-cli compile .
aztec-nargo compile
```

This will compile the smart contract and create a `target` folder with a `.json` artifact inside.

After compiling, you need to generate the ABI and typescript class. In the same directory, run this:

```bash
aztec-cli codegen target -o src/artifacts --ts
```

### Deploy

You can use the previously generated artifact to deploy the smart contract. Our constructor takes two arguments - `initial_counter` and `owner` so let's make sure to pass those in.
Expand Down Expand Up @@ -192,7 +199,7 @@ Use one of these `address`es as the `owner`. You can either copy it or export.
To deploy the counter contract, [ensure the sandbox is running](../cli/sandbox-reference.md) and run this in the root of your Noir project:

```bash
aztec-cli deploy target/Counter.json --args 100 0x25048e8c1b7dea68053d597ac2d920637c99523651edfb123d0632da785970d0
aztec-cli deploy contracts/counter/src/artifacts/Counter.json --args 100 0x2a0f32c34c5b948a7f9766f0c1aad70a86c0ee649f56208e936be4324d49b0b9
```

You can also test the functions by applying what you learned in the [quickstart](./quickstart.md).
Expand Down
16 changes: 15 additions & 1 deletion docs/docs/dev_docs/getting_started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,21 @@ You can run the Sandbox using Docker.
To install the latest Sandbox version, run:

```bash
/bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"
bash -i <(curl -s install.aztec.network)
```

This will install the following:

- **aztec** - launches various infrastructure subsystems (sequencer, prover, pxe, etc).
- **aztec-cli** - a command line tool for interfacing and experimenting with infrastructure.
- **aztec-nargo** - aztec's build of nargo, the noir compiler toolchain.
- **aztec-sandbox** - a wrapper around docker-compose that launches services needed for sandbox testing.
- **aztec-up** - a tool to upgrade the aztec toolchain to the latest, or specific versions.

Once these have been installed, to start the sandbox, run:

```bash
aztec-sandbox
```

This will attempt to run the Sandbox on ` localhost:8080`, so you will have to make sure nothing else is running on that port or change the port defined in `./.aztec/docker-compose.yml`. Running the command again will overwrite any changes made to the `docker-compose.yml`.
Expand Down
10 changes: 8 additions & 2 deletions docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ npx hardhat compile
And compile your Aztec.nr contracts like this:

```bash
cd aztec-contracts
aztec-cli compile --typescript ../../src/test/fixtures token_bridge
cd aztec-contracts/token-bridge
aztec-nargo compile
```

And generate the TypeScript interface for the contract and add it to the test dir:

```bash
aztec-cli codegen target -o ../../../src/test/fixtures --ts
```

This will create a TS interface in our `src/test` folder!
Expand Down
Loading

0 comments on commit 7003853

Please sign in to comment.