@aztec/txe 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -6
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +28 -22
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +73 -46
- package/dest/rpc_translator.d.ts +120 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +376 -153
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +5 -7
- package/dest/state_machine/dummy_p2p_client.d.ts +2 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +1 -1
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +6 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +9 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +36 -17
- package/dest/util/encoding.d.ts +40 -41
- package/dest/util/encoding.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +96 -49
- package/src/rpc_translator.ts +438 -175
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +1 -1
- package/src/state_machine/index.ts +5 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +45 -17
|
@@ -17,7 +17,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
17
17
|
private readonly updater = new ArchiverDataStoreUpdater(this.store);
|
|
18
18
|
|
|
19
19
|
constructor(db: AztecAsyncKVStore) {
|
|
20
|
-
const store = new KVArchiverDataStore(db, 9999
|
|
20
|
+
const store = new KVArchiverDataStore(db, 9999);
|
|
21
21
|
super(store);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -79,12 +79,12 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
public
|
|
83
|
-
throw new Error('TXE Archiver does not implement "
|
|
82
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
83
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
public
|
|
87
|
-
throw new Error('TXE Archiver does not implement "
|
|
86
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
87
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -21,7 +21,7 @@ import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicTyp
|
|
|
21
21
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
22
22
|
|
|
23
23
|
export class DummyP2P implements P2P {
|
|
24
|
-
public
|
|
24
|
+
public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
|
|
25
25
|
return Promise.resolve();
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -4,6 +4,7 @@ import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
7
|
+
import { MessageContextService } from '@aztec/pxe/simulator';
|
|
7
8
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,6 +27,7 @@ export class TXEStateMachine {
|
|
|
26
27
|
public archiver: TXEArchiver,
|
|
27
28
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
29
|
public contractSyncService: ContractSyncService,
|
|
30
|
+
public messageContextService: MessageContextService,
|
|
29
31
|
) {}
|
|
30
32
|
|
|
31
33
|
public static async create(
|
|
@@ -68,7 +70,9 @@ export class TXEStateMachine {
|
|
|
68
70
|
createLogger('txe:contract_sync'),
|
|
69
71
|
);
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
const messageContextService = new MessageContextService(node);
|
|
74
|
+
|
|
75
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
public async handleL2Block(block: L2Block) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -33,12 +33,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
36
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
37
37
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
38
|
-
* @param
|
|
38
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
39
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
40
40
|
*/
|
|
41
|
-
public syncImmediate(_minBlockNumber?: BlockNumber,
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
|
|
42
42
|
return Promise.resolve(this.blockNumber);
|
|
43
43
|
}
|
|
44
44
|
|
package/src/txe_session.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
7
6
|
import {
|
|
8
7
|
AddressStore,
|
|
9
8
|
AnchorBlockStore,
|
|
9
|
+
CapsuleService,
|
|
10
10
|
CapsuleStore,
|
|
11
11
|
ContractStore,
|
|
12
|
+
ContractSyncService,
|
|
12
13
|
JobCoordinator,
|
|
13
14
|
NoteService,
|
|
14
15
|
NoteStore,
|
|
@@ -113,6 +114,10 @@ export interface TXESessionStateHandler {
|
|
|
113
114
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
114
115
|
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
115
116
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
117
|
+
|
|
118
|
+
// TODO(F-335): Exposing the job info is abstraction breakage - drop the following 2 functions.
|
|
119
|
+
cycleJob(): Promise<string>;
|
|
120
|
+
getCurrentJob(): string;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
/**
|
|
@@ -146,6 +151,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
146
151
|
private chainId: Fr,
|
|
147
152
|
private version: Fr,
|
|
148
153
|
private nextBlockTimestamp: bigint,
|
|
154
|
+
private contractSyncService: ContractSyncService,
|
|
149
155
|
) {}
|
|
150
156
|
|
|
151
157
|
static async init(contractStore: ContractStore) {
|
|
@@ -181,6 +187,9 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
181
187
|
|
|
182
188
|
const initialJobId = jobCoordinator.beginJob();
|
|
183
189
|
|
|
190
|
+
const logger = createLogger('txe:session');
|
|
191
|
+
const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
|
|
192
|
+
|
|
184
193
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
185
194
|
stateMachine,
|
|
186
195
|
contractStore,
|
|
@@ -193,16 +202,16 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
193
202
|
senderAddressBookStore,
|
|
194
203
|
capsuleStore,
|
|
195
204
|
privateEventStore,
|
|
196
|
-
initialJobId,
|
|
197
205
|
nextBlockTimestamp,
|
|
198
206
|
version,
|
|
199
207
|
chainId,
|
|
200
208
|
new Map(),
|
|
209
|
+
contractSyncService,
|
|
201
210
|
);
|
|
202
|
-
await topLevelOracleHandler.
|
|
211
|
+
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
203
212
|
|
|
204
213
|
return new TXESession(
|
|
205
|
-
|
|
214
|
+
logger,
|
|
206
215
|
stateMachine,
|
|
207
216
|
topLevelOracleHandler,
|
|
208
217
|
contractStore,
|
|
@@ -220,6 +229,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
220
229
|
version,
|
|
221
230
|
chainId,
|
|
222
231
|
nextBlockTimestamp,
|
|
232
|
+
contractSyncService,
|
|
223
233
|
);
|
|
224
234
|
}
|
|
225
235
|
|
|
@@ -254,6 +264,17 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
254
264
|
}
|
|
255
265
|
}
|
|
256
266
|
|
|
267
|
+
getCurrentJob(): string {
|
|
268
|
+
return this.currentJobId;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */
|
|
272
|
+
async cycleJob(): Promise<string> {
|
|
273
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
274
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
275
|
+
return this.currentJobId;
|
|
276
|
+
}
|
|
277
|
+
|
|
257
278
|
async enterTopLevelState() {
|
|
258
279
|
switch (this.state.name) {
|
|
259
280
|
case 'PRIVATE': {
|
|
@@ -277,8 +298,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
277
298
|
}
|
|
278
299
|
|
|
279
300
|
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
280
|
-
await this.
|
|
281
|
-
this.currentJobId = this.jobCoordinator.beginJob();
|
|
301
|
+
await this.cycleJob();
|
|
282
302
|
|
|
283
303
|
this.oracleHandler = new TXEOracleTopLevelContext(
|
|
284
304
|
this.stateMachine,
|
|
@@ -292,11 +312,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
292
312
|
this.senderAddressBookStore,
|
|
293
313
|
this.capsuleStore,
|
|
294
314
|
this.privateEventStore,
|
|
295
|
-
this.currentJobId,
|
|
296
315
|
this.nextBlockTimestamp,
|
|
297
316
|
this.version,
|
|
298
317
|
this.chainId,
|
|
299
318
|
this.authwits,
|
|
319
|
+
this.contractSyncService,
|
|
300
320
|
);
|
|
301
321
|
|
|
302
322
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -316,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
316
336
|
|
|
317
337
|
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
318
338
|
contractAddress,
|
|
319
|
-
|
|
339
|
+
await this.keyStore.getAccounts(),
|
|
320
340
|
);
|
|
321
341
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
322
342
|
|
|
@@ -352,11 +372,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
352
372
|
senderTaggingStore: this.senderTaggingStore,
|
|
353
373
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
354
374
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
355
|
-
|
|
375
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
356
376
|
privateEventStore: this.privateEventStore,
|
|
357
377
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
378
|
+
l2TipsStore: this.stateMachine.node,
|
|
358
379
|
jobId: this.currentJobId,
|
|
359
|
-
scopes:
|
|
380
|
+
scopes: await this.keyStore.getAccounts(),
|
|
381
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
360
382
|
});
|
|
361
383
|
|
|
362
384
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -409,7 +431,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
409
431
|
this.stateMachine.node,
|
|
410
432
|
anchorBlockHeader,
|
|
411
433
|
this.currentJobId,
|
|
412
|
-
).syncNoteNullifiers(contractAddress,
|
|
434
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
413
435
|
|
|
414
436
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
415
437
|
contractAddress,
|
|
@@ -423,10 +445,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
423
445
|
aztecNode: this.stateMachine.node,
|
|
424
446
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
425
447
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
426
|
-
|
|
448
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
427
449
|
privateEventStore: this.privateEventStore,
|
|
450
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
451
|
+
contractSyncService: this.contractSyncService,
|
|
452
|
+
l2TipsStore: this.stateMachine.node,
|
|
428
453
|
jobId: this.currentJobId,
|
|
429
|
-
scopes:
|
|
454
|
+
scopes: await this.keyStore.getAccounts(),
|
|
430
455
|
});
|
|
431
456
|
|
|
432
457
|
this.state = { name: 'UTILITY' };
|
|
@@ -440,8 +465,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
440
465
|
|
|
441
466
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
442
467
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
443
|
-
// others, it will create empty blocks (via `
|
|
444
|
-
// `
|
|
468
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
469
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
445
470
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
446
471
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
447
472
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -495,7 +520,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
495
520
|
}
|
|
496
521
|
|
|
497
522
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
498
|
-
return async (call: FunctionCall, scopes:
|
|
523
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
499
524
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
500
525
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
501
526
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -514,8 +539,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
514
539
|
aztecNode: this.stateMachine.node,
|
|
515
540
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
516
541
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
517
|
-
|
|
542
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
518
543
|
privateEventStore: this.privateEventStore,
|
|
544
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
545
|
+
contractSyncService: this.contractSyncService,
|
|
546
|
+
l2TipsStore: this.stateMachine.node,
|
|
519
547
|
jobId: this.currentJobId,
|
|
520
548
|
scopes,
|
|
521
549
|
});
|