diff --git a/docs/docs/developers/contracts/writing_contracts/events/emit_event.md b/docs/docs/developers/contracts/writing_contracts/events/emit_event.md index 6fcb7bb8b8c9..3ef4105411be 100644 --- a/docs/docs/developers/contracts/writing_contracts/events/emit_event.md +++ b/docs/docs/developers/contracts/writing_contracts/events/emit_event.md @@ -20,24 +20,7 @@ Encrypted events can only be emitted by private functions and are encrypted usin For this reason it is necessary to register a recipient in the Private Execution Environment (PXE) before encrypting the events for them. Recipients can be registered using Aztec.js: -```ts -const aztecAddress = AztecAddress.fromString( - "0x147392a39e593189902458f4303bc6e0a39128c5a1c1612f76527a162d36d529" -); -const publicKey = Point.fromString( - "0x26e193aef4f83c70651485b5526c6d01a36d763223ab24efd1f9ff91b394ac0c20ad99d0ef669dc0dde8d5f5996c63105de8e15c2c87d8260b9e6f02f72af622" -); -const partialAddress = Fr.fromString( - "0x200e9a6c2d2e8352012e51c6637659713d336405c29386c7c4ac56779ab54fa7" -); - -const completeAddress = new CompleteAddress( - aztecAddress, - publicKey, - partialKey -); -await pxe.registerRecipient(completeAddress); -``` +#include_code register-recipient yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts rust :::info If a note recipient is one of the accounts inside the PXE, we don't need to register it as a recipient because we already have the public key available. You can register a recipient as shown [here](../../deploying_contracts/how_to_deploy_contract.md) diff --git a/docs/docs/learn/concepts/accounts/keys.md b/docs/docs/learn/concepts/accounts/keys.md index edb90ad47d44..2da41177e67e 100644 --- a/docs/docs/learn/concepts/accounts/keys.md +++ b/docs/docs/learn/concepts/accounts/keys.md @@ -35,7 +35,7 @@ To retrieve them a developer can use one of the getters in aztec_nr: If the keys are registered in the key registry these methods can be called without any setup. If they are not there, it is necessary to first register the user as a recipient in our PXE by passing in the recipient's [complete address](#complete-address) as an argument: -#include_code key-getters /noir-projects/aztec-nr/aztec/src/keys/getters.nr rust +#include_code register-recipient yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts rust Simulator will then retrieve these keys via an oracle call from PXE during private function execution. diff --git a/yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts b/yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts index 6cdcf2ba2e8c..169a3cb78f75 100644 --- a/yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts +++ b/yarn-project/end-to-end/src/flakey_e2e_account_init_fees.test.ts @@ -1,11 +1,14 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr'; import { type AccountManager, + type AztecNode, type DebugLogger, + type DeployL1Contracts, ExtendedNote, Fr, NativeFeePaymentMethod, Note, + type PXE, PrivateFeePaymentMethod, PublicFeePaymentMethod, Schnorr, @@ -25,14 +28,7 @@ import { import { jest } from '@jest/globals'; -import { - type BalancesFn, - type EndToEndContext, - expectMapping, - getBalancesFn, - publicDeployAccounts, - setup, -} from './fixtures/utils.js'; +import { type BalancesFn, expectMapping, getBalancesFn, publicDeployAccounts, setup } from './fixtures/utils.js'; import { GasPortalTestingHarnessFactory, type IGasBridgingTestHarness } from './shared/gas_portal_test_harness.js'; const TOKEN_NAME = 'BananaCoin'; @@ -43,8 +39,11 @@ const BRIDGED_FPC_GAS = BigInt(10e12); jest.setTimeout(1_000_000); describe('e2e_fees_account_init', () => { - let ctx: EndToEndContext; let logger: DebugLogger; + let aztecNode: AztecNode; + let pxe: PXE; + let teardown: () => Promise; + let sequencer: Wallet; let sequencersAddress: AztecAddress; let alice: Wallet; @@ -84,22 +83,24 @@ describe('e2e_fees_account_init', () => { } beforeAll(async () => { - ctx = await setup(2, {}, {}, true); - logger = ctx.logger; - [sequencer, alice] = ctx.wallets; + let wallets: Wallet[]; + let wallet: Wallet; + let deployL1ContractsValues: DeployL1Contracts; + ({ logger, wallets, wallet, aztecNode, pxe, deployL1ContractsValues } = await setup(2, {}, {}, true)); + [sequencer, alice] = wallets; sequencersAddress = sequencer.getAddress(); - await ctx.aztecNode.setConfig({ + await aztecNode.setConfig({ feeRecipient: sequencersAddress, }); gasBridgeTestHarness = await GasPortalTestingHarnessFactory.create({ - aztecNode: ctx.aztecNode, - pxeService: ctx.pxe, - publicClient: ctx.deployL1ContractsValues.publicClient, - walletClient: ctx.deployL1ContractsValues.walletClient, - wallet: ctx.wallet, - logger: ctx.logger, + aztecNode, + pxeService: pxe, + publicClient: deployL1ContractsValues.publicClient, + walletClient: deployL1ContractsValues.walletClient, + wallet, + logger, mockL1: false, }); @@ -122,7 +123,7 @@ describe('e2e_fees_account_init', () => { gasBalances = getBalancesFn('⛽', gas.methods.balance_of_public, logger); }); - afterAll(() => ctx.teardown()); + afterAll(() => teardown()); beforeEach(() => { gasSettings = GasSettings.default(); @@ -130,7 +131,7 @@ describe('e2e_fees_account_init', () => { actualFee = 1n; bobsSecretKey = Fr.random(); bobsPrivateSigningKey = Fq.random(); - bobsAccountManager = getSchnorrAccount(ctx.pxe, bobsSecretKey, bobsPrivateSigningKey, Fr.random()); + bobsAccountManager = getSchnorrAccount(pxe, bobsSecretKey, bobsPrivateSigningKey, Fr.random()); bobsAddress = bobsAccountManager.getCompleteAddress().address; }); @@ -288,11 +289,13 @@ describe('e2e_fees_account_init', () => { const instance = bobsAccountManager.getInstance(); // and gives the public keys to alice + // docs:start:register-recipient const signingPubKey = new Schnorr().computePublicKey(bobsPrivateSigningKey); const completeAddress = CompleteAddress.fromSecretKeyAndInstance(bobsSecretKey, instance); - + // alice registers the keys in the PXE - await ctx.pxe.registerRecipient(completeAddress); + await pxe.registerRecipient(completeAddress); + // docs:end:register-recipient // and deploys bob's account, paying the fee from her balance const publicKeysHash = deriveKeys(bobsSecretKey).publicKeys.hash(); @@ -339,6 +342,6 @@ describe('e2e_fees_account_init', () => { const note = new Note([new Fr(amount), secretHash]); // this note isn't encrypted but we need to provide a registered public key const extendedNote = new ExtendedNote(note, owner, bananaCoin.address, storageSlot, noteTypeId, txHash); - await ctx.pxe.addNote(extendedNote); + await pxe.addNote(extendedNote); } }); diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts index ee43e2b3f76d..f367253bdeb3 100644 --- a/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts @@ -46,9 +46,7 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise) => it('registers a recipient and returns it as a recipient only and not as an account', async () => { const completeAddress = CompleteAddress.random(); - // docs:start:register-recipient await pxe.registerRecipient(completeAddress); - // docs:end:register-recipient // Check that the recipient is correctly registered using the getAccounts and getRecipients methods const accounts = await pxe.getRegisteredAccounts();