Skip to content

Commit

Permalink
chore: remove usage of debug and header oracles in contracts which ar…
Browse files Browse the repository at this point in the history
…en't yet supported by AVM
  • Loading branch information
dbanks12 committed May 7, 2024
1 parent ead54c4 commit 7948274
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
5 changes: 1 addition & 4 deletions noir-projects/aztec-nr/aztec/src/context/interface.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use dep::protocol_types::{
abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}, header::Header,
traits::Deserialize
};
use dep::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}, traits::Deserialize};

use crate::context::private_context::PrivateContext;
use crate::context::public_context::PublicContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ contract GasToken {
fn pay_fee(fee_limit: Field) -> Field {
let fee_limit_u128 = U128::from_integer(fee_limit);
let fee = U128::from_integer(calculate_fee(context));
dep::aztec::oracle::debug_log::debug_log_format(
"Gas token: paying fee {0} (limit {1})",
[fee.to_field(), fee_limit]
);
// TODO(6252): implement debug logging in AVM
//dep::aztec::oracle::debug_log::debug_log_format(
// "Gas token: paying fee {0} (limit {1})",
// [fee.to_field(), fee_limit]
//);
assert(fee <= fee_limit_u128, "Fee too high");

let sender_new_balance = storage.balances.at(context.msg_sender()).read() - fee;
Expand Down
23 changes: 13 additions & 10 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ contract Test {
use dep::aztec::protocol_types::{
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs,
constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, CANONICAL_KEY_REGISTRY_ADDRESS},
traits::{Serialize, ToField, FromField}, grumpkin_point::GrumpkinPoint, grumpkin_private_key::GrumpkinPrivateKey
traits::{Serialize, ToField, FromField}, grumpkin_point::GrumpkinPoint,
grumpkin_private_key::GrumpkinPrivateKey
};

use dep::aztec::encrypted_logs::header::EncryptedLogHeader;
Expand Down Expand Up @@ -375,10 +376,11 @@ contract Test {
assert(context.historical_header.hash() == header_hash, "Invalid header hash");
}

#[aztec(public)]
fn assert_header_public(header_hash: Field) {
assert(context.historical_header.hash() == header_hash, "Invalid header hash");
}
// TODO(4840): add AVM opcodes for getting header (members)
//#[aztec(public)]
//fn assert_header_public(header_hash: Field) {
// assert(context.historical_header.hash() == header_hash, "Invalid header hash");
//}

#[aztec(private)]
fn deploy_contract(target: AztecAddress) {
Expand Down Expand Up @@ -431,15 +433,16 @@ contract Test {
let derived_slot = derive_storage_slot_in_map(storage_slot_of_shared_mutable, address_to_get_in_registry);

// It's a bit wonky because we need to know the delay for get_current_value_in_private to work correctly
let registry_private_getter: SharedMutablePrivateGetter<Field, 5> = SharedMutablePrivateGetter::new(context, AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS), derived_slot);
let registry_private_getter: SharedMutablePrivateGetter<Field, 5> = SharedMutablePrivateGetter::new(
context,
AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS),
derived_slot
);
registry_private_getter.get_current_value_in_private()
}

#[aztec(private)]
fn test_nullifier_key_freshness(
address: AztecAddress,
public_nullifying_key: GrumpkinPoint,
) {
fn test_nullifier_key_freshness(address: AztecAddress, public_nullifying_key: GrumpkinPoint) {
assert_eq(get_npk_m(&mut context, address), public_nullifying_key);
}

Expand Down
3 changes: 2 additions & 1 deletion noir-projects/noir-contracts/scripts/transpile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -eu

TRANSPILER=${TRANSPILER:-../../avm-transpiler/target/release/avm-transpiler}
ls target/avm_*.json | parallel "$TRANSPILER {} {}"
ls target/*.json | parallel "$TRANSPILER {} {}"

3 changes: 2 additions & 1 deletion yarn-project/simulator/src/public/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ describe('ACIR public execution simulator', () => {
});
});

describe('Historical header in public context', () => {
// TODO(4840): add AVM opcodes for getting header (members)
describe.skip('Historical header in public context', () => {
let contractAddress: AztecAddress;
let callContext: CallContext;
let assertHeaderPublicArtifact: FunctionArtifact;
Expand Down

0 comments on commit 7948274

Please sign in to comment.