@aztec/txe 3.0.0-devnet.5 → 3.0.0-devnet.6-patch.1
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/bin/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/oracle/interfaces.d.ts +6 -5
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +4 -4
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +4 -3
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +31 -22
- package/dest/rpc_translator.d.ts +10 -7
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +36 -17
- package/dest/state_machine/archiver.d.ts +14 -9
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +14 -4
- package/dest/state_machine/dummy_p2p_client.d.ts +4 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +3 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +1 -1
- package/dest/state_machine/mock_epoch_cache.d.ts +6 -5
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +8 -7
- package/dest/state_machine/synchronizer.d.ts +5 -4
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +5 -5
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +9 -6
- package/dest/util/encoding.d.ts +24 -24
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +1 -1
- package/dest/util/expected_failure_error.d.ts +1 -1
- package/dest/util/expected_failure_error.d.ts.map +1 -1
- package/dest/util/txe_account_data_provider.d.ts +1 -1
- package/dest/util/txe_account_data_provider.d.ts.map +1 -1
- package/dest/util/txe_contract_data_provider.d.ts +1 -1
- package/dest/util/txe_contract_data_provider.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +5 -4
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -1
- package/dest/utils/block_creation.d.ts +4 -3
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +2 -2
- package/dest/utils/tx_effect_creation.d.ts +4 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +6 -6
- package/package.json +18 -17
- package/src/oracle/interfaces.ts +5 -4
- package/src/oracle/txe_oracle_public_context.ts +3 -3
- package/src/oracle/txe_oracle_top_level_context.ts +32 -23
- package/src/rpc_translator.ts +46 -18
- package/src/state_machine/archiver.ts +25 -11
- package/src/state_machine/dummy_p2p_client.ts +6 -1
- package/src/state_machine/global_variable_builder.ts +3 -2
- package/src/state_machine/index.ts +1 -1
- package/src/state_machine/mock_epoch_cache.ts +12 -11
- package/src/state_machine/synchronizer.ts +8 -7
- package/src/txe_session.ts +12 -10
- package/src/util/encoding.ts +1 -1
- package/src/util/txe_public_contract_data_source.ts +4 -3
- package/src/utils/block_creation.ts +4 -2
- package/src/utils/tx_effect_creation.ts +8 -7
package/src/rpc_translator.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
3
3
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
4
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
5
|
import {
|
|
5
6
|
type IMiscOracle,
|
|
6
7
|
type IPrivateExecutionOracle,
|
|
@@ -117,7 +118,7 @@ export class RPCTranslator {
|
|
|
117
118
|
: undefined;
|
|
118
119
|
|
|
119
120
|
const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool()
|
|
120
|
-
? fromSingle(foreignAnchorBlockNumberValue).toNumber()
|
|
121
|
+
? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber())
|
|
121
122
|
: undefined;
|
|
122
123
|
|
|
123
124
|
const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
|
|
@@ -266,12 +267,7 @@ export class RPCTranslator {
|
|
|
266
267
|
]);
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
|
|
270
|
-
privateStoreInExecutionCache(
|
|
271
|
-
_foreignLength: ForeignCallSingle,
|
|
272
|
-
foreignValues: ForeignCallArray,
|
|
273
|
-
foreignHash: ForeignCallSingle,
|
|
274
|
-
) {
|
|
270
|
+
privateStoreInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
|
|
275
271
|
const values = fromArray(foreignValues);
|
|
276
272
|
const hash = fromSingle(foreignHash);
|
|
277
273
|
|
|
@@ -315,7 +311,7 @@ export class RPCTranslator {
|
|
|
315
311
|
) {
|
|
316
312
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
317
313
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
318
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
314
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
319
315
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
320
316
|
|
|
321
317
|
const values = await this.handlerAsUtility().utilityStorageRead(
|
|
@@ -329,7 +325,7 @@ export class RPCTranslator {
|
|
|
329
325
|
}
|
|
330
326
|
|
|
331
327
|
async utilityGetPublicDataWitness(foreignBlockNumber: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
332
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
328
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
333
329
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
334
330
|
|
|
335
331
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockNumber, leafSlot);
|
|
@@ -341,6 +337,8 @@ export class RPCTranslator {
|
|
|
341
337
|
}
|
|
342
338
|
|
|
343
339
|
async utilityGetNotes(
|
|
340
|
+
foreignOwnerIsSome: ForeignCallSingle,
|
|
341
|
+
foreignOwnerValue: ForeignCallSingle,
|
|
344
342
|
foreignStorageSlot: ForeignCallSingle,
|
|
345
343
|
foreignNumSelects: ForeignCallSingle,
|
|
346
344
|
foreignSelectByIndexes: ForeignCallArray,
|
|
@@ -358,6 +356,10 @@ export class RPCTranslator {
|
|
|
358
356
|
foreignMaxNotes: ForeignCallSingle,
|
|
359
357
|
foreignPackedRetrievedNoteLength: ForeignCallSingle,
|
|
360
358
|
) {
|
|
359
|
+
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
360
|
+
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
361
|
+
? AztecAddress.fromField(fromSingle(foreignOwnerValue))
|
|
362
|
+
: undefined;
|
|
361
363
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
362
364
|
const numSelects = fromSingle(foreignNumSelects).toNumber();
|
|
363
365
|
const selectByIndexes = fromArray(foreignSelectByIndexes).map(fr => fr.toNumber());
|
|
@@ -376,6 +378,7 @@ export class RPCTranslator {
|
|
|
376
378
|
const packedRetrievedNoteLength = fromSingle(foreignPackedRetrievedNoteLength).toNumber();
|
|
377
379
|
|
|
378
380
|
const noteDatas = await this.handlerAsUtility().utilityGetNotes(
|
|
381
|
+
owner,
|
|
379
382
|
storageSlot,
|
|
380
383
|
numSelects,
|
|
381
384
|
selectByIndexes,
|
|
@@ -392,7 +395,17 @@ export class RPCTranslator {
|
|
|
392
395
|
status,
|
|
393
396
|
);
|
|
394
397
|
|
|
395
|
-
const returnDataAsArrayOfArrays = noteDatas.map(
|
|
398
|
+
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
399
|
+
packAsRetrievedNote({
|
|
400
|
+
contractAddress: noteData.contractAddress,
|
|
401
|
+
owner: noteData.owner,
|
|
402
|
+
randomness: noteData.randomness,
|
|
403
|
+
storageSlot: noteData.storageSlot,
|
|
404
|
+
noteNonce: noteData.noteNonce,
|
|
405
|
+
index: noteData.index,
|
|
406
|
+
note: noteData.note,
|
|
407
|
+
}),
|
|
408
|
+
);
|
|
396
409
|
|
|
397
410
|
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
398
411
|
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map(subArray =>
|
|
@@ -410,19 +423,31 @@ export class RPCTranslator {
|
|
|
410
423
|
}
|
|
411
424
|
|
|
412
425
|
privateNotifyCreatedNote(
|
|
426
|
+
foreignOwner: ForeignCallSingle,
|
|
413
427
|
foreignStorageSlot: ForeignCallSingle,
|
|
428
|
+
foreignRandomness: ForeignCallSingle,
|
|
414
429
|
foreignNoteTypeId: ForeignCallSingle,
|
|
415
430
|
foreignNote: ForeignCallArray,
|
|
416
431
|
foreignNoteHash: ForeignCallSingle,
|
|
417
432
|
foreignCounter: ForeignCallSingle,
|
|
418
433
|
) {
|
|
434
|
+
const owner = addressFromSingle(foreignOwner);
|
|
419
435
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
436
|
+
const randomness = fromSingle(foreignRandomness);
|
|
420
437
|
const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
|
|
421
438
|
const note = fromArray(foreignNote);
|
|
422
439
|
const noteHash = fromSingle(foreignNoteHash);
|
|
423
440
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
424
441
|
|
|
425
|
-
this.handlerAsPrivate().privateNotifyCreatedNote(
|
|
442
|
+
this.handlerAsPrivate().privateNotifyCreatedNote(
|
|
443
|
+
owner,
|
|
444
|
+
storageSlot,
|
|
445
|
+
randomness,
|
|
446
|
+
noteTypeId,
|
|
447
|
+
note,
|
|
448
|
+
noteHash,
|
|
449
|
+
counter,
|
|
450
|
+
);
|
|
426
451
|
|
|
427
452
|
return toForeignCallResult([]);
|
|
428
453
|
}
|
|
@@ -505,7 +530,7 @@ export class RPCTranslator {
|
|
|
505
530
|
foreignBlockNumber: ForeignCallSingle,
|
|
506
531
|
foreignNullifier: ForeignCallSingle,
|
|
507
532
|
) {
|
|
508
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
533
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
509
534
|
const nullifier = fromSingle(foreignNullifier);
|
|
510
535
|
|
|
511
536
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockNumber, nullifier);
|
|
@@ -549,6 +574,12 @@ export class RPCTranslator {
|
|
|
549
574
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
550
575
|
}
|
|
551
576
|
|
|
577
|
+
public async privateIsSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
|
|
578
|
+
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
579
|
+
const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
|
|
580
|
+
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
581
|
+
}
|
|
582
|
+
|
|
552
583
|
async utilityGetUtilityContext() {
|
|
553
584
|
const context = await this.handlerAsUtility().utilityGetUtilityContext();
|
|
554
585
|
|
|
@@ -556,7 +587,7 @@ export class RPCTranslator {
|
|
|
556
587
|
}
|
|
557
588
|
|
|
558
589
|
async utilityGetBlockHeader(foreignBlockNumber: ForeignCallSingle) {
|
|
559
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
590
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
560
591
|
|
|
561
592
|
const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
|
|
562
593
|
|
|
@@ -571,7 +602,7 @@ export class RPCTranslator {
|
|
|
571
602
|
foreignTreeId: ForeignCallSingle,
|
|
572
603
|
foreignLeafValue: ForeignCallSingle,
|
|
573
604
|
) {
|
|
574
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
605
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
575
606
|
const treeId = fromSingle(foreignTreeId).toNumber();
|
|
576
607
|
const leafValue = fromSingle(foreignLeafValue);
|
|
577
608
|
|
|
@@ -589,7 +620,7 @@ export class RPCTranslator {
|
|
|
589
620
|
foreignBlockNumber: ForeignCallSingle,
|
|
590
621
|
foreignNullifier: ForeignCallSingle,
|
|
591
622
|
) {
|
|
592
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
623
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
593
624
|
const nullifier = fromSingle(foreignNullifier);
|
|
594
625
|
|
|
595
626
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
@@ -921,7 +952,6 @@ export class RPCTranslator {
|
|
|
921
952
|
foreignFrom: ForeignCallSingle,
|
|
922
953
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
923
954
|
foreignFunctionSelector: ForeignCallSingle,
|
|
924
|
-
_foreignArgsLength: ForeignCallSingle,
|
|
925
955
|
foreignArgs: ForeignCallArray,
|
|
926
956
|
foreignArgsHash: ForeignCallSingle,
|
|
927
957
|
foreignIsStaticCall: ForeignCallSingle,
|
|
@@ -948,7 +978,6 @@ export class RPCTranslator {
|
|
|
948
978
|
async txeSimulateUtilityFunction(
|
|
949
979
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
950
980
|
foreignFunctionSelector: ForeignCallSingle,
|
|
951
|
-
_foreignArgsLength: ForeignCallSingle,
|
|
952
981
|
foreignArgs: ForeignCallArray,
|
|
953
982
|
) {
|
|
954
983
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
@@ -967,7 +996,6 @@ export class RPCTranslator {
|
|
|
967
996
|
async txePublicCallNewFlow(
|
|
968
997
|
foreignFrom: ForeignCallSingle,
|
|
969
998
|
foreignAddress: ForeignCallSingle,
|
|
970
|
-
_foreignLength: ForeignCallSingle,
|
|
971
999
|
foreignCalldata: ForeignCallArray,
|
|
972
1000
|
foreignIsStaticCall: ForeignCallSingle,
|
|
973
1001
|
) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ArchiverStoreHelper, KVArchiverDataStore, type PublishedL2Block } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
8
|
import type { L2Block, L2BlockSource, L2Tips, ValidateBlockResult } from '@aztec/stdlib/block';
|
|
9
|
+
import type { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
10
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
9
11
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
10
12
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
@@ -31,7 +33,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
31
33
|
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
32
34
|
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
33
35
|
*/
|
|
34
|
-
public getBlockNumber(): Promise<
|
|
36
|
+
public getBlockNumber(): Promise<BlockNumber> {
|
|
35
37
|
return this.store.getSynchedL2BlockNumber();
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -39,7 +41,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
39
41
|
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
40
42
|
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
41
43
|
*/
|
|
42
|
-
public getProvenBlockNumber(): Promise<
|
|
44
|
+
public getProvenBlockNumber(): Promise<BlockNumber> {
|
|
43
45
|
return this.store.getSynchedL2BlockNumber();
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -56,7 +58,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
56
58
|
if (number == 0) {
|
|
57
59
|
return undefined;
|
|
58
60
|
}
|
|
59
|
-
const blocks = await this.store.getPublishedBlocks(number, 1);
|
|
61
|
+
const blocks = await this.store.getPublishedBlocks(BlockNumber(number), 1);
|
|
60
62
|
return blocks.length === 0 ? undefined : blocks[0];
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -81,31 +83,43 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
81
83
|
if (number === 0) {
|
|
82
84
|
return undefined;
|
|
83
85
|
}
|
|
84
|
-
const headers = await this.store.getBlockHeaders(number, 1);
|
|
86
|
+
const headers = await this.store.getBlockHeaders(BlockNumber(number), 1);
|
|
85
87
|
return headers.length === 0 ? undefined : headers[0];
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
public getBlocks(from: number, limit: number, _proven?: boolean): Promise<L2Block[]> {
|
|
89
|
-
return this.getPublishedBlocks(from, limit).then(blocks => blocks.map(b => b.block));
|
|
91
|
+
return this.getPublishedBlocks(BlockNumber(from), limit).then(blocks => blocks.map(b => b.block));
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
public
|
|
94
|
+
public getPublishedCheckpoints(_from: CheckpointNumber, _limit: number): Promise<PublishedCheckpoint[]> {
|
|
95
|
+
throw new Error('TXE Archiver does not implement "getPublishedCheckpoints"');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public getCheckpointByArchive(_archive: Fr): Promise<Checkpoint | undefined> {
|
|
99
|
+
throw new Error('TXE Archiver does not implement "getCheckpointByArchive"');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public getL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
93
103
|
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
94
104
|
}
|
|
95
105
|
|
|
96
|
-
public getL2EpochNumber(): Promise<
|
|
106
|
+
public getL2EpochNumber(): Promise<EpochNumber> {
|
|
97
107
|
throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
public
|
|
110
|
+
public getCheckpointsForEpoch(_epochNumber: EpochNumber): Promise<Checkpoint[]> {
|
|
111
|
+
throw new Error('TXE Archiver does not implement "getCheckpointsForEpoch"');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public getBlocksForEpoch(_epochNumber: EpochNumber): Promise<L2Block[]> {
|
|
101
115
|
throw new Error('TXE Archiver does not implement "getBlocksForEpoch"');
|
|
102
116
|
}
|
|
103
117
|
|
|
104
|
-
public getBlockHeadersForEpoch(_epochNumber:
|
|
118
|
+
public getBlockHeadersForEpoch(_epochNumber: EpochNumber): Promise<BlockHeader[]> {
|
|
105
119
|
throw new Error('TXE Archiver does not implement "getBlockHeadersForEpoch"');
|
|
106
120
|
}
|
|
107
121
|
|
|
108
|
-
public isEpochComplete(_epochNumber:
|
|
122
|
+
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
109
123
|
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
110
124
|
}
|
|
111
125
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type {
|
|
2
3
|
AuthRequest,
|
|
3
4
|
ENR,
|
|
@@ -17,6 +18,10 @@ import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
|
17
18
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
18
19
|
|
|
19
20
|
export class DummyP2P implements P2P {
|
|
21
|
+
public broadcastAttestations(_attestations: BlockAttestation[]): Promise<void> {
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
public validate(_txs: Tx[]): Promise<void> {
|
|
21
26
|
return Promise.resolve();
|
|
22
27
|
}
|
|
@@ -113,7 +118,7 @@ export class DummyP2P implements P2P {
|
|
|
113
118
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
public getAttestationsForSlot(_slot:
|
|
121
|
+
public getAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<BlockAttestation[]> {
|
|
117
122
|
throw new Error('DummyP2P does not implement "getAttestationForSlot"');
|
|
118
123
|
}
|
|
119
124
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -10,10 +11,10 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
public buildGlobalVariables(
|
|
13
|
-
_blockNumber:
|
|
14
|
+
_blockNumber: BlockNumber,
|
|
14
15
|
_coinbase: EthAddress,
|
|
15
16
|
_feeRecipient: AztecAddress,
|
|
16
|
-
_slotNumber?:
|
|
17
|
+
_slotNumber?: SlotNumber,
|
|
17
18
|
): Promise<GlobalVariables> {
|
|
18
19
|
return Promise.resolve(makeGlobalVariables());
|
|
19
20
|
}
|
|
@@ -59,7 +59,7 @@ export class TXEStateMachine {
|
|
|
59
59
|
|
|
60
60
|
public async handleL2Block(block: L2Block) {
|
|
61
61
|
await Promise.all([
|
|
62
|
-
this.synchronizer.handleL2Block(block),
|
|
62
|
+
this.synchronizer.handleL2Block(block.toL2Block()),
|
|
63
63
|
this.archiver.addBlocks([
|
|
64
64
|
PublishedL2Block.fromFields({
|
|
65
65
|
block,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -10,46 +11,46 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
10
11
|
return Promise.resolve({
|
|
11
12
|
committee: undefined,
|
|
12
13
|
seed: 0n,
|
|
13
|
-
epoch:
|
|
14
|
+
epoch: EpochNumber.ZERO,
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
getEpochAndSlotNow(): EpochAndSlot {
|
|
18
19
|
return {
|
|
19
|
-
epoch:
|
|
20
|
-
slot:
|
|
20
|
+
epoch: EpochNumber.ZERO,
|
|
21
|
+
slot: SlotNumber(0),
|
|
21
22
|
ts: 0n,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint } {
|
|
26
27
|
return {
|
|
27
|
-
epoch:
|
|
28
|
-
slot:
|
|
28
|
+
epoch: EpochNumber.ZERO,
|
|
29
|
+
slot: SlotNumber(0),
|
|
29
30
|
ts: 0n,
|
|
30
31
|
now: 0n,
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
getProposerIndexEncoding(_epoch:
|
|
35
|
+
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
35
36
|
return '0x00';
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
computeProposerIndex(_slot:
|
|
39
|
+
computeProposerIndex(_slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, _size: bigint): bigint {
|
|
39
40
|
return 0n;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
|
|
43
44
|
currentProposer: EthAddress | undefined;
|
|
44
45
|
nextProposer: EthAddress | undefined;
|
|
45
|
-
currentSlot:
|
|
46
|
-
nextSlot:
|
|
46
|
+
currentSlot: SlotNumber;
|
|
47
|
+
nextSlot: SlotNumber;
|
|
47
48
|
}> {
|
|
48
49
|
return Promise.resolve({
|
|
49
50
|
currentProposer: undefined,
|
|
50
51
|
nextProposer: undefined,
|
|
51
|
-
currentSlot:
|
|
52
|
-
nextSlot:
|
|
52
|
+
currentSlot: SlotNumber(0),
|
|
53
|
+
nextSlot: SlotNumber(0),
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
4
5
|
import type {
|
|
5
6
|
MerkleTreeReadOperations,
|
|
6
7
|
MerkleTreeWriteOperations,
|
|
@@ -12,7 +13,7 @@ import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
|
12
13
|
|
|
13
14
|
export class TXESynchronizer implements WorldStateSynchronizer {
|
|
14
15
|
// This works when set to 1 as well.
|
|
15
|
-
private blockNumber =
|
|
16
|
+
private blockNumber = BlockNumber.ZERO;
|
|
16
17
|
|
|
17
18
|
constructor(public nativeWorldStateService: NativeWorldStateService) {}
|
|
18
19
|
|
|
@@ -22,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
22
23
|
return new this(nativeWorldStateService);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
public async handleL2Block(block:
|
|
26
|
+
public async handleL2Block(block: L2BlockNew) {
|
|
26
27
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
27
28
|
block,
|
|
28
29
|
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
|
|
@@ -37,7 +38,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
37
38
|
* @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
|
|
38
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
39
40
|
*/
|
|
40
|
-
public syncImmediate(_minBlockNumber?:
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber> {
|
|
41
42
|
return Promise.resolve(this.blockNumber);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -48,12 +49,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
48
49
|
|
|
49
50
|
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
50
51
|
public fork(block?: number): Promise<MerkleTreeWriteOperations> {
|
|
51
|
-
return this.nativeWorldStateService.fork(block);
|
|
52
|
+
return this.nativeWorldStateService.fork(block ? BlockNumber(block) : undefined);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/** Gets a handle that allows reading the state as it was at the given block number. */
|
|
55
56
|
public getSnapshot(blockNumber: number): MerkleTreeReadOperations {
|
|
56
|
-
return this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
57
|
+
return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/** Backups the db to the target path. */
|
package/src/txe_session.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
4
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
@@ -25,10 +26,10 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
25
26
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
27
|
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
27
28
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
29
|
+
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
28
30
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
29
31
|
import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
30
32
|
import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
31
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
32
33
|
|
|
33
34
|
import { z } from 'zod';
|
|
34
35
|
|
|
@@ -66,7 +67,7 @@ type SessionState =
|
|
|
66
67
|
| {
|
|
67
68
|
name: 'PRIVATE';
|
|
68
69
|
nextBlockGlobalVariables: GlobalVariables;
|
|
69
|
-
|
|
70
|
+
protocolNullifier: Fr;
|
|
70
71
|
noteCache: ExecutionNoteCache;
|
|
71
72
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
72
73
|
}
|
|
@@ -101,7 +102,7 @@ export type TXEOracleFunctionName = Exclude<
|
|
|
101
102
|
export interface TXESessionStateHandler {
|
|
102
103
|
enterTopLevelState(): Promise<void>;
|
|
103
104
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
104
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
105
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
105
106
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -270,7 +271,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
270
271
|
|
|
271
272
|
async enterPrivateState(
|
|
272
273
|
contractAddress: AztecAddress = DEFAULT_ADDRESS,
|
|
273
|
-
anchorBlockNumber?:
|
|
274
|
+
anchorBlockNumber?: BlockNumber,
|
|
274
275
|
): Promise<PrivateContextInputs> {
|
|
275
276
|
this.exitTopLevelState();
|
|
276
277
|
|
|
@@ -288,14 +289,15 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
288
289
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
289
290
|
|
|
290
291
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
291
|
-
blockNumber: latestBlock!.globalVariables.blockNumber + 1,
|
|
292
|
+
blockNumber: BlockNumber(latestBlock!.globalVariables.blockNumber + 1),
|
|
292
293
|
timestamp: this.nextBlockTimestamp,
|
|
293
294
|
version: this.version,
|
|
294
295
|
chainId: this.chainId,
|
|
295
296
|
});
|
|
296
297
|
|
|
297
298
|
const txRequestHash = getSingleTxBlockRequestHash(nextBlockGlobalVariables.blockNumber);
|
|
298
|
-
const
|
|
299
|
+
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
300
|
+
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
299
301
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
300
302
|
|
|
301
303
|
this.oracleHandler = new PrivateExecutionOracle(
|
|
@@ -316,7 +318,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
316
318
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
317
319
|
// will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
|
|
318
320
|
// execution finishes.
|
|
319
|
-
this.state = { name: 'PRIVATE', nextBlockGlobalVariables,
|
|
321
|
+
this.state = { name: 'PRIVATE', nextBlockGlobalVariables, protocolNullifier, noteCache, taggingIndexCache };
|
|
320
322
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
321
323
|
|
|
322
324
|
return (this.oracleHandler as PrivateExecutionOracle).getPrivateContextInputs();
|
|
@@ -329,7 +331,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
329
331
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
330
332
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.blockNumber;
|
|
331
333
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
332
|
-
blockNumber: latestBlockNumber + 1,
|
|
334
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
333
335
|
timestamp: this.nextBlockTimestamp,
|
|
334
336
|
version: this.version,
|
|
335
337
|
chainId: this.chainId,
|
|
@@ -392,7 +394,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
392
394
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
393
395
|
const txEffect = await makeTxEffect(
|
|
394
396
|
this.state.noteCache,
|
|
395
|
-
this.state.
|
|
397
|
+
this.state.protocolNullifier,
|
|
396
398
|
this.state.nextBlockGlobalVariables.blockNumber,
|
|
397
399
|
);
|
|
398
400
|
|
package/src/util/encoding.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
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';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { ContractDataProvider } from '@aztec/pxe/server';
|
|
3
4
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -14,11 +15,11 @@ import {
|
|
|
14
15
|
export class TXEPublicContractDataSource implements ContractDataSource {
|
|
15
16
|
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
16
17
|
constructor(
|
|
17
|
-
private blockNumber:
|
|
18
|
+
private blockNumber: BlockNumber,
|
|
18
19
|
private contractDataProvider: ContractDataProvider,
|
|
19
20
|
) {}
|
|
20
21
|
|
|
21
|
-
getBlockNumber(): Promise<
|
|
22
|
+
getBlockNumber(): Promise<BlockNumber> {
|
|
22
23
|
return Promise.resolve(this.blockNumber);
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
5
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
8
|
-
import { Fr } from '@aztec/foundation/
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
10
|
import { L2BlockHeader } from '@aztec/stdlib/block';
|
|
10
11
|
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
11
12
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
@@ -16,7 +17,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
|
16
17
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
17
18
|
* @returns The transaction request hash.
|
|
18
19
|
*/
|
|
19
|
-
export function getSingleTxBlockRequestHash(blockNumber:
|
|
20
|
+
export function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr {
|
|
20
21
|
return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -58,5 +59,6 @@ export async function makeTXEBlockHeader(
|
|
|
58
59
|
Fr.ZERO,
|
|
59
60
|
Fr.ZERO,
|
|
60
61
|
Fr.ZERO,
|
|
62
|
+
Fr.ZERO,
|
|
61
63
|
);
|
|
62
64
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
3
4
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
4
5
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
7
|
export async function makeTxEffect(
|
|
7
8
|
noteCache: ExecutionNoteCache,
|
|
8
|
-
|
|
9
|
-
txBlockNumber:
|
|
9
|
+
protocolNullifier: Fr,
|
|
10
|
+
txBlockNumber: BlockNumber,
|
|
10
11
|
): Promise<TxEffect> {
|
|
11
12
|
const txEffect = TxEffect.empty();
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
-
const nonceGenerator =
|
|
14
|
+
const { usedProtocolNullifierForNonces } = noteCache.finish();
|
|
15
|
+
const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
|
|
15
16
|
|
|
16
17
|
txEffect.noteHashes = await Promise.all(
|
|
17
18
|
noteCache
|
|
@@ -27,8 +28,8 @@ export async function makeTxEffect(
|
|
|
27
28
|
// Nullifiers are already siloed
|
|
28
29
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
29
30
|
|
|
30
|
-
if (
|
|
31
|
-
txEffect.nullifiers.unshift(
|
|
31
|
+
if (usedProtocolNullifierForNonces) {
|
|
32
|
+
txEffect.nullifiers.unshift(protocolNullifier);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|