diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index 814471cf870..24f1579974a 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -29,7 +29,7 @@ impl PublicContext { * @param event_selector The event selector for the log. * @param message The message to emit in the log. */ - pub fn emit_unencrypted_log_with_selector( + pub fn emit_unencrypted_log_with_selector( &mut self, event_selector: Field, log: T @@ -37,7 +37,7 @@ impl PublicContext { emit_unencrypted_log(event_selector, Serialize::serialize(log).as_slice()); } // For compatibility with the selector-less API. We'll probably rename the above one. - pub fn emit_unencrypted_log(&mut self, log: T) where T: Serialize { + pub fn emit_unencrypted_log(&mut self, log: T) where T: Serialize { self.emit_unencrypted_log_with_selector(/*event_selector=*/ 5, log); } pub fn note_hash_exists(self, note_hash: Field, leaf_index: Field) -> bool { @@ -169,6 +169,12 @@ impl PublicContext { fn get_args_hash(self) -> Field { self.inputs.args_hash } + fn l2_gas_left(self) -> Field { + l2_gas_left() + } + fn da_gas_left(self) -> Field { + da_gas_left() + } } // Helper functions @@ -368,4 +374,4 @@ impl FunctionReturns { pub fn deserialize_into(self) -> T where T: Deserialize { Deserialize::deserialize(self.raw()) } -} \ No newline at end of file +} diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index befe4412f0b..c3d31d3e507 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -281,6 +281,16 @@ contract AvmTest { context.timestamp() } + #[aztec(public)] + fn get_l2_gas_left() -> Field { + context.l2_gas_left() + } + + #[aztec(public)] + fn get_da_gas_left() -> Field { + context.da_gas_left() + } + // #[aztec(public)] // fn get_contract_call_depth() -> Field { // context.contract_call_depth() diff --git a/yarn-project/bb-prover/src/avm_proving.test.ts b/yarn-project/bb-prover/src/avm_proving.test.ts index 40ebc18d6e9..a11bd6e27ff 100644 --- a/yarn-project/bb-prover/src/avm_proving.test.ts +++ b/yarn-project/bb-prover/src/avm_proving.test.ts @@ -127,6 +127,51 @@ describe('AVM WitGen, proof generation and verification', () => { // ) }); +it.skip( + 'Should prove a keccak hash evaluation', + async () => { + await proveAndVerifyAvmTestContract('keccak_hash', [ + new Fr(0), + new Fr(1), + new Fr(2), + new Fr(3), + new Fr(4), + new Fr(5), + new Fr(6), + new Fr(7), + new Fr(8), + new Fr(9), + ]); + }, + TIMEOUT, +); + +/************************************************************************ + * AvmContext functions + ************************************************************************/ +const avmContextFunctions = [ + 'get_address', + 'get_storage_address', + 'get_sender', + 'get_fee_per_l2_gas', + 'get_fee_per_da_gas', + 'get_transaction_fee', + 'get_chain_id', + 'get_version', + 'get_block_number', + 'get_timestamp', + 'get_l2_gas_left', + 'get_da_gas_left', +]; + +it.each(avmContextFunctions)( + 'Should prove an avm context function %s', + async contextFunction => { + await proveAndVerifyAvmTestContract(contextFunction); + }, + TIMEOUT, +); + const proveAndVerifyAvmTestContract = async (functionName: string, calldata: Fr[] = []) => { const startSideEffectCounter = 0; const environment = initExecutionEnvironment({ calldata });