Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/simulator/docs/avm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ single AVM proof.

### Overview of Public Simulation
- **[Enqueued Calls](./enqueued-calls.md)**: How public calls are enqueued from private and delivered to the AVM
- **[Public Transaction Simulation](./public-tx-simulation.md)**: Execution phases, rollback on reverts, fee payment, and finalization
- **[Public Transaction Simulation](./public-tx-simulation.md)**: Execution phases, rollback on reverts, fee payment, and tree padding

### The Machine Model
- **[State](./state.md)**: World state (persistent) vs execution state (transient)
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/simulator/docs/avm/addressing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Relative addressing adds the memory offset to the value stored at memory address

When both indirect and relative addressing modes are applied to an offset `x`, **relative addressing is resolved first, then indirect addressing**.

**Notation**: `M[x + M[0]]` (resolved address)
**Notation**: `M[M[x + M[0]]]`

This means the VM first adds the base pointer `M[0]` to the offset to compute an intermediate address, then reads the pointer from that intermediate address to get the final address.

Expand Down
5 changes: 4 additions & 1 deletion yarn-project/simulator/docs/avm/avm-isa-quick-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Quick reference for all Aztec Virtual Machine (AVM) opcodes.

Before diving into the instruction set, familiarize yourself with these core concepts:

- **[Introduction](index.md)**: What is the AVM and why do we need it?
- **[Introduction](README.md)**: What is the AVM and why do we need it?
- **[State](state.md)**: World state (persistent) vs execution state (transient)
- **[Memory Model](memory.md)**: Memory notation and tagged memory (`M[x]` and `T[x]`)
- **[Addressing Modes](addressing.md)**: Direct, indirect, and relative addressing along with their gas implications
Expand Down Expand Up @@ -265,3 +265,6 @@ Click on an opcode name to view its detailed documentation.
/*outputBits=*/M[outputBitsOffset]
)
```

---
← Previous: [Wire Formats](./wire-format.md) | Next: [Tooling and Compilation](./tooling.md) →
3 changes: 2 additions & 1 deletion yarn-project/simulator/docs/avm/external-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ This is not a comprehensive list. See individual opcode docs for more details.
| Error | Cause |
|-------|-------|
| OUT_OF_GAS | Insufficient gas for instruction |
| INVALID_TAG | Type tag mismatch on operands |
| INVALID_TAG | Operand tag is not valid for the operation |
| TAG_MISMATCH | Type tag mismatch between operands |
| MEMORY_ACCESS_OUT_OF_RANGE | Memory offset exceeds addressable space |
| SIDE_EFFECT_LIMIT_REACHED | Transaction limit exceeded (see [Transaction Limits](#transaction-limits)) |
| STATIC_CALL_VIOLATION | State modification attempted in static context |
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/simulator/docs/avm/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ An out-of-bounds memory access can be encountered when:
- An instruction operand uses relative addressing which derives a memory offset from the addition of two values (see [Addressing](addressing.md)).
- An instruction operates on a _range_ of data (see [EMITUNENCRYPTEDLOG](opcodes/emitunencryptedlog.md))

When this happens, the instruction errors and execution in the current context exceptionally halts (See [Errors](./errors.md).
When this happens, the instruction errors and execution in the current context exceptionally halts (see [Errors](./errors.md)).

---
← Previous: [State](./state.md) | Next: [Addressing Modes](./addressing.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Performs addition. Both operands must have the same type tag. For integer types
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -110,4 +110,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/and.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Performs bitwise AND operation. Both operands must have the same integral type t
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |
| L2 Dynamic | 3 | - |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -113,4 +113,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Calls another contract with the specified calldata and gas allocation. Can modif
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -122,4 +122,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/calldatacopy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Copies a section of the current call's calldata into memory at the specified off
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |
| L2 Dynamic | 3 | `M[copySizeOffset]` |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -99,4 +99,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/cast.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Changes the type tag of a value. The value itself is preserved if casting to a l
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -106,4 +106,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
6 changes: 3 additions & 3 deletions yarn-project/simulator/docs/avm/opcodes/debuglog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ debugLog(level, message, M[fieldsOffset:fieldsOffset+M[fieldsSizeOffset]])

## Details

Prints a debug log to console as a formatted a message, and pushes a structured debug object (`{contractAddress, level, message, fields[]}`) to an accumulated list for the transaction. This opcode does nearly nothing when executed by sequencers or provers (only performs PC increment and address resolution). It is meant for local debugging or for use by RPC nodes and wallets. Logs are only printed if logging level is "Debug" (6) or higher. Message size is an immediate (constant in the bytecode). Throws an irrecoverable error if truly doing debug logging and log level is invalid (greater than 7) or upon reaching the node's configured maxDebugLogMemoryReads.
Prints a debug log to console as a formatted message, and pushes a structured debug object (`{contractAddress, level, message, fields[]}`) to an accumulated list for the transaction. This opcode does nearly nothing when executed by sequencers or provers (only performs PC increment and address resolution). It is meant for local debugging or for use by RPC nodes and wallets. Logs are only printed if logging level is "Debug" (6) or higher. Message size is an immediate (constant in the bytecode). Throws an irrecoverable error if truly doing debug logging and log level is invalid (greater than 7) or upon reaching the node's configured maxDebugLogMemoryReads.

## Gas Costs

Expand All @@ -22,7 +22,7 @@ Prints a debug log to console as a formatted a message, and pushes a structured
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -96,4 +96,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/div.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Performs integer division (truncating). Both operands must have the same integra
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -113,4 +113,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/ecadd.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Performs elliptic curve point addition on the Grumpkin curve. Each point is repr
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -120,4 +120,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
6 changes: 3 additions & 3 deletions yarn-project/simulator/docs/avm/opcodes/emitnotehash.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Writes a new note hash to the Note Hash Tree. Note hash must have type tag FIELD
| DA Base | 512 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -81,10 +81,10 @@ packet-beta
## Error Conditions

- **INVALID_TAG**: Note hash operand is not FIELD
- **STATIC_CALL_ALTERATION**: Attempted note hash emission in static call context
- **STATIC_CALL_VIOLATION**: Attempted note hash emission in static call context
- **SIDE_EFFECT_LIMIT_REACHED**: Exceeded maximum note hashes per transaction (MAX_NOTE_HASHES_PER_TX)
- **MEMORY_ACCESS_OUT_OF_RANGE**: Memory offset operand exceeds addressable memory

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
6 changes: 3 additions & 3 deletions yarn-project/simulator/docs/avm/opcodes/emitnullifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Writes a new nullifier to the Nullifier Tree. This opcode can only emit nullifie
| DA Base | 512 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -81,11 +81,11 @@ packet-beta
## Error Conditions

- **INVALID_TAG**: Nullifier operand is not FIELD
- **STATIC_CALL_ALTERATION**: Attempted nullifier emission in static call context
- **STATIC_CALL_VIOLATION**: Attempted nullifier emission in static call context
- **NULLIFIER_COLLISION**: Nullifier already exists
- **SIDE_EFFECT_LIMIT_REACHED**: Exceeded maximum nullifiers per transaction (MAX_NULLIFIERS_PER_TX)
- **MEMORY_ACCESS_OUT_OF_RANGE**: Memory offset operand exceeds addressable memory

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
6 changes: 3 additions & 3 deletions yarn-project/simulator/docs/avm/opcodes/emitunencryptedlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Emits a public log from the currently executing contract. Log size must be Uint3
| L2 Dynamic | 3 | `M[logSizeOffset]` |
| DA Dynamic | 512 | `M[logSizeOffset]` |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -86,10 +86,10 @@ packet-beta
## Error Conditions

- **INVALID_TAG**: Log size is not Uint32 or log data is not FIELD
- **STATIC_CALL_ALTERATION**: Attempted log emission in static call context
- **STATIC_CALL_VIOLATION**: Attempted log emission in static call context
- **SIDE_EFFECT_LIMIT_REACHED**: Exceeded maximum cumulative log size per transaction (FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH)
- **MEMORY_ACCESS_OUT_OF_RANGE**: Memory offset operand exceeds addressable memory

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/eq.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Compares two values for equality. Both operands must have the same type tag. The
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -110,4 +110,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/fdiv.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Performs field division (computes a * b^(-1) mod p where p is the BN254 field mo
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -113,4 +113,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This separation allows for:
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -115,4 +115,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/getenvvar.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Retrieves environment variables from the currently executing context. The variab
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -104,4 +104,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/internalcall.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Pushes current PC and return PC onto internal call stack, then jumps to the targ
| L2 Base | 9 |
| DA Base | 0 |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand All @@ -48,4 +48,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
6 changes: 3 additions & 3 deletions yarn-project/simulator/docs/avm/opcodes/internalreturn.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Pops return PC from internal call stack and sets PC to it.
| L2 Base | 9 |
| DA Base | 0 |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Wire Formats
See [Wire Format](wire-format.md) page for an explanation of wire format variants and opcode naming (e.g., why `ADD_8` vs `ADD_16`).
Expand All @@ -41,8 +41,8 @@ packet-beta

## Error Conditions

- **INTERNAL_CALL_STACK_EMPTY**: Internal call stack is empty
- **INTERNAL_CALL_STACK_UNDERFLOW**: Internal call stack is empty

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/jump.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Sets the program counter to the specified offset. The offset is an immediate val
| L2 Base | 9 |
| DA Base | 0 |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand All @@ -48,4 +48,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
4 changes: 2 additions & 2 deletions yarn-project/simulator/docs/avm/opcodes/jumpi.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Jumps to the specified location if the condition is non-zero (true). The conditi
| DA Base | 0 | - |
| L2 Addressing | 3 | 3 L2 gas per indirect memory offset<br/>3 L2 gas per relative memory offset |

*See [Gas Metering](gas.md) for details on how gas costs are computed and applied.
\* See [Gas Metering](gas.md) for details on how gas costs are computed and applied.

## Operands

Expand Down Expand Up @@ -87,4 +87,4 @@ packet-beta

---

[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
[&larr; Back to Instruction Set: Quick Reference](../avm-isa-quick-reference.md)
Loading
Loading