diff --git a/docs/docs/concepts/foundation/accounts/main.md b/docs/docs/concepts/foundation/accounts/main.md index 5f6b1cf8595..5317f784af1 100644 --- a/docs/docs/concepts/foundation/accounts/main.md +++ b/docs/docs/concepts/foundation/accounts/main.md @@ -98,7 +98,12 @@ A side-effect of not having nonces at the protocol level is that it is not possi Since the `entrypoint` interface is not enshrined, there is nothing that differentiates an account contract from an application one in the protocol. This means that a transaction can be initiated in any contract. This allows implementing functions that do not need to be called by any particular user and are just intended to advance the state of a contract. -As an example, we can think of a lottery contract, where at some point a prize needs to be paid out to its winners. This `pay` action does not require authentication and does not need to be executed by any user in particular, so anyone could submit a transaction that defines the lottery contract itself as `origin` and `pay` as entrypoint function. For an example implementation of a different use case, refer to the [`pokeable_token_contract`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr) in the repository. +As an example, we can think of a lottery contract, where at some point a prize needs to be paid out to its winners. This `pay` action does not require authentication and does not need to be executed by any user in particular, so anyone could submit a transaction that defines the lottery contract itself as `origin` and `pay` as entrypoint function. For an example of this behavior see our [non_contract_account test](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts) and the [SignerLess wallet](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/wallet/signerless_wallet.ts) implementation. +Notice that the Signerless wallet doesn't invoke an entrypoint function of an account contract but instead invokes the target contract function directly. + +:::info +In case no contract entrypoint is used `msg_sender` is set to 0. +::: ### Account initialization diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index f5ecbb713f9..6e660ce2ead 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -421,7 +421,7 @@ describe('Private Execution test suite', () => { const dummyNote = { amount: 1, secretHash: 2 }; const deepStruct = { aField: 1, aBool: true, aNote: dummyNote, manyNotes: [dummyNote, dummyNote, dummyNote] }; args = [1, true, 1, [1, 2], dummyNote, deepStruct]; - testCodeGenArtifact = TestContractArtifact.functions.find(f => f.name === 'testCodeGen')!; + testCodeGenArtifact = TestContractArtifact.functions.find(f => f.name === 'test_code_gen')!; const serializedArgs = encodeArguments(testCodeGenArtifact, args); argsHash = await computeVarArgsHash(await CircuitsWasm.get(), serializedArgs); }); @@ -786,7 +786,7 @@ describe('Private Execution test suite', () => { describe('get public key', () => { it('gets the public key for an address', async () => { // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'getPublicKey'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_public_key'); artifact.returnTypes = [{ kind: 'array', length: 2, type: { kind: 'field' } }]; // Generate a partial address, pubkey, and resulting address @@ -806,7 +806,7 @@ describe('Private Execution test suite', () => { const aztecAddressToQuery = AztecAddress.random(); // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'getPortalContractAddress'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_portal_contract_address'); artifact.returnTypes = [{ kind: 'field' }]; const args = [aztecAddressToQuery.toField()]; @@ -821,7 +821,7 @@ describe('Private Execution test suite', () => { const contractAddress = AztecAddress.random(); // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'getThisAddress'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_this_address'); artifact.returnTypes = [{ kind: 'field' }]; // Overwrite the oracle return value @@ -833,7 +833,7 @@ describe('Private Execution test suite', () => { const portalContractAddress = EthAddress.random(); // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'getThisPortalAddress'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_this_portal_address'); artifact.returnTypes = [{ kind: 'field' }]; // Overwrite the oracle return value diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 0fd804b42d8..a84c28071e6 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -343,7 +343,7 @@ describe('ACIR public execution simulator', () => { it('Should be able to create a L2 to L1 message from the public context', async () => { const createL2ToL1MessagePublicArtifact = TestContractArtifact.functions.find( - f => f.name === 'createL2ToL1MessagePublic', + f => f.name === 'create_l2_to_l1_message_public', )!; const args = encodeArguments(createL2ToL1MessagePublicArtifact, params); @@ -429,7 +429,7 @@ describe('ACIR public execution simulator', () => { it('Should be able to create a nullifier from the public context', async () => { const createNullifierPublicArtifact = TestContractArtifact.functions.find( - f => f.name === 'createNullifierPublic', + f => f.name === 'create_nullifier_public', )!; const args = encodeArguments(createNullifierPublicArtifact, params); diff --git a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts index 0a66236dd0d..8a4af3d7c4b 100644 --- a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts +++ b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts @@ -105,7 +105,6 @@ ImportTestContractArtifact LendingContractArtifact ParentContractArtifact PendingCommitmentsContractArtifact -PokeableTokenContractArtifact PriceFeedContractArtifact SchnorrAccountContractArtifact SchnorrHardcodedAccountContractArtifact diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 4920384d1c0..65e11066e01 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -119,7 +119,7 @@ describe('e2e_block_building', () => { it('drops tx with public nullifier already emitted on the same block', async () => { const secret = Fr.random(); - const calls = times(2, () => contract.methods.createNullifierPublic(140n, secret)); + const calls = times(2, () => contract.methods.create_nullifier_public(140n, secret)); for (const call of calls) await call.simulate(); const [tx1, tx2] = calls.map(call => call.send()); await tx1.wait(); @@ -141,7 +141,7 @@ describe('e2e_block_building', () => { ); const calls = [ - contract.methods.createNullifierPublic(140n, secret), + contract.methods.create_nullifier_public(140n, secret), contract.methods.emit_nullifier(emittedPublicNullifier), ]; diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 3cc9079d287..f9b3c39f7e8 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -149,13 +149,13 @@ describe('e2e_cheat_codes', () => { expect(Number(await rollup.read.lastBlockTs())).toEqual(newTimestamp); expect(Number(await rollup.read.lastWarpedBlockTs())).toEqual(newTimestamp); - const txIsTimeEqual = contract.methods.isTimeEqual(newTimestamp).send(); + const txIsTimeEqual = contract.methods.is_time_equal(newTimestamp).send(); const isTimeEqualReceipt = await txIsTimeEqual.wait({ interval: 0.1 }); expect(isTimeEqualReceipt.status).toBe(TxStatus.MINED); // Since last rollup block was warped, txs for this rollup will have time incremented by 1 // See https://github.com/AztecProtocol/aztec-packages/issues/1614 for details - const txTimeNotEqual = contract.methods.isTimeEqual(newTimestamp + 1).send(); + const txTimeNotEqual = contract.methods.is_time_equal(newTimestamp + 1).send(); const isTimeNotEqualReceipt = await txTimeNotEqual.wait({ interval: 0.1 }); expect(isTimeNotEqualReceipt.status).toBe(TxStatus.MINED); // block is published at t >= newTimestamp + 1. diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 8304e87dc33..c4bff39a70d 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -82,7 +82,7 @@ describe('e2e_deploy_contract', () => { const contract = await Contract.at(receipt.contractAddress!, TestContractArtifact, wallet); logger(`Sending TX to contract ${index + 1}...`); - await contract.methods.getPublicKey(accounts[0].address).send().wait(); + await contract.methods.get_public_key(accounts[0].address).send().wait(); } }, 30_000); diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index 9a40f277243..2b2b486fbf0 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -1,63 +1,46 @@ -import { AztecAddress, SignerlessWallet, Wallet } from '@aztec/aztec.js'; +import { SignerlessWallet, Wallet } from '@aztec/aztec.js'; +import { CircuitsWasm, Fr } from '@aztec/circuits.js'; +import { siloNullifier } from '@aztec/circuits.js/abis'; import { DebugLogger } from '@aztec/foundation/log'; -import { PokeableTokenContract } from '@aztec/noir-contracts/types'; -import { AztecNode, CompleteAddress, PXE, TxStatus } from '@aztec/types'; +import { TestContract } from '@aztec/noir-contracts/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; -import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_non_contract_account', () => { let aztecNode: AztecNode | undefined; let pxe: PXE; - let wallet: Wallet; - let sender: AztecAddress; - let recipient: AztecAddress; - let pokerWallet: Wallet; + let nonContractAccountWallet: Wallet; let teardown: () => Promise; let logger: DebugLogger; - let contract: PokeableTokenContract; - - const initialBalance = 987n; + let contract: TestContract; beforeEach(async () => { - let accounts: CompleteAddress[]; - ({ teardown, aztecNode, pxe, accounts, wallet, logger } = await setup(2)); - sender = accounts[0].address; - recipient = accounts[1].address; - pokerWallet = new SignerlessWallet(pxe); + let wallet: Wallet; + ({ teardown, aztecNode, pxe, wallet, logger } = await setup(1)); + nonContractAccountWallet = new SignerlessWallet(pxe); logger(`Deploying L2 contract...`); - const tx = PokeableTokenContract.deploy(pxe, initialBalance, sender, recipient).send(); - await tx.isMined({ interval: 0.1 }); - const receipt = await tx.getReceipt(); - expect(receipt.status).toEqual(TxStatus.MINED); + contract = await TestContract.deploy(wallet).send().deployed(); logger('L2 contract deployed'); - contract = await PokeableTokenContract.at(receipt.contractAddress!, wallet); }, 100_000); afterEach(() => teardown()); - const expectBalance = async (owner: AztecAddress, expectedBalance: bigint) => { - const balance = await contract.methods.getBalance(owner).view({ from: owner }); - logger(`Account ${owner} balance: ${balance}`); - expect(balance).toBe(expectedBalance); - }; - it('Arbitrary non-contract account can call a private function on a contract', async () => { - await expectBalance(sender, initialBalance); - await expectBalance(recipient, 0n); - await expectsNumOfEncryptedLogsInTheLastBlockToBe(aztecNode, 1); - - const contractWithNoContractWallet = await PokeableTokenContract.at(contract.address, pokerWallet); + const contractWithNoContractWallet = await TestContract.at(contract.address, nonContractAccountWallet); - // Send transaction as poker (arbitrary non-contract account) - await contractWithNoContractWallet.methods.poke(sender, recipient).send().wait({ interval: 0.1 }); + // Send transaction as arbitrary non-contract account + const nullifier = new Fr(940); + const receipt = await contractWithNoContractWallet.methods.emit_nullifier(nullifier).send().wait({ interval: 0.1 }); + expect(receipt.status).toBe(TxStatus.MINED); - // Initial balance should be fully transferred to the recipient - await expectBalance(sender, 0n); - await expectBalance(recipient, initialBalance); + const tx = await aztecNode!.getTx(receipt.txHash); + const expectedSiloedNullifier = siloNullifier(await CircuitsWasm.get(), contract.address, nullifier); + const siloedNullifier = tx!.newNullifiers[1]; - await expectsNumOfEncryptedLogsInTheLastBlockToBe(aztecNode, 1); + expect(siloedNullifier.equals(expectedSiloedNullifier)).toBeTruthy(); }, 120_000); }); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 8f10f3e4ca0..92d3ed69e26 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -144,7 +144,7 @@ describe('guides/dapp/testing', () => { // docs:start:warp const newTimestamp = Math.floor(Date.now() / 1000) + 60 * 60 * 24; await cheats.aztec.warp(newTimestamp); - await testContract.methods.isTimeEqual(newTimestamp).send().wait(); + await testContract.methods.is_time_equal(newTimestamp).send().wait(); // docs:end:warp }); }); diff --git a/yarn-project/noir-contracts/Nargo.toml b/yarn-project/noir-contracts/Nargo.toml index 74708cbe79d..663bed76c2c 100644 --- a/yarn-project/noir-contracts/Nargo.toml +++ b/yarn-project/noir-contracts/Nargo.toml @@ -11,7 +11,6 @@ members = [ "src/contracts/lending_contract", "src/contracts/parent_contract", "src/contracts/pending_commitments_contract", - "src/contracts/pokeable_token_contract", "src/contracts/price_feed_contract", "src/contracts/schnorr_account_contract", "src/contracts/schnorr_hardcoded_account_contract", diff --git a/yarn-project/noir-contracts/src/contracts/import_test_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/import_test_contract/src/main.nr index 4e2ff6b772b..11247b403b6 100644 --- a/yarn-project/noir-contracts/src/contracts/import_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/import_test_contract/src/main.nr @@ -26,7 +26,7 @@ contract ImportTest { target: Field ) -> Field { let test_contract_instance = TestPrivateContextInterface::at(target); - let return_values = test_contract_instance.testCodeGen( + let return_values = test_contract_instance.test_code_gen( &mut context, 1, true, @@ -56,7 +56,7 @@ contract ImportTest { target: Field ) -> Field { let test_contract_instance = TestPrivateContextInterface::at(target); - let return_values = test_contract_instance.getThisAddress(&mut context); + let return_values = test_contract_instance.get_this_address(&mut context); return_values[0] } @@ -69,7 +69,7 @@ contract ImportTest { target: Field, ) { let test_contract_instance = TestPrivateContextInterface::at(target); - test_contract_instance.createNullifierPublic(&mut context, 1, 2); + test_contract_instance.create_nullifier_public(&mut context, 1, 2); } // Calls the createNullifierPublic on the Test contract at the target address @@ -80,7 +80,7 @@ contract ImportTest { target: Field, ) -> Field { let test_contract_instance = TestPublicContextInterface::at(target); - let ret = test_contract_instance.createNullifierPublic(context, 1, 2); + let ret = test_contract_instance.create_nullifier_public(context, 1, 2); ret[0] } diff --git a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/Nargo.toml b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/Nargo.toml deleted file mode 100644 index 5d8e70f060d..00000000000 --- a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/Nargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "pokeable_token_contract" -authors = [""] -compiler_version = "0.1" -type = "contract" - -[dependencies] -aztec = { path = "../../../../aztec-nr/aztec" } -address_note = { path = "../../../../aztec-nr/address-note"} -value_note = { path = "../../../../aztec-nr/value-note"} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr deleted file mode 100644 index fb3fd533845..00000000000 --- a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr +++ /dev/null @@ -1,125 +0,0 @@ -contract PokeableToken { - // Libs - use dep::std::option::Option; - use dep::value_note::{ - balance_utils, - utils::increment, - value_note::{VALUE_NOTE_LEN, ValueNoteMethods, ValueNote}, - }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - note::{ - note_getter::NoteGetterOptions, - note_header::{NoteHeader}, - utils as note_utils, - }, - state_vars::{immutable_singleton::ImmutableSingleton, map::Map, set::Set}, - types::point::Point, - }; - use dep::address_note::address_note::{ - AddressNote, - AddressNoteMethods, - ADDRESS_NOTE_LEN, - }; - - struct Storage { - sender: ImmutableSingleton, - recipient: ImmutableSingleton, - balances: Map>, - } - - impl Storage { - fn init(context: Context) -> pub Self { - Storage { - sender: ImmutableSingleton::new(context, 1, AddressNoteMethods), - recipient: ImmutableSingleton::new(context, 2, AddressNoteMethods), - balances: Map::new( - context, - 3, - |context, slot| { - Set::new(context, slot, ValueNoteMethods) - }, - ), - } - } - } - - // Constructs the contract and sets `initial_supply` which is fully owned by `sender`. - #[aztec(private)] - fn constructor( - initial_supply: Field, - sender: Field, - recipient: Field - ) { - let mut sender_note = AddressNote::new(sender, sender); - let mut recipient_note = AddressNote::new(recipient, recipient); - - storage.sender.initialize(&mut sender_note, Option::none(), false); - storage.recipient.initialize(&mut recipient_note, Option::none(), false); - - // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. - let sender_balance = storage.balances.at(sender); - increment(sender_balance, initial_supply, sender); - } - - // Transfers full balance of tokens from `sender` to a `recipient`. - #[aztec(private)] - fn poke( - sender: Field, - recipient: Field - ) { - // TODO: This check is not satisfying constraints - // let mut sender_note = AddressNote::new(sender); - // storage.sender.assert_contains(&mut context, &mut sender_note); - // let mut recipient_note = AddressNote::new(recipient); - // storage.recipient.assert_contains(&mut context, &mut recipient_note); - - // Pick from the set of sender's notes. - let sender_balance = storage.balances.at(sender); - - let options = NoteGetterOptions::new(); - let maybe_notes = sender_balance.get_notes(options); - let mut note_sum = 0; - for i in 0..maybe_notes.len() { - if maybe_notes[i].is_some() { - let note = maybe_notes[i].unwrap_unchecked(); - - // Ensure the notes are actually owned by the owner (to prevent user from generating a valid proof while - // spending someone else's notes). - assert(note.owner == sender); - - // Removes the note from the owner's set of notes. - sender_balance.remove(note); - - note_sum += note.value; - } - } - - // Create new note for the recipient. - let recipient_balance = storage.balances.at(recipient); - increment(recipient_balance, note_sum, recipient); - } - - // Helper function to get the balance of a user ("unconstrained" is a Noir alternative of Solidity's "view" function). - unconstrained fn getBalance( - sender: Field, - ) -> Field { - // Get the set of notes owned by the user. - let sender_balance = storage.balances.at(sender); - - // Return the sum of all notes in the set. - balance_utils::get_balance(sender_balance) - } - - // Computes note hash and nullifier. - // Note 1: Needs to be defined by every contract producing logs. - // Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes. - unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] { - let note_header = NoteHeader::new(contract_address, nonce, storage_slot); - if (storage_slot == 1) | (storage_slot == 2) { - note_utils::compute_note_hash_and_nullifier(AddressNoteMethods, note_header, preimage) - } else { - note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, preimage) - } - } -} diff --git a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr index 2a8addc00e9..b1a55a1070c 100644 --- a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr @@ -79,7 +79,7 @@ impl TestPrivateContextInterface { } - pub fn createL2ToL1MessagePublic( + pub fn create_l2_to_l1_message_public( self, context: &mut PrivateContext, amount: Field, @@ -89,11 +89,11 @@ impl TestPrivateContextInterface { serialized_args[0] = amount; serialized_args[1] = secretHash; - context.call_public_function(self.address, 0xbac98727, serialized_args) + context.call_public_function(self.address, 0x9749ca06, serialized_args) } - pub fn createNullifierPublic( + pub fn create_nullifier_public( self, context: &mut PrivateContext, amount: Field, @@ -103,7 +103,7 @@ impl TestPrivateContextInterface { serialized_args[0] = amount; serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x42040a24, serialized_args) + context.call_public_function(self.address, 0xdf02db8d, serialized_args) } @@ -131,7 +131,7 @@ impl TestPrivateContextInterface { } - pub fn getPortalContractAddress( + pub fn get_portal_contract_address( self, context: &mut PrivateContext, aztec_address: Field @@ -139,11 +139,11 @@ impl TestPrivateContextInterface { let mut serialized_args = [0; 1]; serialized_args[0] = aztec_address; - context.call_private_function(self.address, 0xaf15a45f, serialized_args) + context.call_private_function(self.address, 0x98ff64fd, serialized_args) } - pub fn getPublicKey( + pub fn get_public_key( self, context: &mut PrivateContext, address: Field @@ -151,31 +151,31 @@ impl TestPrivateContextInterface { let mut serialized_args = [0; 1]; serialized_args[0] = address; - context.call_private_function(self.address, 0x88f0753b, serialized_args) + context.call_private_function(self.address, 0x5ccf578f, serialized_args) } - pub fn getThisAddress( + pub fn get_this_address( self, context: &mut PrivateContext ) -> [Field; RETURN_VALUES_LENGTH] { let mut serialized_args = [0; 0]; - context.call_private_function(self.address, 0xd3953822, serialized_args) + context.call_private_function(self.address, 0x95a7b2ae, serialized_args) } - pub fn getThisPortalAddress( + pub fn get_this_portal_address( self, context: &mut PrivateContext ) -> [Field; RETURN_VALUES_LENGTH] { let mut serialized_args = [0; 0]; - context.call_private_function(self.address, 0x82cc9431, serialized_args) + context.call_private_function(self.address, 0xc71384f5, serialized_args) } - pub fn isTimeEqual( + pub fn is_time_equal( self, context: &mut PrivateContext, time: Field @@ -183,11 +183,11 @@ impl TestPrivateContextInterface { let mut serialized_args = [0; 1]; serialized_args[0] = time; - context.call_public_function(self.address, 0xfff6026c, serialized_args) + context.call_public_function(self.address, 0x61fa2bda, serialized_args) } - pub fn testCodeGen( + pub fn test_code_gen( self, context: &mut PrivateContext, aField: Field, @@ -216,7 +216,7 @@ impl TestPrivateContextInterface { serialized_args[15] = aDeepStruct.manyNotes[2].amount; serialized_args[16] = aDeepStruct.manyNotes[2].secretHash; - context.call_private_function(self.address, 0x81d7c118, serialized_args) + context.call_private_function(self.address, 0x0f054f9b, serialized_args) } } @@ -256,7 +256,7 @@ impl TestPublicContextInterface { } - pub fn createL2ToL1MessagePublic( + pub fn create_l2_to_l1_message_public( self, context: PublicContext, amount: Field, @@ -266,11 +266,11 @@ impl TestPublicContextInterface { serialized_args[0] = amount; serialized_args[1] = secretHash; - context.call_public_function(self.address, 0xbac98727, serialized_args) + context.call_public_function(self.address, 0x9749ca06, serialized_args) } - pub fn createNullifierPublic( + pub fn create_nullifier_public( self, context: PublicContext, amount: Field, @@ -280,7 +280,7 @@ impl TestPublicContextInterface { serialized_args[0] = amount; serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x42040a24, serialized_args) + context.call_public_function(self.address, 0xdf02db8d, serialized_args) } @@ -296,7 +296,7 @@ impl TestPublicContextInterface { } - pub fn isTimeEqual( + pub fn is_time_equal( self, context: PublicContext, time: Field @@ -304,7 +304,7 @@ impl TestPublicContextInterface { let mut serialized_args = [0; 1]; serialized_args[0] = time; - context.call_public_function(self.address, 0xfff6026c, serialized_args) + context.call_public_function(self.address, 0x61fa2bda, serialized_args) } } diff --git a/yarn-project/noir-contracts/src/contracts/test_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/test_contract/src/main.nr index 82a276afddb..e0456f5fa6b 100644 --- a/yarn-project/noir-contracts/src/contracts/test_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/test_contract/src/main.nr @@ -9,7 +9,7 @@ contract Test { abi::PrivateContextInputs, context::PrivateContext, oracle::{ - get_public_key::get_public_key, + get_public_key::get_public_key as get_public_key_oracle, context::get_portal_address, rand::rand }, @@ -29,17 +29,17 @@ contract Test { // docs:end:empty-constructor #[aztec(private)] - fn getPublicKey( + fn get_public_key( address: Field, ) -> [Field; 2]{ - let pub_key = get_public_key(address); + let pub_key = get_public_key_oracle(address); [pub_key.x, pub_key.y] } // Get the portal contract address through an oracle call #[aztec(private)] - fn getPortalContractAddress( + fn get_portal_contract_address( aztec_address: Field ) -> Field { get_portal_address(aztec_address) @@ -47,20 +47,20 @@ contract Test { // Get the address of the l1 portal for this contract (taken from the input context) #[aztec(private)] - fn getThisPortalAddress() -> Field { + fn get_this_portal_address() -> Field { context.this_portal_address() } // Get the address of this contract (taken from the input context) #[aztec(private)] - fn getThisAddress() -> Field { + fn get_this_address() -> Field { context.this_address() } // Test codegen for Aztec.nr interfaces // See yarn-project/acir-simulator/src/client/private_execution.test.ts 'nested calls through autogenerated interface' // Note; this function is deliberately NOT annotated with #[aztec(private)] due to its use in tests - fn testCodeGen( + fn test_code_gen( inputs: PrivateContextInputs, aField: Field, aBool: bool, @@ -92,7 +92,7 @@ contract Test { // Purely exists for testing #[aztec(public)] - fn createL2ToL1MessagePublic( + fn create_l2_to_l1_message_public( amount: Field, secretHash: Field, ) { @@ -106,7 +106,7 @@ contract Test { // Purely exists for testing #[aztec(public)] - fn createNullifierPublic( + fn create_nullifier_public( amount: Field, secretHash: Field, ) { @@ -125,7 +125,7 @@ contract Test { // docs:start:is-time-equal #[aztec(public)] - fn isTimeEqual( + fn is_time_equal( time: Field, ) -> Field { assert(context.timestamp() == time); @@ -170,7 +170,7 @@ contract Test { } // Purely exists for testing - unconstrained fn getRandom( + unconstrained fn get_random( kindaSeed: Field ) -> Field { kindaSeed * rand()