@aztec/txe 0.0.1-commit.db765a8 → 0.0.1-commit.ddcf04837
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/oracle/txe_oracle_top_level_context.d.ts +10 -4
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +34 -17
- package/dest/rpc_translator.d.ts +58 -20
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +179 -50
- 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 +7 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- 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 +8 -4
- package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +35 -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 +4 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +24 -12
- package/dest/util/encoding.d.ts +71 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/dest/util/txe_public_contract_data_source.d.ts +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -3
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +44 -21
- package/src/rpc_translator.ts +224 -59
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +8 -2
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +26 -10
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +0 -2
|
@@ -8,7 +8,7 @@ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/ep
|
|
|
8
8
|
* Since in TXE we don't validate transactions, mock suffices here.
|
|
9
9
|
*/
|
|
10
10
|
export class MockEpochCache implements EpochCacheInterface {
|
|
11
|
-
getCommittee(): Promise<EpochCommitteeInfo> {
|
|
11
|
+
getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
|
|
12
12
|
return Promise.resolve({
|
|
13
13
|
committee: undefined,
|
|
14
14
|
seed: 0n,
|
|
@@ -17,6 +17,22 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
getSlotNow(): SlotNumber {
|
|
21
|
+
return SlotNumber(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getTargetSlot(): SlotNumber {
|
|
25
|
+
return SlotNumber(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getEpochNow(): EpochNumber {
|
|
29
|
+
return EpochNumber.ZERO;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getTargetEpoch(): EpochNumber {
|
|
33
|
+
return EpochNumber.ZERO;
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
21
37
|
return {
|
|
22
38
|
epoch: EpochNumber.ZERO,
|
|
@@ -26,15 +42,27 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
26
42
|
};
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
45
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
30
46
|
return {
|
|
31
47
|
epoch: EpochNumber.ZERO,
|
|
32
48
|
slot: SlotNumber(0),
|
|
33
49
|
ts: 0n,
|
|
34
|
-
|
|
50
|
+
nowSeconds: 0n,
|
|
35
51
|
};
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
55
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isProposerPipeliningEnabled(): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
pipeliningOffset(): number {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
38
66
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
39
67
|
return '0x00';
|
|
40
68
|
}
|
|
@@ -50,6 +78,13 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
50
78
|
};
|
|
51
79
|
}
|
|
52
80
|
|
|
81
|
+
getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
82
|
+
return {
|
|
83
|
+
targetSlot: SlotNumber(0),
|
|
84
|
+
nextSlot: SlotNumber(0),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
53
88
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
54
89
|
return Promise.resolve(undefined);
|
|
55
90
|
}
|
|
@@ -66,6 +101,14 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
66
101
|
return Promise.resolve([]);
|
|
67
102
|
}
|
|
68
103
|
|
|
104
|
+
isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean> {
|
|
105
|
+
return Promise.resolve(false);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
isEscapeHatchOpenAtSlot(_slot: SlotTag): Promise<boolean> {
|
|
109
|
+
return Promise.resolve(false);
|
|
110
|
+
}
|
|
111
|
+
|
|
69
112
|
getL1Constants(): L1RollupConstants {
|
|
70
113
|
return EmptyL1RollupConstants;
|
|
71
114
|
}
|
|
@@ -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,
|
|
@@ -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) {
|
|
@@ -185,6 +187,9 @@ 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(stateMachine.node, contractStore, noteStore, logger);
|
|
192
|
+
|
|
188
193
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
189
194
|
stateMachine,
|
|
190
195
|
contractStore,
|
|
@@ -201,11 +206,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
201
206
|
version,
|
|
202
207
|
chainId,
|
|
203
208
|
new Map(),
|
|
209
|
+
contractSyncService,
|
|
204
210
|
);
|
|
205
211
|
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
206
212
|
|
|
207
213
|
return new TXESession(
|
|
208
|
-
|
|
214
|
+
logger,
|
|
209
215
|
stateMachine,
|
|
210
216
|
topLevelOracleHandler,
|
|
211
217
|
contractStore,
|
|
@@ -223,6 +229,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
223
229
|
version,
|
|
224
230
|
chainId,
|
|
225
231
|
nextBlockTimestamp,
|
|
232
|
+
contractSyncService,
|
|
226
233
|
);
|
|
227
234
|
}
|
|
228
235
|
|
|
@@ -309,6 +316,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
309
316
|
this.version,
|
|
310
317
|
this.chainId,
|
|
311
318
|
this.authwits,
|
|
319
|
+
this.contractSyncService,
|
|
312
320
|
);
|
|
313
321
|
|
|
314
322
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -328,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
328
336
|
|
|
329
337
|
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
330
338
|
contractAddress,
|
|
331
|
-
|
|
339
|
+
await this.keyStore.getAccounts(),
|
|
332
340
|
);
|
|
333
341
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
334
342
|
|
|
@@ -364,11 +372,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
364
372
|
senderTaggingStore: this.senderTaggingStore,
|
|
365
373
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
366
374
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
367
|
-
|
|
375
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
368
376
|
privateEventStore: this.privateEventStore,
|
|
369
377
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
378
|
+
l2TipsStore: this.stateMachine.node,
|
|
370
379
|
jobId: this.currentJobId,
|
|
371
|
-
scopes:
|
|
380
|
+
scopes: await this.keyStore.getAccounts(),
|
|
381
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
372
382
|
});
|
|
373
383
|
|
|
374
384
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -421,7 +431,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
421
431
|
this.stateMachine.node,
|
|
422
432
|
anchorBlockHeader,
|
|
423
433
|
this.currentJobId,
|
|
424
|
-
).syncNoteNullifiers(contractAddress,
|
|
434
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
425
435
|
|
|
426
436
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
427
437
|
contractAddress,
|
|
@@ -435,10 +445,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
435
445
|
aztecNode: this.stateMachine.node,
|
|
436
446
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
437
447
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
438
|
-
|
|
448
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
439
449
|
privateEventStore: this.privateEventStore,
|
|
450
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
451
|
+
contractSyncService: this.contractSyncService,
|
|
452
|
+
l2TipsStore: this.stateMachine.node,
|
|
440
453
|
jobId: this.currentJobId,
|
|
441
|
-
scopes:
|
|
454
|
+
scopes: await this.keyStore.getAccounts(),
|
|
442
455
|
});
|
|
443
456
|
|
|
444
457
|
this.state = { name: 'UTILITY' };
|
|
@@ -507,7 +520,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
507
520
|
}
|
|
508
521
|
|
|
509
522
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
510
|
-
return async (call: FunctionCall, scopes:
|
|
523
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
511
524
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
512
525
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
513
526
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -526,8 +539,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
526
539
|
aztecNode: this.stateMachine.node,
|
|
527
540
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
528
541
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
529
|
-
|
|
542
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
530
543
|
privateEventStore: this.privateEventStore,
|
|
544
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
545
|
+
contractSyncService: this.contractSyncService,
|
|
546
|
+
l2TipsStore: this.stateMachine.node,
|
|
531
547
|
jobId: this.currentJobId,
|
|
532
548
|
scopes,
|
|
533
549
|
});
|
package/src/util/encoding.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import { hexToBuffer } from '@aztec/foundation/string';
|
|
4
4
|
import { type ContractArtifact, ContractArtifactSchema } from '@aztec/stdlib/abi';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
6
7
|
import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
|
|
7
8
|
|
|
8
9
|
import { z } from 'zod';
|
|
@@ -25,6 +26,10 @@ export function addressFromSingle(obj: ForeignCallSingle) {
|
|
|
25
26
|
return new AztecAddress(fromSingle(obj));
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
export function blockHashFromSingle(obj: ForeignCallSingle) {
|
|
30
|
+
return new BlockHash(fromSingle(obj));
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
export function fromArray(obj: ForeignCallArray) {
|
|
29
34
|
return obj.map(str => Fr.fromBuffer(hexToBuffer(str)));
|
|
30
35
|
}
|
|
@@ -26,8 +26,6 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
26
26
|
packedBytecode: contractClass.packedBytecode,
|
|
27
27
|
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
28
28
|
version: contractClass.version,
|
|
29
|
-
privateFunctions: [],
|
|
30
|
-
utilityFunctions: [],
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
|