Skip to content

Commit

Permalink
feat!: switch public to use the AVM
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed May 16, 2024
1 parent e7a0d13 commit 2a8da61
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,7 @@ New L2 to L1 messages contains messages that are delivered to the [l1 outbox](/a

## Public Context

The Public Context includes all of the information passed from the `Public VM` into the execution environment. It is very similar to the [Private Context](#the-private-context), however it has some minor differences (detailed below).

### Public Context Inputs

In the current version of the system, the public context is almost a clone of the private execution context.

#include_code public-context-inputs /noir-projects/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr rust
The Public Context includes all of the information passed from the `Public VM` into the execution environment. It's interface is very similar to the [Private Context](#the-private-context), however it has some minor differences (detailed below).

### Public Global Variables

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use dep::protocol_types::traits::Empty;

// These inputs will likely go away once the AVM processes 1 public kernel per enqueued call.
struct PublicContextInputs {
selector: Field,
args_hash: Field,
Expand Down
44 changes: 22 additions & 22 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -200,75 +200,75 @@ fn gas_for_call(user_gas: GasOpts) -> [Field; 2] {

// Unconstrained opcode wrappers (do not use directly).
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6420): reconsider.
fn address() -> AztecAddress {
unconstrained fn address() -> AztecAddress {
address_opcode()
}
fn storage_address() -> AztecAddress {
unconstrained fn storage_address() -> AztecAddress {
storage_address_opcode()
}
fn sender() -> AztecAddress {
unconstrained fn sender() -> AztecAddress {
sender_opcode()
}
fn portal() -> EthAddress {
unconstrained fn portal() -> EthAddress {
portal_opcode()
}
fn fee_per_l2_gas() -> Field {
unconstrained fn fee_per_l2_gas() -> Field {
fee_per_l2_gas_opcode()
}
fn fee_per_da_gas() -> Field {
unconstrained fn fee_per_da_gas() -> Field {
fee_per_da_gas_opcode()
}
fn transaction_fee() -> Field {
unconstrained fn transaction_fee() -> Field {
transaction_fee_opcode()
}
fn chain_id() -> Field {
unconstrained fn chain_id() -> Field {
chain_id_opcode()
}
fn version() -> Field {
unconstrained fn version() -> Field {
version_opcode()
}
fn block_number() -> Field {
unconstrained fn block_number() -> Field {
block_number_opcode()
}
fn timestamp() -> u64 {
unconstrained fn timestamp() -> u64 {
timestamp_opcode()
}
fn l2_gas_left() -> Field {
unconstrained fn l2_gas_left() -> Field {
l2_gas_left_opcode()
}
fn da_gas_left() -> Field {
unconstrained fn da_gas_left() -> Field {
da_gas_left_opcode()
}
fn note_hash_exists(note_hash: Field, leaf_index: Field) -> u8 {
unconstrained fn note_hash_exists(note_hash: Field, leaf_index: Field) -> u8 {
note_hash_exists_opcode(note_hash, leaf_index)
}
fn emit_note_hash(note_hash: Field) {
unconstrained fn emit_note_hash(note_hash: Field) {
emit_note_hash_opcode(note_hash)
}
fn nullifier_exists(nullifier: Field, address: Field) -> u8 {
unconstrained fn nullifier_exists(nullifier: Field, address: Field) -> u8 {
nullifier_exists_opcode(nullifier, address)
}
fn emit_nullifier(nullifier: Field) {
unconstrained fn emit_nullifier(nullifier: Field) {
emit_nullifier_opcode(nullifier)
}
fn emit_unencrypted_log<T>(event_selector: Field, message: T) {
unconstrained fn emit_unencrypted_log<T>(event_selector: Field, message: T) {
emit_unencrypted_log_opcode(event_selector, message)
}
fn l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> u8 {
unconstrained fn l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> u8 {
l1_to_l2_msg_exists_opcode(msg_hash, msg_leaf_index)
}
fn send_l2_to_l1_msg(recipient: EthAddress, content: Field) {
unconstrained fn send_l2_to_l1_msg(recipient: EthAddress, content: Field) {
send_l2_to_l1_msg_opcode(recipient, content)
}
fn call<RET_SIZE>(
unconstrained fn call<RET_SIZE>(
gas: [Field; 2],
address: AztecAddress,
args: [Field],
function_selector: Field
) -> ([Field; RET_SIZE], u8) {
call_opcode(gas, address, args, function_selector)
}
fn call_static<RET_SIZE>(
unconstrained fn call_static<RET_SIZE>(
gas: [Field; 2],
address: AztecAddress,
args: [Field],
Expand Down

0 comments on commit 2a8da61

Please sign in to comment.