@aztec/txe 4.1.2 → 4.2.0-aztecnr-rc.2
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 +28 -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 +22 -21
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +33 -27
- package/dest/rpc_translator.d.ts +87 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +272 -151
- package/dest/state_machine/index.d.ts +6 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +8 -4
- 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 +4 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +19 -10
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +27 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +34 -25
- package/src/rpc_translator.ts +316 -173
- package/src/state_machine/index.ts +8 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +24 -5
|
@@ -3,7 +3,9 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
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
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
6
7
|
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
8
|
+
import { MessageContextService } from '@aztec/pxe/simulator';
|
|
7
9
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
10
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
11
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,6 +28,7 @@ export class TXEStateMachine {
|
|
|
26
28
|
public archiver: TXEArchiver,
|
|
27
29
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
30
|
public contractSyncService: ContractSyncService,
|
|
31
|
+
public messageContextService: MessageContextService,
|
|
29
32
|
) {}
|
|
30
33
|
|
|
31
34
|
public static async create(
|
|
@@ -33,6 +36,7 @@ export class TXEStateMachine {
|
|
|
33
36
|
anchorBlockStore: AnchorBlockStore,
|
|
34
37
|
contractStore: ContractStore,
|
|
35
38
|
noteStore: NoteStore,
|
|
39
|
+
keyStore: KeyStore,
|
|
36
40
|
) {
|
|
37
41
|
const synchronizer = await TXESynchronizer.create();
|
|
38
42
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
@@ -65,10 +69,13 @@ export class TXEStateMachine {
|
|
|
65
69
|
node,
|
|
66
70
|
contractStore,
|
|
67
71
|
noteStore,
|
|
72
|
+
() => keyStore.getAccounts(),
|
|
68
73
|
createLogger('txe:contract_sync'),
|
|
69
74
|
);
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
const messageContextService = new MessageContextService(node);
|
|
77
|
+
|
|
78
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
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
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
AnchorBlockStore,
|
|
10
10
|
CapsuleStore,
|
|
11
11
|
ContractStore,
|
|
12
|
+
ContractSyncService,
|
|
12
13
|
JobCoordinator,
|
|
13
14
|
NoteService,
|
|
14
15
|
NoteStore,
|
|
@@ -150,6 +151,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
150
151
|
private chainId: Fr,
|
|
151
152
|
private version: Fr,
|
|
152
153
|
private nextBlockTimestamp: bigint,
|
|
154
|
+
private contractSyncService: ContractSyncService,
|
|
153
155
|
) {}
|
|
154
156
|
|
|
155
157
|
static async init(contractStore: ContractStore) {
|
|
@@ -177,7 +179,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
177
179
|
|
|
178
180
|
const archiver = new TXEArchiver(store);
|
|
179
181
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
180
|
-
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
182
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore, keyStore);
|
|
181
183
|
|
|
182
184
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
183
185
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
@@ -185,6 +187,15 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
185
187
|
|
|
186
188
|
const initialJobId = jobCoordinator.beginJob();
|
|
187
189
|
|
|
190
|
+
const logger = createLogger('txe:session');
|
|
191
|
+
const contractSyncService = new ContractSyncService(
|
|
192
|
+
stateMachine.node,
|
|
193
|
+
contractStore,
|
|
194
|
+
noteStore,
|
|
195
|
+
() => keyStore.getAccounts(),
|
|
196
|
+
logger,
|
|
197
|
+
);
|
|
198
|
+
|
|
188
199
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
189
200
|
stateMachine,
|
|
190
201
|
contractStore,
|
|
@@ -201,11 +212,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
201
212
|
version,
|
|
202
213
|
chainId,
|
|
203
214
|
new Map(),
|
|
215
|
+
contractSyncService,
|
|
204
216
|
);
|
|
205
|
-
await topLevelOracleHandler.
|
|
217
|
+
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
206
218
|
|
|
207
219
|
return new TXESession(
|
|
208
|
-
|
|
220
|
+
logger,
|
|
209
221
|
stateMachine,
|
|
210
222
|
topLevelOracleHandler,
|
|
211
223
|
contractStore,
|
|
@@ -223,6 +235,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
223
235
|
version,
|
|
224
236
|
chainId,
|
|
225
237
|
nextBlockTimestamp,
|
|
238
|
+
contractSyncService,
|
|
226
239
|
);
|
|
227
240
|
}
|
|
228
241
|
|
|
@@ -309,6 +322,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
309
322
|
this.version,
|
|
310
323
|
this.chainId,
|
|
311
324
|
this.authwits,
|
|
325
|
+
this.contractSyncService,
|
|
312
326
|
);
|
|
313
327
|
|
|
314
328
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -369,6 +383,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
369
383
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
370
384
|
jobId: this.currentJobId,
|
|
371
385
|
scopes: 'ALL_SCOPES',
|
|
386
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
372
387
|
});
|
|
373
388
|
|
|
374
389
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -437,6 +452,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
437
452
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
438
453
|
capsuleStore: this.capsuleStore,
|
|
439
454
|
privateEventStore: this.privateEventStore,
|
|
455
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
456
|
+
contractSyncService: this.contractSyncService,
|
|
440
457
|
jobId: this.currentJobId,
|
|
441
458
|
scopes: 'ALL_SCOPES',
|
|
442
459
|
});
|
|
@@ -452,8 +469,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
452
469
|
|
|
453
470
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
454
471
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
455
|
-
// others, it will create empty blocks (via `
|
|
456
|
-
// `
|
|
472
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
473
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
457
474
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
458
475
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
459
476
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -528,6 +545,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
528
545
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
529
546
|
capsuleStore: this.capsuleStore,
|
|
530
547
|
privateEventStore: this.privateEventStore,
|
|
548
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
549
|
+
contractSyncService: this.contractSyncService,
|
|
531
550
|
jobId: this.currentJobId,
|
|
532
551
|
scopes,
|
|
533
552
|
});
|