Skip to content

Commit

Permalink
chore(avm): enable tag checking and some proving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed Jun 7, 2024
1 parent db49ed5 commit 4715e08
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 468 deletions.
2 changes: 0 additions & 2 deletions noir-projects/noir-contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ members = [
"contracts/auth_contract",
"contracts/avm_initializer_test_contract",
"contracts/avm_test_contract",
"contracts/avm_nested_calls_test_contract",
"contracts/avm_acvm_interop_test_contract",
"contracts/fpc_contract",
"contracts/benchmarking_contract",
"contracts/card_game_contract",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ contract AvmTest {
use dep::aztec::protocol_types::{address::{AztecAddress, EthAddress}, constants::L1_TO_L2_MESSAGE_LENGTH};
use dep::aztec::oracle::get_contract_instance::{get_contract_instance_avm, get_contract_instance_internal_avm};
use dep::aztec::protocol_types::abis::function_selector::FunctionSelector;
use dep::aztec::context::gas::GasOpts;
use dep::compressed_string::CompressedString;

#[aztec(storage)]
Expand Down Expand Up @@ -178,6 +179,12 @@ contract AvmTest {
dep::aztec::oracle::debug_log::debug_log("tabs and newlines\n\t- first\n\t- second");
}

#[aztec(public)]
fn assert_same(arg_a: Field, arg_b: Field) -> pub Field {
assert(arg_a == arg_b, "Values are not equal");
1
}

/************************************************************************
* Hashing functions
************************************************************************/
Expand Down Expand Up @@ -291,11 +298,6 @@ contract AvmTest {
context.da_gas_left()
}

// #[aztec(public)]
// fn get_contract_call_depth() -> Field {
// context.contract_call_depth()
// }

#[aztec(public)]
fn check_selector() {
assert(
Expand Down Expand Up @@ -370,6 +372,49 @@ contract AvmTest {
context.message_portal(recipient, content)
}

/************************************************************************
* Nested calls
************************************************************************/
#[aztec(public)]
fn nested_call_to_add_with_gas(
arg_a: Field,
arg_b: Field,
l2_gas: Field,
da_gas: Field
) -> pub Field {
AvmTest::at(context.this_address()).add_args_return(arg_a, arg_b).with_gas(GasOpts::new(l2_gas, da_gas)).call(&mut context)
}

// Use the `call_public_function` wrapper to initiate a nested call to the add function
#[aztec(public)]
fn nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field {
AvmTest::at(context.this_address()).add_args_return(arg_a, arg_b).call(&mut context)
}

// Indirectly call_static the external call opcode to initiate a nested call to the add function
#[aztec(public)]
fn nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field {
AvmTest::at(context.this_address()).add_args_return(arg_a, arg_b).view(&mut context)
}

// Indirectly call_static `set_storage_single`. Should revert since it's accessing storage.
#[aztec(public)]
fn nested_static_call_to_set_storage() {
AvmTest::at(context.this_address()).set_storage_single(20).view(&mut context);
}

#[aztec(public)]
fn create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) {
context.push_new_nullifier(nullifier, 0);
AvmTest::at(nestedAddress).new_nullifier(nullifier).call(&mut context);
}

#[aztec(public)]
fn create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) {
context.push_new_nullifier(nullifier, 0);
AvmTest::at(nestedAddress).new_nullifier(nullifier + 1).call(&mut context);
}

/**
* Enqueue a public call from private
*/
Expand Down
Loading

0 comments on commit 4715e08

Please sign in to comment.