@aztec/pxe 0.63.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/database/contracts/contract_artifact_db.d.ts +1 -0
- package/dest/database/contracts/contract_artifact_db.d.ts.map +1 -1
- package/dest/database/incoming_note_dao.d.ts +10 -1
- package/dest/database/incoming_note_dao.d.ts.map +1 -1
- package/dest/database/incoming_note_dao.js +18 -5
- package/dest/database/kv_pxe_database.d.ts +6 -3
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +123 -22
- package/dest/database/outgoing_note_dao.d.ts +10 -1
- package/dest/database/outgoing_note_dao.d.ts.map +1 -1
- package/dest/database/outgoing_note_dao.js +18 -5
- package/dest/database/pxe_database.d.ts +22 -5
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.js +65 -16
- package/dest/kernel_oracle/index.js +2 -2
- package/dest/note_decryption_utils/produce_note_daos.d.ts +1 -1
- package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
- package/dest/note_decryption_utils/produce_note_daos.js +5 -5
- package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +1 -1
- package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -1
- package/dest/note_decryption_utils/produce_note_daos_for_key.js +3 -3
- package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/create_pxe_service.js +6 -3
- package/dest/pxe_service/pxe_service.d.ts +5 -4
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +51 -25
- package/dest/simulator_oracle/index.d.ts +8 -0
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +67 -10
- package/dest/synchronizer/synchronizer.d.ts +13 -28
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +42 -64
- package/package.json +14 -14
- package/src/database/contracts/contract_artifact_db.ts +1 -0
- package/src/database/incoming_note_dao.ts +46 -1
- package/src/database/kv_pxe_database.ts +148 -23
- package/src/database/outgoing_note_dao.ts +43 -1
- package/src/database/pxe_database.ts +25 -5
- package/src/database/pxe_database_test_suite.ts +79 -17
- package/src/kernel_oracle/index.ts +1 -1
- package/src/note_decryption_utils/produce_note_daos.ts +8 -0
- package/src/note_decryption_utils/produce_note_daos_for_key.ts +5 -1
- package/src/pxe_service/create_pxe_service.ts +7 -4
- package/src/pxe_service/pxe_service.ts +109 -72
- package/src/simulator_oracle/index.ts +95 -17
- package/src/synchronizer/synchronizer.ts +60 -71
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type AztecNode } from '@aztec/circuit-types';
|
|
2
|
-
import { type
|
|
1
|
+
import { type AztecNode, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/circuit-types';
|
|
2
|
+
import { type L2TipsStore } from '@aztec/kv-store/stores';
|
|
3
|
+
import { type PXEConfig } from '../config/index.js';
|
|
3
4
|
import { type PxeDatabase } from '../database/index.js';
|
|
4
5
|
/**
|
|
5
6
|
* The Synchronizer class manages the synchronization of note processors and interacts with the Aztec node
|
|
@@ -8,15 +9,18 @@ import { type PxeDatabase } from '../database/index.js';
|
|
|
8
9
|
* details, and fetch transactions by hash. The Synchronizer ensures that it maintains the note processors
|
|
9
10
|
* in sync with the blockchain while handling retries and errors gracefully.
|
|
10
11
|
*/
|
|
11
|
-
export declare class Synchronizer {
|
|
12
|
+
export declare class Synchronizer implements L2BlockStreamEventHandler {
|
|
12
13
|
private node;
|
|
13
14
|
private db;
|
|
14
|
-
private
|
|
15
|
-
private runningPromise?;
|
|
15
|
+
private l2TipsStore;
|
|
16
16
|
private running;
|
|
17
17
|
private initialSyncBlockNumber;
|
|
18
18
|
private log;
|
|
19
|
-
|
|
19
|
+
protected readonly blockStream: L2BlockStream;
|
|
20
|
+
constructor(node: AztecNode, db: PxeDatabase, l2TipsStore: L2TipsStore, config?: Partial<Pick<PXEConfig, 'l2BlockPollingIntervalMS' | 'l2StartingBlock'>>, logSuffix?: string);
|
|
21
|
+
protected createBlockStream(config: Partial<Pick<PXEConfig, 'l2BlockPollingIntervalMS' | 'l2StartingBlock'>>): L2BlockStream;
|
|
22
|
+
/** Handle events emitted by the block stream. */
|
|
23
|
+
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
20
24
|
/**
|
|
21
25
|
* Starts the synchronization process by fetching encrypted logs and blocks from a specified position.
|
|
22
26
|
* Continuously processes the fetched data for all note processors until stopped. If there is no data
|
|
@@ -25,28 +29,7 @@ export declare class Synchronizer {
|
|
|
25
29
|
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
26
30
|
* @param retryInterval - The time interval (in ms) to wait before retrying if no data is available.
|
|
27
31
|
*/
|
|
28
|
-
start(
|
|
29
|
-
protected initialSync(): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Fetches encrypted logs and blocks from the Aztec node and processes them for all note processors.
|
|
32
|
-
* If needed, catches up note processors that are lagging behind the main sync, e.g. because we just added a new account.
|
|
33
|
-
*
|
|
34
|
-
* Uses the job queue to ensure that
|
|
35
|
-
* - sync does not overlap with pxe simulations.
|
|
36
|
-
* - one sync is running at a time.
|
|
37
|
-
*
|
|
38
|
-
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
39
|
-
* @returns a promise that resolves when the sync is complete
|
|
40
|
-
*/
|
|
41
|
-
protected sync(limit: number): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Fetches encrypted logs and blocks from the Aztec node and processes them for all note processors.
|
|
44
|
-
*
|
|
45
|
-
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
46
|
-
* @returns true if there could be more work, false if we're caught up or there was an error.
|
|
47
|
-
*/
|
|
48
|
-
protected work(limit?: number): Promise<boolean>;
|
|
49
|
-
private setHeaderFromBlock;
|
|
32
|
+
start(): Promise<void>;
|
|
50
33
|
/**
|
|
51
34
|
* Stops the synchronizer gracefully, interrupting any ongoing sleep and waiting for the current
|
|
52
35
|
* iteration to complete before setting the running state to false. Once stopped, the synchronizer
|
|
@@ -55,6 +38,8 @@ export declare class Synchronizer {
|
|
|
55
38
|
* @returns A promise that resolves when the synchronizer has successfully stopped.
|
|
56
39
|
*/
|
|
57
40
|
stop(): Promise<void>;
|
|
41
|
+
/** Triggers a single run. */
|
|
42
|
+
trigger(): Promise<void>;
|
|
58
43
|
private getSynchedBlockNumber;
|
|
59
44
|
/**
|
|
60
45
|
* Checks whether all the blocks were processed (tree roots updated, txs updated with block info, etc.).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/synchronizer/synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/synchronizer/synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;GAMG;AACH,qBAAa,YAAa,YAAW,yBAAyB;IAO1D,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,WAAW;IARrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,sBAAsB,CAA4B;IAC1D,OAAO,CAAC,GAAG,CAAc;IACzB,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;gBAGpC,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,WAAW,EACf,WAAW,EAAE,WAAW,EAChC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,0BAA0B,GAAG,iBAAiB,CAAC,CAAM,EACrF,SAAS,CAAC,EAAE,MAAM;IAMpB,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,0BAA0B,GAAG,iBAAiB,CAAC,CAAC;IAO5G,iDAAiD;IACpC,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7E;;;;;;;OAOG;IACU,KAAK;IAelB;;;;;;OAMG;IACU,IAAI;IAMjB,6BAA6B;IAChB,OAAO;IAIpB,OAAO,CAAC,qBAAqB;IAI7B;;;;;OAKG;IACU,yBAAyB;IAKtC;;;OAGG;IACI,aAAa;;;CAMrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { L2BlockStream, } from '@aztec/circuit-types';
|
|
1
2
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
|
|
2
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
4
4
|
/**
|
|
5
5
|
* The Synchronizer class manages the synchronization of note processors and interacts with the Aztec node
|
|
6
6
|
* to obtain encrypted logs, blocks, and other necessary information for the accounts.
|
|
@@ -9,13 +9,41 @@ import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
|
9
9
|
* in sync with the blockchain while handling retries and errors gracefully.
|
|
10
10
|
*/
|
|
11
11
|
export class Synchronizer {
|
|
12
|
-
constructor(node, db,
|
|
12
|
+
constructor(node, db, l2TipsStore, config = {}, logSuffix) {
|
|
13
13
|
this.node = node;
|
|
14
14
|
this.db = db;
|
|
15
|
-
this.
|
|
15
|
+
this.l2TipsStore = l2TipsStore;
|
|
16
16
|
this.running = false;
|
|
17
17
|
this.initialSyncBlockNumber = INITIAL_L2_BLOCK_NUM - 1;
|
|
18
18
|
this.log = createDebugLogger(logSuffix ? `aztec:pxe_synchronizer_${logSuffix}` : 'aztec:pxe_synchronizer');
|
|
19
|
+
this.blockStream = this.createBlockStream(config);
|
|
20
|
+
}
|
|
21
|
+
createBlockStream(config) {
|
|
22
|
+
return new L2BlockStream(this.node, this.l2TipsStore, this, {
|
|
23
|
+
pollIntervalMS: config.l2BlockPollingIntervalMS,
|
|
24
|
+
startingBlock: config.l2StartingBlock,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Handle events emitted by the block stream. */
|
|
28
|
+
async handleBlockStreamEvent(event) {
|
|
29
|
+
await this.l2TipsStore.handleBlockStreamEvent(event);
|
|
30
|
+
switch (event.type) {
|
|
31
|
+
case 'blocks-added':
|
|
32
|
+
this.log.verbose(`Processing blocks ${event.blocks[0].number} to ${event.blocks.at(-1).number}`);
|
|
33
|
+
await this.db.setHeader(event.blocks.at(-1).header);
|
|
34
|
+
break;
|
|
35
|
+
case 'chain-pruned':
|
|
36
|
+
this.log.info(`Pruning data after block ${event.blockNumber} due to reorg`);
|
|
37
|
+
// We first unnullify and then remove so that unnullified notes that were created after the block number end up deleted.
|
|
38
|
+
await this.db.unnullifyNotesAfter(event.blockNumber);
|
|
39
|
+
await this.db.removeNotesAfter(event.blockNumber);
|
|
40
|
+
// Remove all note tagging indexes to force a full resync. This is suboptimal, but unless we track the
|
|
41
|
+
// block number in which each index is used it's all we can do.
|
|
42
|
+
await this.db.resetNoteSyncData();
|
|
43
|
+
// Update the header to the last block.
|
|
44
|
+
await this.db.setHeader(await this.node.getBlockHeader(event.blockNumber));
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
19
47
|
}
|
|
20
48
|
/**
|
|
21
49
|
* Starts the synchronization process by fetching encrypted logs and blocks from a specified position.
|
|
@@ -25,72 +53,18 @@ export class Synchronizer {
|
|
|
25
53
|
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
26
54
|
* @param retryInterval - The time interval (in ms) to wait before retrying if no data is available.
|
|
27
55
|
*/
|
|
28
|
-
async start(
|
|
56
|
+
async start() {
|
|
29
57
|
if (this.running) {
|
|
30
58
|
return;
|
|
31
59
|
}
|
|
32
60
|
this.running = true;
|
|
33
|
-
|
|
61
|
+
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
62
|
+
await this.db.setHeader(await this.node.getBlockHeader(0));
|
|
63
|
+
await this.trigger();
|
|
34
64
|
this.log.info('Initial sync complete');
|
|
35
|
-
this.
|
|
36
|
-
this.runningPromise.start();
|
|
65
|
+
this.blockStream.start();
|
|
37
66
|
this.log.debug('Started loop');
|
|
38
67
|
}
|
|
39
|
-
async initialSync() {
|
|
40
|
-
// fast forward to the latest block
|
|
41
|
-
const latestHeader = await this.node.getHeader();
|
|
42
|
-
this.initialSyncBlockNumber = Number(latestHeader.globalVariables.blockNumber.toBigInt());
|
|
43
|
-
await this.db.setHeader(latestHeader);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Fetches encrypted logs and blocks from the Aztec node and processes them for all note processors.
|
|
47
|
-
* If needed, catches up note processors that are lagging behind the main sync, e.g. because we just added a new account.
|
|
48
|
-
*
|
|
49
|
-
* Uses the job queue to ensure that
|
|
50
|
-
* - sync does not overlap with pxe simulations.
|
|
51
|
-
* - one sync is running at a time.
|
|
52
|
-
*
|
|
53
|
-
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
54
|
-
* @returns a promise that resolves when the sync is complete
|
|
55
|
-
*/
|
|
56
|
-
sync(limit) {
|
|
57
|
-
return this.jobQueue.put(async () => {
|
|
58
|
-
let moreWork = true;
|
|
59
|
-
// keep external this.running flag to interrupt greedy sync
|
|
60
|
-
while (moreWork && this.running) {
|
|
61
|
-
moreWork = await this.work(limit);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Fetches encrypted logs and blocks from the Aztec node and processes them for all note processors.
|
|
67
|
-
*
|
|
68
|
-
* @param limit - The maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
|
|
69
|
-
* @returns true if there could be more work, false if we're caught up or there was an error.
|
|
70
|
-
*/
|
|
71
|
-
async work(limit = 1) {
|
|
72
|
-
const from = this.getSynchedBlockNumber() + 1;
|
|
73
|
-
try {
|
|
74
|
-
const blocks = await this.node.getBlocks(from, limit);
|
|
75
|
-
if (blocks.length === 0) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
// Update latest tree roots from the most recent block
|
|
79
|
-
const latestBlock = blocks[blocks.length - 1];
|
|
80
|
-
await this.setHeaderFromBlock(latestBlock);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
this.log.error(`Error in synchronizer work`, err);
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async setHeaderFromBlock(latestBlock) {
|
|
89
|
-
if (latestBlock.number < this.initialSyncBlockNumber) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
await this.db.setHeader(latestBlock.header);
|
|
93
|
-
}
|
|
94
68
|
/**
|
|
95
69
|
* Stops the synchronizer gracefully, interrupting any ongoing sleep and waiting for the current
|
|
96
70
|
* iteration to complete before setting the running state to false. Once stopped, the synchronizer
|
|
@@ -100,9 +74,13 @@ export class Synchronizer {
|
|
|
100
74
|
*/
|
|
101
75
|
async stop() {
|
|
102
76
|
this.running = false;
|
|
103
|
-
await this.
|
|
77
|
+
await this.blockStream.stop();
|
|
104
78
|
this.log.info('Stopped');
|
|
105
79
|
}
|
|
80
|
+
/** Triggers a single run. */
|
|
81
|
+
async trigger() {
|
|
82
|
+
await this.blockStream.sync();
|
|
83
|
+
}
|
|
106
84
|
getSynchedBlockNumber() {
|
|
107
85
|
return this.db.getBlockNumber() ?? this.initialSyncBlockNumber;
|
|
108
86
|
}
|
|
@@ -127,4 +105,4 @@ export class Synchronizer {
|
|
|
127
105
|
};
|
|
128
106
|
}
|
|
129
107
|
}
|
|
130
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
108
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY2hyb25pemVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N5bmNocm9uaXplci9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUVMLGFBQWEsR0FHZCxNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzFELE9BQU8sRUFBb0IsaUJBQWlCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQU01RTs7Ozs7O0dBTUc7QUFDSCxNQUFNLE9BQU8sWUFBWTtJQU12QixZQUNVLElBQWUsRUFDZixFQUFlLEVBQ2YsV0FBd0IsRUFDaEMsU0FBbUYsRUFBRSxFQUNyRixTQUFrQjtRQUpWLFNBQUksR0FBSixJQUFJLENBQVc7UUFDZixPQUFFLEdBQUYsRUFBRSxDQUFhO1FBQ2YsZ0JBQVcsR0FBWCxXQUFXLENBQWE7UUFSMUIsWUFBTyxHQUFHLEtBQUssQ0FBQztRQUNoQiwyQkFBc0IsR0FBRyxvQkFBb0IsR0FBRyxDQUFDLENBQUM7UUFXeEQsSUFBSSxDQUFDLEdBQUcsR0FBRyxpQkFBaUIsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLDBCQUEwQixTQUFTLEVBQUUsQ0FBQyxDQUFDLENBQUMsd0JBQXdCLENBQUMsQ0FBQztRQUMzRyxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNwRCxDQUFDO0lBRVMsaUJBQWlCLENBQUMs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SyxDQUFDO1FBQ3JCLE1BQU0sSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM5QixJQUFJLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUMzQixDQUFDO0lBRUQsNkJBQTZCO0lBQ3RCLEtBQUssQ0FBQyxPQUFPO1FBQ2xCLE1BQU0sSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQyxDQUFDO0lBRU8scUJBQXFCO1FBQzNCLE9BQU8sSUFBSSxDQUFDLEVBQUUsQ0FBQyxjQUFjLEVBQUUsSUFBSSxJQUFJLENBQUMsc0JBQXNCLENBQUM7SUFDakUsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0ksS0FBSyxDQUFDLHlCQUF5QjtRQUNwQyxNQUFNLE1BQU0sR0FBRyxNQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBYyxFQUFFLENBQUM7UUFDaEQsT0FBTyxNQUFNLElBQUksSUFBSSxDQUFDLHFCQUFxQixFQUFFLENBQUM7SUFDaEQsQ0FBQztJQUVEOzs7T0FHRztJQUNJLGFBQWE7UUFDbEIsTUFBTSxlQUFlLEdBQUcsSUFBSSxDQUFDLHFCQUFxQixFQUFFLENBQUM7UUFDckQsT0FBTztZQUNMLE1BQU0sRUFBRSxlQUFlO1NBQ3hCLENBQUM7SUFDSixDQUFDO0NBQ0YifQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -59,19 +59,19 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aztec/bb-prover": "0.
|
|
63
|
-
"@aztec/bb.js": "0.
|
|
64
|
-
"@aztec/builder": "0.
|
|
65
|
-
"@aztec/circuit-types": "0.
|
|
66
|
-
"@aztec/circuits.js": "0.
|
|
67
|
-
"@aztec/ethereum": "0.
|
|
68
|
-
"@aztec/foundation": "0.
|
|
69
|
-
"@aztec/key-store": "0.
|
|
70
|
-
"@aztec/kv-store": "0.
|
|
71
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
72
|
-
"@aztec/protocol-contracts": "0.
|
|
73
|
-
"@aztec/simulator": "0.
|
|
74
|
-
"@aztec/types": "0.
|
|
62
|
+
"@aztec/bb-prover": "0.64.0",
|
|
63
|
+
"@aztec/bb.js": "0.64.0",
|
|
64
|
+
"@aztec/builder": "0.64.0",
|
|
65
|
+
"@aztec/circuit-types": "0.64.0",
|
|
66
|
+
"@aztec/circuits.js": "0.64.0",
|
|
67
|
+
"@aztec/ethereum": "0.64.0",
|
|
68
|
+
"@aztec/foundation": "0.64.0",
|
|
69
|
+
"@aztec/key-store": "0.64.0",
|
|
70
|
+
"@aztec/kv-store": "0.64.0",
|
|
71
|
+
"@aztec/noir-protocol-circuits-types": "0.64.0",
|
|
72
|
+
"@aztec/protocol-contracts": "0.64.0",
|
|
73
|
+
"@aztec/simulator": "0.64.0",
|
|
74
|
+
"@aztec/types": "0.64.0",
|
|
75
75
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
76
76
|
"@noir-lang/noirc_abi": "portal:../../noir/packages/noirc_abi",
|
|
77
77
|
"@noir-lang/types": "workspace:*",
|
|
@@ -9,6 +9,7 @@ export interface ContractArtifactDatabase {
|
|
|
9
9
|
* Adds a new contract artifact to the database or updates an existing one.
|
|
10
10
|
* @param id - Id of the corresponding contract class.
|
|
11
11
|
* @param contract - Contract artifact to add.
|
|
12
|
+
* @throws - If there are duplicate private function selectors.
|
|
12
13
|
*/
|
|
13
14
|
addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
|
|
14
15
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type L1NotePayload, Note, TxHash } from '@aztec/circuit-types';
|
|
1
|
+
import { type L1NotePayload, Note, TxHash, randomTxHash } from '@aztec/circuit-types';
|
|
2
2
|
import { AztecAddress, Fr, Point, type PublicKey } from '@aztec/circuits.js';
|
|
3
3
|
import { NoteSelector } from '@aztec/foundation/abi';
|
|
4
4
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
@@ -22,6 +22,10 @@ export class IncomingNoteDao implements NoteData {
|
|
|
22
22
|
public noteTypeId: NoteSelector,
|
|
23
23
|
/** The hash of the tx the note was created in. */
|
|
24
24
|
public txHash: TxHash,
|
|
25
|
+
/** The L2 block number in which the tx with this note was included. */
|
|
26
|
+
public l2BlockNumber: number,
|
|
27
|
+
/** The L2 block hash in which the tx with this note was included. */
|
|
28
|
+
public l2BlockHash: string,
|
|
25
29
|
/** The nonce of the note. */
|
|
26
30
|
public nonce: Fr,
|
|
27
31
|
/**
|
|
@@ -44,6 +48,8 @@ export class IncomingNoteDao implements NoteData {
|
|
|
44
48
|
note: Note,
|
|
45
49
|
payload: L1NotePayload,
|
|
46
50
|
noteInfo: NoteInfo,
|
|
51
|
+
l2BlockNumber: number,
|
|
52
|
+
l2BlockHash: string,
|
|
47
53
|
dataStartIndexForTx: number,
|
|
48
54
|
addressPoint: PublicKey,
|
|
49
55
|
) {
|
|
@@ -54,6 +60,8 @@ export class IncomingNoteDao implements NoteData {
|
|
|
54
60
|
payload.storageSlot,
|
|
55
61
|
payload.noteTypeId,
|
|
56
62
|
noteInfo.txHash,
|
|
63
|
+
l2BlockNumber,
|
|
64
|
+
l2BlockHash,
|
|
57
65
|
noteInfo.nonce,
|
|
58
66
|
noteInfo.noteHash,
|
|
59
67
|
noteInfo.siloedNullifier,
|
|
@@ -69,6 +77,8 @@ export class IncomingNoteDao implements NoteData {
|
|
|
69
77
|
this.storageSlot,
|
|
70
78
|
this.noteTypeId,
|
|
71
79
|
this.txHash.buffer,
|
|
80
|
+
this.l2BlockNumber,
|
|
81
|
+
Fr.fromString(this.l2BlockHash),
|
|
72
82
|
this.nonce,
|
|
73
83
|
this.noteHash,
|
|
74
84
|
this.siloedNullifier,
|
|
@@ -76,6 +86,7 @@ export class IncomingNoteDao implements NoteData {
|
|
|
76
86
|
this.addressPoint,
|
|
77
87
|
]);
|
|
78
88
|
}
|
|
89
|
+
|
|
79
90
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
80
91
|
const reader = BufferReader.asReader(buffer);
|
|
81
92
|
|
|
@@ -84,6 +95,8 @@ export class IncomingNoteDao implements NoteData {
|
|
|
84
95
|
const storageSlot = Fr.fromBuffer(reader);
|
|
85
96
|
const noteTypeId = reader.readObject(NoteSelector);
|
|
86
97
|
const txHash = reader.readObject(TxHash);
|
|
98
|
+
const l2BlockNumber = reader.readNumber();
|
|
99
|
+
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
87
100
|
const nonce = Fr.fromBuffer(reader);
|
|
88
101
|
const noteHash = Fr.fromBuffer(reader);
|
|
89
102
|
const siloedNullifier = Fr.fromBuffer(reader);
|
|
@@ -96,6 +109,8 @@ export class IncomingNoteDao implements NoteData {
|
|
|
96
109
|
storageSlot,
|
|
97
110
|
noteTypeId,
|
|
98
111
|
txHash,
|
|
112
|
+
l2BlockNumber,
|
|
113
|
+
l2BlockHash,
|
|
99
114
|
nonce,
|
|
100
115
|
noteHash,
|
|
101
116
|
siloedNullifier,
|
|
@@ -122,4 +137,34 @@ export class IncomingNoteDao implements NoteData {
|
|
|
122
137
|
const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
|
|
123
138
|
return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
|
|
124
139
|
}
|
|
140
|
+
|
|
141
|
+
static random({
|
|
142
|
+
note = Note.random(),
|
|
143
|
+
contractAddress = AztecAddress.random(),
|
|
144
|
+
txHash = randomTxHash(),
|
|
145
|
+
storageSlot = Fr.random(),
|
|
146
|
+
noteTypeId = NoteSelector.random(),
|
|
147
|
+
nonce = Fr.random(),
|
|
148
|
+
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
149
|
+
l2BlockHash = Fr.random().toString(),
|
|
150
|
+
noteHash = Fr.random(),
|
|
151
|
+
siloedNullifier = Fr.random(),
|
|
152
|
+
index = Fr.random().toBigInt(),
|
|
153
|
+
addressPoint = Point.random(),
|
|
154
|
+
}: Partial<IncomingNoteDao> = {}) {
|
|
155
|
+
return new IncomingNoteDao(
|
|
156
|
+
note,
|
|
157
|
+
contractAddress,
|
|
158
|
+
storageSlot,
|
|
159
|
+
noteTypeId,
|
|
160
|
+
txHash,
|
|
161
|
+
l2BlockNumber,
|
|
162
|
+
l2BlockHash,
|
|
163
|
+
nonce,
|
|
164
|
+
noteHash,
|
|
165
|
+
siloedNullifier,
|
|
166
|
+
index,
|
|
167
|
+
addressPoint,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
125
170
|
}
|