Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export {
GlobalVariables,
} from '@aztec/stdlib/tx';
export { Body, L2Block } from '@aztec/stdlib/block';
export { LogId, type LogFilter, EncryptedLogPayload } from '@aztec/stdlib/logs';
export { L1EventPayload, EventMetadata } from '@aztec/stdlib/event';
export { LogId, type LogFilter } from '@aztec/stdlib/logs';
export { L1ToL2Message, L2Actor, L1Actor } from '@aztec/stdlib/messaging';
export { UniqueNote, ExtendedNote, Comparator, Note } from '@aztec/stdlib/note';
export { type PXE, EventType } from '@aztec/stdlib/interfaces/client';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ import {
type FieldLike,
Fr,
type FunctionSelectorLike,
L1EventPayload,
loadContractArtifact,
loadContractArtifactForPublic,
type NoirCompiledContract,
Expand Down
45 changes: 32 additions & 13 deletions yarn-project/end-to-end/src/e2e_block_building.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { type InitialAccountData, deployFundedSchnorrAccount } from '@aztec/acco
import type { AztecNodeService } from '@aztec/aztec-node';
import {
type AccountWallet,
AccountWalletWithSecretKey,
type AztecAddress,
type AztecNode,
ContractDeployer,
ContractFunctionInteraction,
Fr,
type GlobalVariables,
L1EventPayload,
type Logger,
type PXE,
TxStatus,
Expand Down Expand Up @@ -420,13 +418,27 @@ describe('e2e_block_building', () => {
afterAll(() => teardown());

it('calls a method with nested encrypted logs', async () => {
const thisWallet = new AccountWalletWithSecretKey(pxe, ownerWallet, owner.secret, owner.salt);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While originally we manually decrypted here now I call the getPrivateEvents endpoint.

const address = owner.address;

const values = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected value changed to a struct because that's how the event looks and the getPrivateEvents endpoint returns the value ABI decoded and not as an array of fields.

value0: 5n,
value1: 4n,
value2: 3n,
value3: 2n,
value4: 1n,
};
const nestedValues = {
value0: 0n,
value1: 0n,
value2: 0n,
value3: 0n,
value4: 0n,
};

// call test contract
const values = [new Fr(5), new Fr(4), new Fr(3), new Fr(2), new Fr(1)];
const nestedValues = [new Fr(0), new Fr(0), new Fr(0), new Fr(0), new Fr(0)];
const action = testContract.methods.emit_array_as_encrypted_log(values, address, address, true);
const valuesAsArray = Object.values(values);

const action = testContract.methods.emit_array_as_encrypted_log(valuesAsArray, address, address, true);
const tx = await action.prove();
const rct = await tx.send().wait();

Expand All @@ -436,16 +448,23 @@ describe('e2e_block_building', () => {
expect(privateLogs.length).toBe(3);

// The first two logs are encrypted.
const event0 = (await L1EventPayload.decryptAsIncoming(privateLogs[0], await thisWallet.getEncryptionSecret()))!;
expect(event0.event.items).toEqual(values);

const event1 = (await L1EventPayload.decryptAsIncoming(privateLogs[1], await thisWallet.getEncryptionSecret()))!;
expect(event1.event.items).toEqual(nestedValues);
const events = await pxe.getPrivateEvents(
testContract.address,
TestContract.events.ExampleEvent,
rct.blockNumber!,
1,
[address],
);
expect(events[0]).toEqual(values);
expect(events[1]).toEqual(nestedValues);

// The last log is not encrypted.
// The first field is the first value and is siloed with contract address by the kernel circuit.
const expectedFirstField = await poseidon2Hash([testContract.address, values[0]]);
expect(privateLogs[2].fields.slice(0, 5)).toEqual([expectedFirstField, ...values.slice(1)]);
const expectedFirstField = await poseidon2Hash([testContract.address, valuesAsArray[0]]);
expect(privateLogs[2].fields.slice(0, 5).map((f: Fr) => f.toBigInt())).toEqual([
expectedFirstField.toBigInt(),
...valuesAsArray.slice(1),
]);
}, 60_000);
});

Expand Down
8 changes: 3 additions & 5 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
getContractClassFromArtifact,
} from '@aztec/stdlib/contract';
import { SimulationError } from '@aztec/stdlib/errors';
import { EventMetadata } from '@aztec/stdlib/event';
import type { GasFees } from '@aztec/stdlib/gas';
import { siloNullifier } from '@aztec/stdlib/hash';
import type {
Expand Down Expand Up @@ -915,7 +914,6 @@ export class PXEService implements PXE {
}

async getPublicEvents<T>(eventMetadataDef: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
const eventMetadata = new EventMetadata<T>(eventMetadataDef);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely nuked the EventMetadata thing as it now felt largely useless.

const { logs } = await this.node.getPublicLogs({
fromBlock: from,
toBlock: from + limit,
Expand All @@ -924,10 +922,10 @@ export class PXEService implements PXE {
const decodedEvents = logs
.map(log => {
// +1 for the event selector
const expectedLength = eventMetadata.fieldNames.length + 1;
const expectedLength = eventMetadataDef.fieldNames.length + 1;
const logFields = log.log.log.slice(0, expectedLength);
// We are assuming here that event logs are the last 4 bytes of the event. This is not enshrined but is a function of aztec.nr raw log emission.
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadata.eventSelector)) {
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
return undefined;
}
// If any of the remaining fields, are non-zero, the payload does match expected:
Expand All @@ -937,7 +935,7 @@ export class PXEService implements PXE {
);
}

return eventMetadata.decode(log.log);
return decodeFromAbi([eventMetadataDef.abiType], log.log.log) as T;
})
.filter(log => log !== undefined) as T[];

Expand Down
1 change: 0 additions & 1 deletion yarn-project/stdlib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"./tx": "./dest/tx/index.js",
"./fees": "./dest/fees/index.js",
"./note": "./dest/note/index.js",
"./event": "./dest/event/index.js",
"./p2p": "./dest/p2p/index.js",
"./errors": "./dest/errors/index.js",
"./stats": "./dest/stats/index.js",
Expand Down
12 changes: 0 additions & 12 deletions yarn-project/stdlib/src/event/event.test.ts

This file was deleted.

16 changes: 0 additions & 16 deletions yarn-project/stdlib/src/event/event.ts

This file was deleted.

56 changes: 0 additions & 56 deletions yarn-project/stdlib/src/event/event_metadata.ts

This file was deleted.

3 changes: 0 additions & 3 deletions yarn-project/stdlib/src/event/index.ts

This file was deleted.

87 changes: 0 additions & 87 deletions yarn-project/stdlib/src/event/l1_event_payload.ts

This file was deleted.

2 changes: 1 addition & 1 deletion yarn-project/stdlib/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface PXE {

/**
* Proves the private portion of a simulated transaction, ready to send to the network
* (where valiators prove the public portion).
* (where validators prove the public portion).
*
* @param txRequest - An authenticated tx request ready for proving
* @param privateExecutionResult - The result of the private execution of the transaction
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/stdlib/src/logs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export * from './log_id.js';
export * from './log_filter.js';
export * from './extended_public_log.js';
export * from './extended_contract_class_log.js';
export * from './l1_payload/index.js';
export * from './shared_secret_derivation.js';
export * from './tx_scoped_l2_log.js';
Loading
Loading