Skip to content

Commit

Permalink
fix(docs): Update debugging docs (#9200)
Browse files Browse the repository at this point in the history
Updates the debugging docs to actually work.

closes: AztecProtocol/dev-rel#396
  • Loading branch information
critesjosh authored Oct 20, 2024
1 parent 419642b commit 2a4188c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
27 changes: 16 additions & 11 deletions docs/docs/reference/developer_references/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can log statements from Aztec.nr contracts that will show ups in the Sandbox

### Import `debug_log`

Import the [`debug_log` (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/oracle/debug_log.nr) dependency from Aztec oracles:
Import the `debug_log` dependency from Aztec oracles:

```rust
use dep::aztec::oracle::debug_log::{ debug_log };
Expand Down Expand Up @@ -47,16 +47,21 @@ debug_log_array(my_array);

### Start Sandbox in debug mode

Prepend the command to start the sandbox with `DEBUG=aztec:*` to log everything or `DEBUG=aztec:simulator:oracle` to only log your `debug_log()` statements.

```bash
# Using the docker-compose.yml setup
cd ~/.aztec && DEBUG=aztec:* docker-compose up
```

Alternatively you can update the `DEBUG` environment variable in docker-compose.yml and start the sandbox normally.
Update the `DEBUG` environment variable in docker-compose.sandbox.yml to the following:

```yml
environment:
DEBUG: aztec:*
# ~/.aztec/docker-compose.sandbox.yml

# ...

aztec:
image: "aztecprotocol/aztec"
ports:
- "${PXE_PORT:-8080}:${PXE_PORT:-8080}"
environment:
DEBUG: aztec:simulator:client_execution_context, aztec:sandbox, aztec:avm_simulator:debug_log
LOG_LEVEL: verbose # optionally add this for more logs
# ...
```

and start the sandbox normally.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ For a quick start, follow the [guide](../../../guides/developer_guides/getting_s

There are various environment variables you can use when running the whole sandbox or when running on of the available modes.

To change them, you can open `~/.aztec/docker-compose.yml` and edit them directly.
To change them, you can open `~/.aztec/docker-compose.sandbox.yml` and edit them directly.

**Sandbox**

```sh
DEBUG=aztec:* # The level of debugging logs to be displayed. using "aztec:*" will log everything.
HOST_WORKDIR='${PWD}' # The location to store log outpus. Will use ~/.aztec where the docker-compose.yml file is stored by default.
LOG_LEVEL=debug # Setting to 'debug' will print the debug logs
HOST_WORKDIR='${PWD}' # The location to store log outputs. Will use ~/.aztec where the docker-compose.yml file is stored by default.
ETHEREUM_HOST=http://ethereum:8545 # The Ethereum JSON RPC URL. We use an anvil instance that runs in parallel to the sandbox on docker by default.
L1_CHAIN_ID=31337 # The Chain ID that the Ethereum host is using.
TEST_ACCOUNTS='true' # Option to deploy 3 test account when sandbox starts. (default: true)
Expand Down Expand Up @@ -78,7 +79,7 @@ SEQ_MAX_SECONDS_BETWEEN_BLOCKS=0 # Sequencer will produce a block with less than
SEQ_MIN_SECONDS_BETWEEN_BLOCKS=0 # Minimum seconds to wait between consecutive blocks. (default: 0)

## Validator variables ##
VALIDATOR_PRIVATE_KEY=0x01234567890abcde01234567890abcde # Private key of the ethereum account that will be used to perform validator duties
VALIDATOR_PRIVATE_KEY=0x01234567890abcde01234567890abcde # Private key of the ethereum account that will be used to perform validator duties
```

**PXE**
Expand Down Expand Up @@ -158,7 +159,7 @@ UniswapContractArtifact

> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/master//yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts#L95-L118" target="_blank" rel="noopener noreferrer">Source code: /yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts#L95-L118</a></sub></sup>
You can see all of our example contracts in the monorepo [here (GitHub link)](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts).
You can see all of our example contracts in the monorepo [here (GitHub link)](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts).

## Running Aztec PXE / Node / P2P-Bootstrap node individually

Expand All @@ -176,4 +177,4 @@ To update the sandbox, run:

```bash
aztec-up
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages/", t
Go to `main.nr` and start with this contract initialization:

```rust
contract Counter {
#include_code setup /noir-projects/noir-contracts/contracts/counter_contract/src/main.nr raw
}
```

Expand Down Expand Up @@ -159,4 +159,4 @@ Follow the private voting contract tutorial on the [next page](./private_voting_

### Optional: Learn more about concepts mentioned here

- [Functions and annotations like `#[aztec(private)]`](../../../aztec/smart_contracts/functions/inner_workings.md)
- [Functions and annotations like `#[aztec(private)]`](../../../aztec/smart_contracts/functions/inner_workings.md)
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// docs:start:setup
use dep::aztec::macros::aztec;

#[aztec]
contract Counter {
// docs:end:setup
// docs:start:imports
use aztec::prelude::{AztecAddress, Map};
use value_note::{balance_utils, value_note::ValueNote};
Expand Down

0 comments on commit 2a4188c

Please sign in to comment.