Skip to main content
Version: dev

How to Debug

This guide shows you how to debug issues in your Aztec development environment.

Prerequisites:

  • Aztec sandbox running
  • Aztec.nr contract or aztec.js application
  • Basic understanding of Aztec architecture

How to Enable Logging

In Aztec.nr Contracts

// Import debug logging
use dep::aztec::oracle::debug_log::{ debug_log, debug_log_format, debug_log_field, debug_log_array };

// Log simple messages
debug_log("checkpoint reached");

// Log field values with context
debug_log_format("slot:{0}, hash:{1}", [storage_slot, note_hash]);

// Log single field
debug_log_field(my_field);

// Log arrays
debug_log_array(my_array);

In Sandbox

# Set log level (options: fatal, error, warn, info, verbose, debug, trace)
LOG_LEVEL=debug aztec start --sandbox

# Different levels for different services
LOG_LEVEL="verbose;info:sequencer" aztec start --sandbox

How to Debug Common Errors

Contract Errors

ErrorSolution
Aztec dependency not foundAdd to Nargo.toml: aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="noir-projects/aztec-nr/aztec" }
Public state writes only supported in public functionsMove state writes to public functions
Unknown contract 0x0Call pxe.addContracts(...) to register contract
No public key registered for addressCall pxe.registerRecipient(...) or pxe.registerAccount(...)
Failed to solve brillig functionCheck function parameters and note validity

Circuit Errors

Error CodeMeaningFix
2002Invalid contract addressEnsure contract is deployed and address is correct
2005/2006Static call violationsRemove state modifications from static calls
2017User intent mismatchVerify transaction parameters match function call
3001Unsupported operationCheck if operation is supported in current context
3005Non-empty private call stackEnsure private functions complete before public
4007/4008Chain ID/version mismatchVerify L1 chain ID and Aztec version
7008Membership check failedEnsure using valid historical state
7009Array overflowReduce number of operations in transaction

Quick Fixes for Common Issues

# Archiver sync issues - force progress with dummy transactions
aztec-wallet send transfer --from test0 --to test0 --amount 0
aztec-wallet send transfer --from test0 --to test0 --amount 0

# L1 to L2 message pending - wait for inclusion
# Messages need 2 blocks to be processed

How to Debug WASM Errors

Enable Debug WASM

// In vite.config.ts or similar
export default {
define: {
'process.env.BB_WASM_PATH': JSON.stringify('https://debug.wasm.url')
}
}

Profile Transactions

import { serializePrivateExecutionSteps } from "@aztec/stdlib";

// Profile the transaction
const profileTx = await contract.methods
.myMethod(param1, param2)
.profile({ profileMode: "execution-steps" });

// Serialize for debugging
const ivcMessagePack = serializePrivateExecutionSteps(profileTx.executionSteps);

// Download debug file
const blob = new Blob([ivcMessagePack]);
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "debug-steps.msgpack";
link.click();

⚠️ Warning: Debug files may contain private data. Use only in development.

How to Interpret Error Messages

Kernel Circuit Errors (2xxx)

  • Private kernel errors (2xxx): Issues with private function execution
  • Public kernel errors (3xxx): Issues with public function execution
  • Rollup errors (4xxx): Block production issues
  • Generic errors (7xxx): Resource limits or state validation

Transaction Limits

Current limits that trigger 7009 - ARRAY_OVERFLOW:

  • Max new notes per tx: Check MAX_NOTE_HASHES_PER_TX
  • Max nullifiers per tx: Check MAX_NULLIFIERS_PER_TX
  • Max function calls: Check call stack size limits
  • Max L2→L1 messages: Check message limits

How to Debug Sequencer Issues

Common Sequencer Errors

ErrorCauseSolution
tree root mismatchState inconsistencyRestart sandbox or check state transitions
next available leaf index mismatchTree corruptionVerify tree updates are sequential
Public call stack size exceededToo many public callsReduce public function calls
Failed to publish blockL1 submission failedCheck L1 connection and gas

How to Report Issues

When debugging fails:

  1. Collect error messages and codes
  2. Generate transaction profile (if applicable)
  3. Note your environment setup
  4. Create issue at aztec-packages

Quick Reference

Enable Verbose Logging

LOG_LEVEL=verbose aztec start --sandbox

Common Debug Imports

use dep::aztec::oracle::debug_log::{ debug_log, debug_log_format };

Check Contract Registration

await pxe.getContracts();
await pxe.getRegisteredAccounts();

Decode L1 Errors

Check hex errors against Errors.sol

Tips

  • Always check logs before diving into circuit errors
  • State-related errors often indicate timing issues
  • Array overflow errors mean you hit transaction limits
  • Use debug WASM for detailed stack traces
  • Profile transactions when errors are unclear