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
49 changes: 28 additions & 21 deletions docs/docs/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Aztec is in full-speed development. Literally every version breaks compatibility

## TBD

## [aztec.js] AztecNode.findLeavesIndexes returns indexes with block metadata

It's common that we need block metadata of a block in which leaves where inserted when querying indexes of these tree leaves.
For this reason we now return that information along with the indexes.
This allows us to reduce the number of individual AztecNode queries.

Along this change `findNullifiersIndexesWithBlock` and `findBlockNumbersForIndexes` functions wer removed as all its uses can now be replaced with the newly modified `findLeavesIndexes` function.

## [aztec.js] AztecNode.getPublicDataTreeWitness renamed as AztecNode.getPublicDataWitness

This change was done to have consistent naming across codebase.
Expand All @@ -16,42 +24,42 @@ This change was done to have consistent naming across codebase.

The `Wallet` interface in `aztec.js` is undergoing transformations, trying to be friendlier to wallet builders and reducing the surface of its API. This means `Wallet` no longer extends `PXE`, and instead just implements a subset of the methods of the former. This is NOT going to be its final form, but paves the way towards better interfaces and starts to clarify what the responsibilities of the wallet are:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Below are just formatting-related changes.

``` typescript
```typescript
/**
* The wallet interface.
*/
export type Wallet = AccountInterface &
Pick<
PXE,
// Simulation
| 'simulateTx'
| 'simulateUnconstrained'
| 'profileTx'
| "simulateTx"
| "simulateUnconstrained"
| "profileTx"
// Sending
| 'sendTx'
| "sendTx"
// Contract management (will probably be collapsed in the future to avoid instance and class versions)
| 'getContractClassMetadata'
| 'getContractMetadata'
| 'registerContract'
| 'registerContractClass'
| "getContractClassMetadata"
| "getContractMetadata"
| "registerContract"
| "registerContractClass"
// Likely to be removed
| 'proveTx'
| "proveTx"
// Will probably be collapsed
| 'getNodeInfo'
| 'getPXEInfo'
| "getNodeInfo"
| "getPXEInfo"
// Fee info
| 'getCurrentBaseFees'
| "getCurrentBaseFees"
// Still undecided, kept for the time being
| 'updateContract'
| "updateContract"
// Sender management
| 'registerSender'
| 'getSenders'
| 'removeSender'
| "registerSender"
| "getSenders"
| "removeSender"
// Tx status
| 'getTxReceipt'
| "getTxReceipt"
// Events. Kept since events are going to be reworked and changes will come when that's done
| 'getPrivateEvents'
| 'getPublicEvents'
| "getPrivateEvents"
| "getPublicEvents"
> & {
createAuthWit(intent: IntentInnerHash | IntentAction): Promise<AuthWitness>;
};
Expand Down Expand Up @@ -98,7 +106,6 @@ const witness = await wallet.createAuthWit({ caller, action });
++await wallet.lookupValidity(wallet.getAddress(), { caller, action }, witness);
```


### [PXE] Concurrent contract function simulation disabled

PXE is no longer be able to execute contract functions concurrently (e.g. by collecting calls to `simulateTx` and then using `await Promise.all`). They will instead be put in a job queue and executed sequentially in order of arrival.
Expand Down
24 changes: 1 addition & 23 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
type L2BlockSource,
L2BlockSourceEvents,
type L2Tips,
type NullifierWithBlockSource,
} from '@aztec/stdlib/block';
import {
type ContractClassPublic,
Expand Down Expand Up @@ -67,11 +66,7 @@ import type { PublishedL2Block } from './structs/published.js';
/**
* Helper interface to combine all sources this archiver implementation provides.
*/
export type ArchiveSource = L2BlockSource &
L2LogsSource &
ContractDataSource &
L1ToL2MessageSource &
NullifierWithBlockSource;
export type ArchiveSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nullifier store was nuked and with that the Archiver interface was changed.


/**
* Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
Expand Down Expand Up @@ -734,17 +729,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
return this.store.getLogsByTags(tags);
}

/**
* Returns the provided nullifier indexes scoped to the block
* they were first included in, or undefined if they're not present in the tree
* @param blockNumber Max block number to search for the nullifiers
* @param nullifiers Nullifiers to get
* @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
*/
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

findLeavesIndexes on AztecNode now covers the functionality of this func.

return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
}

/**
* Gets public logs based on the provided filter.
* @param filter - The filter to apply to the logs.
Expand Down Expand Up @@ -883,8 +867,6 @@ class ArchiverStoreHelper
ArchiverDataStore,
| 'addLogs'
| 'deleteLogs'
| 'addNullifiers'
| 'deleteNullifiers'
| 'addContractClasses'
| 'deleteContractClasses'
| 'addContractInstances'
Expand Down Expand Up @@ -1050,7 +1032,6 @@ class ArchiverStoreHelper
])
).every(Boolean);
}),
this.store.addNullifiers(blocks.map(block => block.block)),
this.store.addBlocks(blocks),
]);

Expand Down Expand Up @@ -1117,9 +1098,6 @@ class ArchiverStoreHelper
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
return this.store.getLogsByTags(tags);
}
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
}
getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
return this.store.getPublicLogs(filter);
}
Expand Down
17 changes: 0 additions & 17 deletions yarn-project/archiver/src/archiver/archiver_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,6 @@ export interface ArchiverDataStore {
addLogs(blocks: L2Block[]): Promise<boolean>;
deleteLogs(blocks: L2Block[]): Promise<boolean>;

/**
* Append new nullifiers to the store's list.
* @param blocks - The blocks for which to add the nullifiers.
* @returns True if the operation is successful.
*/
addNullifiers(blocks: L2Block[]): Promise<boolean>;
deleteNullifiers(blocks: L2Block[]): Promise<boolean>;

/**
* Returns the provided nullifier indexes scoped to the block
* they were first included in, or undefined if they're not present in the tree
* @param blockNumber Max block number to search for the nullifiers
* @param nullifiers Nullifiers to get
* @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
*/
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;

/**
* Append L1 to L2 messages to the store.
* @param messages - The L1 to L2 messages to be added to the store and the last processed L1 block.
Expand Down
54 changes: 0 additions & 54 deletions yarn-project/archiver/src/archiver/archiver_store_test_suite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
INITIAL_L2_BLOCK_NUM,
L1_TO_L2_MSG_SUBTREE_HEIGHT,
MAX_NULLIFIERS_PER_TX,
PRIVATE_LOG_SIZE_IN_FIELDS,
PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
} from '@aztec/constants';
Expand Down Expand Up @@ -776,58 +775,5 @@ export function describeArchiverDataStore(
}
});
});

describe('findNullifiersIndexesWithBlock', () => {
let blocks: L2Block[];
const numBlocks = 10;
const nullifiersPerBlock = new Map<number, Fr[]>();

beforeEach(async () => {
blocks = await timesParallel(numBlocks, (index: number) => L2Block.random(index + 1, 1));

blocks.forEach((block, blockIndex) => {
nullifiersPerBlock.set(
blockIndex,
block.body.txEffects.flatMap(txEffect => txEffect.nullifiers),
);
});
});

it('returns wrapped nullifiers with blocks if they exist', async () => {
await store.addNullifiers(blocks);
const nullifiersToRetrieve = [...nullifiersPerBlock.get(0)!, ...nullifiersPerBlock.get(5)!, Fr.random()];
const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(10, nullifiersToRetrieve);

expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
const [undefinedNullifier] = blockScopedNullifiers.slice(-1);
const realNullifiers = blockScopedNullifiers.slice(0, -1);
realNullifiers.forEach((blockScopedNullifier, index) => {
expect(blockScopedNullifier).not.toBeUndefined();
const { data, l2BlockNumber } = blockScopedNullifier!;
expect(data).toEqual(expect.any(BigInt));
expect(l2BlockNumber).toEqual(index < MAX_NULLIFIERS_PER_TX ? 1 : 6);
});
expect(undefinedNullifier).toBeUndefined();
});

it('returns wrapped nullifiers filtering by blockNumber', async () => {
await store.addNullifiers(blocks);
const nullifiersToRetrieve = [...nullifiersPerBlock.get(0)!, ...nullifiersPerBlock.get(5)!];
const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(5, nullifiersToRetrieve);

expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
const undefinedNullifiers = blockScopedNullifiers.slice(-MAX_NULLIFIERS_PER_TX);
const realNullifiers = blockScopedNullifiers.slice(0, -MAX_NULLIFIERS_PER_TX);
realNullifiers.forEach(blockScopedNullifier => {
expect(blockScopedNullifier).not.toBeUndefined();
const { data, l2BlockNumber } = blockScopedNullifier!;
expect(data).toEqual(expect.any(BigInt));
expect(l2BlockNumber).toEqual(1);
});
undefinedNullifiers.forEach(undefinedNullifier => {
expect(undefinedNullifier).toBeUndefined();
});
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createLogger } from '@aztec/foundation/log';
import type { AztecAsyncKVStore, StoreSize } from '@aztec/kv-store';
import { FunctionSelector } from '@aztec/stdlib/abi';
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
import type { InBlock, L2Block } from '@aztec/stdlib/block';
import type { L2Block } from '@aztec/stdlib/block';
import type {
ContractClassPublic,
ContractInstanceUpdateWithAddress,
Expand All @@ -25,7 +25,6 @@ import { ContractClassStore } from './contract_class_store.js';
import { ContractInstanceStore } from './contract_instance_store.js';
import { LogStore } from './log_store.js';
import { MessageStore } from './message_store.js';
import { NullifierStore } from './nullifier_store.js';

/**
* LMDB implementation of the ArchiverDataStore interface.
Expand All @@ -35,7 +34,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {

#blockStore: BlockStore;
#logStore: LogStore;
#nullifierStore: NullifierStore;
#messageStore: MessageStore;
#contractClassStore: ContractClassStore;
#contractInstanceStore: ContractInstanceStore;
Expand All @@ -49,7 +47,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
this.#messageStore = new MessageStore(db);
this.#contractClassStore = new ContractClassStore(db);
this.#contractInstanceStore = new ContractInstanceStore(db);
this.#nullifierStore = new NullifierStore(db);
}

// TODO: These function names are in memory only as they are for development/debugging. They require the full contract
Expand Down Expand Up @@ -215,23 +212,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
return this.#logStore.deleteLogs(blocks);
}

/**
* Append new nullifiers to the store's list.
* @param blocks - The blocks for which to add the nullifiers.
* @returns True if the operation is successful.
*/
addNullifiers(blocks: L2Block[]): Promise<boolean> {
return this.#nullifierStore.addNullifiers(blocks);
}

deleteNullifiers(blocks: L2Block[]): Promise<boolean> {
return this.#nullifierStore.deleteNullifiers(blocks);
}

findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
return this.#nullifierStore.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
}

getTotalL1ToL2MessageCount(): Promise<bigint> {
return this.#messageStore.getTotalL1ToL2MessageCount();
}
Expand Down

This file was deleted.

Loading