@aztec/txe 0.0.1-commit.6230efd → 0.0.1-commit.64b6bbb
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/interfaces.d.ts +3 -3
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +6 -6
- 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 +99 -31
- package/dest/rpc_translator.d.ts +19 -13
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +75 -50
- package/dest/state_machine/archiver.d.ts +20 -67
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +59 -178
- package/dest/state_machine/dummy_p2p_client.d.ts +14 -12
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +26 -20
- package/dest/state_machine/global_variable_builder.d.ts +2 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +34 -11
- package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +14 -7
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +5 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +87 -15
- package/dest/util/encoding.d.ts +17 -17
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -5
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +6 -8
- package/src/oracle/txe_oracle_top_level_context.ts +118 -77
- package/src/rpc_translator.ts +78 -52
- package/src/state_machine/archiver.ts +54 -220
- package/src/state_machine/dummy_p2p_client.ts +37 -26
- package/src/state_machine/global_variable_builder.ts +1 -1
- package/src/state_machine/index.ts +48 -11
- package/src/state_machine/mock_epoch_cache.ts +15 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +90 -68
- package/src/utils/block_creation.ts +19 -16
- package/src/utils/tx_effect_creation.ts +3 -11
package/src/txe_session.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
6
6
|
import type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
7
7
|
import {
|
|
8
8
|
AddressStore,
|
|
9
|
+
AnchorBlockStore,
|
|
9
10
|
CapsuleStore,
|
|
11
|
+
JobCoordinator,
|
|
10
12
|
NoteService,
|
|
11
13
|
NoteStore,
|
|
12
14
|
PrivateEventStore,
|
|
@@ -48,6 +50,7 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
|
|
|
48
50
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
49
51
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
50
52
|
import { RPCTranslator } from './rpc_translator.js';
|
|
53
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
51
54
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
52
55
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
53
56
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
@@ -74,7 +77,6 @@ type SessionState =
|
|
|
74
77
|
| {
|
|
75
78
|
name: 'PRIVATE';
|
|
76
79
|
nextBlockGlobalVariables: GlobalVariables;
|
|
77
|
-
protocolNullifier: Fr;
|
|
78
80
|
noteCache: ExecutionNoteCache;
|
|
79
81
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
80
82
|
}
|
|
@@ -139,6 +141,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
139
141
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
140
142
|
private capsuleStore: CapsuleStore,
|
|
141
143
|
private privateEventStore: PrivateEventStore,
|
|
144
|
+
private jobCoordinator: JobCoordinator,
|
|
145
|
+
private currentJobId: string,
|
|
142
146
|
private chainId: Fr,
|
|
143
147
|
private version: Fr,
|
|
144
148
|
private nextBlockTimestamp: bigint,
|
|
@@ -150,7 +154,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
150
154
|
const addressStore = new AddressStore(store);
|
|
151
155
|
const privateEventStore = new PrivateEventStore(store);
|
|
152
156
|
const contractStore = new TXEContractStore(store);
|
|
153
|
-
const noteStore =
|
|
157
|
+
const noteStore = new NoteStore(store);
|
|
154
158
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
155
159
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
156
160
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -158,18 +162,32 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
158
162
|
const keyStore = new KeyStore(store);
|
|
159
163
|
const accountStore = new TXEAccountStore(store);
|
|
160
164
|
|
|
165
|
+
// Create job coordinator and register staged stores
|
|
166
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
167
|
+
jobCoordinator.registerStores([
|
|
168
|
+
capsuleStore,
|
|
169
|
+
senderTaggingStore,
|
|
170
|
+
recipientTaggingStore,
|
|
171
|
+
privateEventStore,
|
|
172
|
+
noteStore,
|
|
173
|
+
]);
|
|
174
|
+
|
|
161
175
|
// Register protocol contracts.
|
|
162
176
|
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
163
177
|
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
164
178
|
await contractStore.addContractInstance(instance);
|
|
165
179
|
}
|
|
166
180
|
|
|
167
|
-
const
|
|
181
|
+
const archiver = new TXEArchiver(store);
|
|
182
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
183
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
168
184
|
|
|
169
185
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
170
186
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
171
187
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
172
188
|
|
|
189
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
190
|
+
|
|
173
191
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
174
192
|
stateMachine,
|
|
175
193
|
contractStore,
|
|
@@ -182,6 +200,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
182
200
|
senderAddressBookStore,
|
|
183
201
|
capsuleStore,
|
|
184
202
|
privateEventStore,
|
|
203
|
+
initialJobId,
|
|
185
204
|
nextBlockTimestamp,
|
|
186
205
|
version,
|
|
187
206
|
chainId,
|
|
@@ -203,6 +222,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
203
222
|
senderAddressBookStore,
|
|
204
223
|
capsuleStore,
|
|
205
224
|
privateEventStore,
|
|
225
|
+
jobCoordinator,
|
|
226
|
+
initialJobId,
|
|
206
227
|
version,
|
|
207
228
|
chainId,
|
|
208
229
|
nextBlockTimestamp,
|
|
@@ -262,6 +283,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
262
283
|
}
|
|
263
284
|
}
|
|
264
285
|
|
|
286
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
287
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
288
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
289
|
+
|
|
265
290
|
this.oracleHandler = new TXEOracleTopLevelContext(
|
|
266
291
|
this.stateMachine,
|
|
267
292
|
this.contractStore,
|
|
@@ -274,6 +299,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
274
299
|
this.senderAddressBookStore,
|
|
275
300
|
this.capsuleStore,
|
|
276
301
|
this.privateEventStore,
|
|
302
|
+
this.currentJobId,
|
|
277
303
|
this.nextBlockTimestamp,
|
|
278
304
|
this.version,
|
|
279
305
|
this.chainId,
|
|
@@ -290,16 +316,14 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
290
316
|
): Promise<PrivateContextInputs> {
|
|
291
317
|
this.exitTopLevelState();
|
|
292
318
|
|
|
293
|
-
await new NoteService(
|
|
294
|
-
this.noteStore,
|
|
295
|
-
this.stateMachine.node,
|
|
296
|
-
this.stateMachine.anchorBlockStore,
|
|
297
|
-
).syncNoteNullifiers(contractAddress);
|
|
298
|
-
|
|
299
319
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
300
320
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
301
321
|
// a single transaction with the effects of what was done in the test.
|
|
302
322
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
323
|
+
|
|
324
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
325
|
+
contractAddress,
|
|
326
|
+
);
|
|
303
327
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
304
328
|
|
|
305
329
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
@@ -315,36 +339,37 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
315
339
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
316
340
|
|
|
317
341
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
318
|
-
this.oracleHandler = new PrivateExecutionOracle(
|
|
319
|
-
Fr.ZERO,
|
|
320
|
-
new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
321
|
-
new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
322
|
-
anchorBlock!,
|
|
342
|
+
this.oracleHandler = new PrivateExecutionOracle({
|
|
343
|
+
argsHash: Fr.ZERO,
|
|
344
|
+
txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
345
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
346
|
+
anchorBlockHeader: anchorBlock!,
|
|
323
347
|
utilityExecutor,
|
|
324
|
-
[],
|
|
325
|
-
[],
|
|
326
|
-
new HashedValuesCache(),
|
|
348
|
+
authWitnesses: [],
|
|
349
|
+
capsules: [],
|
|
350
|
+
executionCache: new HashedValuesCache(),
|
|
327
351
|
noteCache,
|
|
328
352
|
taggingIndexCache,
|
|
329
|
-
this.contractStore,
|
|
330
|
-
this.noteStore,
|
|
331
|
-
this.keyStore,
|
|
332
|
-
this.addressStore,
|
|
333
|
-
this.stateMachine.node,
|
|
334
|
-
this.
|
|
335
|
-
this.
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
this.
|
|
339
|
-
this.
|
|
340
|
-
|
|
353
|
+
contractStore: this.contractStore,
|
|
354
|
+
noteStore: this.noteStore,
|
|
355
|
+
keyStore: this.keyStore,
|
|
356
|
+
addressStore: this.addressStore,
|
|
357
|
+
aztecNode: this.stateMachine.node,
|
|
358
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
359
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
360
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
361
|
+
capsuleStore: this.capsuleStore,
|
|
362
|
+
privateEventStore: this.privateEventStore,
|
|
363
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
364
|
+
jobId: this.currentJobId,
|
|
365
|
+
});
|
|
341
366
|
|
|
342
367
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
343
368
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
344
369
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
345
370
|
// will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
|
|
346
371
|
// execution finishes.
|
|
347
|
-
this.state = { name: 'PRIVATE', nextBlockGlobalVariables,
|
|
372
|
+
this.state = { name: 'PRIVATE', nextBlockGlobalVariables, noteCache, taggingIndexCache };
|
|
348
373
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
349
374
|
|
|
350
375
|
return (this.oracleHandler as PrivateExecutionOracle).getPrivateContextInputs();
|
|
@@ -377,6 +402,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
377
402
|
async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
|
|
378
403
|
this.exitTopLevelState();
|
|
379
404
|
|
|
405
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
406
|
+
|
|
380
407
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
381
408
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
382
409
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
@@ -385,27 +412,26 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
385
412
|
await new NoteService(
|
|
386
413
|
this.noteStore,
|
|
387
414
|
this.stateMachine.node,
|
|
388
|
-
|
|
415
|
+
anchorBlockHeader,
|
|
416
|
+
this.currentJobId,
|
|
389
417
|
).syncNoteNullifiers(contractAddress);
|
|
390
418
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
419
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
394
420
|
contractAddress,
|
|
395
|
-
[],
|
|
396
|
-
[],
|
|
421
|
+
authWitnesses: [],
|
|
422
|
+
capsules: [],
|
|
397
423
|
anchorBlockHeader,
|
|
398
|
-
this.contractStore,
|
|
399
|
-
this.noteStore,
|
|
400
|
-
this.keyStore,
|
|
401
|
-
this.addressStore,
|
|
402
|
-
this.stateMachine.node,
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
405
|
-
this.
|
|
406
|
-
this.
|
|
407
|
-
this.
|
|
408
|
-
);
|
|
424
|
+
contractStore: this.contractStore,
|
|
425
|
+
noteStore: this.noteStore,
|
|
426
|
+
keyStore: this.keyStore,
|
|
427
|
+
addressStore: this.addressStore,
|
|
428
|
+
aztecNode: this.stateMachine.node,
|
|
429
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
430
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
431
|
+
capsuleStore: this.capsuleStore,
|
|
432
|
+
privateEventStore: this.privateEventStore,
|
|
433
|
+
jobId: this.currentJobId,
|
|
434
|
+
});
|
|
409
435
|
|
|
410
436
|
this.state = { name: 'UTILITY' };
|
|
411
437
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
@@ -440,11 +466,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
440
466
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
441
467
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
442
468
|
|
|
443
|
-
const txEffect = await makeTxEffect(
|
|
444
|
-
this.state.noteCache,
|
|
445
|
-
this.state.protocolNullifier,
|
|
446
|
-
this.state.nextBlockGlobalVariables.blockNumber,
|
|
447
|
-
);
|
|
469
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
448
470
|
|
|
449
471
|
// We build a block holding just this transaction
|
|
450
472
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
@@ -484,22 +506,22 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
484
506
|
}
|
|
485
507
|
|
|
486
508
|
try {
|
|
487
|
-
const oracle = new UtilityExecutionOracle(
|
|
488
|
-
call.to,
|
|
489
|
-
[],
|
|
490
|
-
[],
|
|
491
|
-
anchorBlock!,
|
|
492
|
-
this.contractStore,
|
|
493
|
-
this.noteStore,
|
|
494
|
-
this.keyStore,
|
|
495
|
-
this.addressStore,
|
|
496
|
-
this.stateMachine.node,
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
499
|
-
this.
|
|
500
|
-
this.
|
|
501
|
-
this.
|
|
502
|
-
);
|
|
509
|
+
const oracle = new UtilityExecutionOracle({
|
|
510
|
+
contractAddress: call.to,
|
|
511
|
+
authWitnesses: [],
|
|
512
|
+
capsules: [],
|
|
513
|
+
anchorBlockHeader: anchorBlock!,
|
|
514
|
+
contractStore: this.contractStore,
|
|
515
|
+
noteStore: this.noteStore,
|
|
516
|
+
keyStore: this.keyStore,
|
|
517
|
+
addressStore: this.addressStore,
|
|
518
|
+
aztecNode: this.stateMachine.node,
|
|
519
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
520
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
521
|
+
capsuleStore: this.capsuleStore,
|
|
522
|
+
privateEventStore: this.privateEventStore,
|
|
523
|
+
jobId: this.currentJobId,
|
|
524
|
+
});
|
|
503
525
|
await new WASMSimulator()
|
|
504
526
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
505
527
|
.catch((err: Error) => {
|
|
@@ -4,13 +4,12 @@ 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
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { Body, L2Block
|
|
11
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
12
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
13
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
12
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
@@ -47,20 +46,18 @@ export async function insertTxEffectIntoWorldTrees(
|
|
|
47
46
|
export async function makeTXEBlockHeader(
|
|
48
47
|
worldTrees: MerkleTreeWriteOperations,
|
|
49
48
|
globalVariables: GlobalVariables,
|
|
50
|
-
): Promise<
|
|
49
|
+
): Promise<BlockHeader> {
|
|
51
50
|
const stateReference = await worldTrees.getStateReference();
|
|
52
51
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
53
52
|
|
|
54
|
-
return
|
|
55
|
-
new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
56
|
-
|
|
57
|
-
stateReference,
|
|
53
|
+
return BlockHeader.from({
|
|
54
|
+
lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
55
|
+
spongeBlobHash: Fr.ZERO,
|
|
56
|
+
state: stateReference,
|
|
58
57
|
globalVariables,
|
|
59
|
-
Fr.ZERO,
|
|
60
|
-
Fr.ZERO,
|
|
61
|
-
|
|
62
|
-
Fr.ZERO,
|
|
63
|
-
);
|
|
58
|
+
totalFees: Fr.ZERO,
|
|
59
|
+
totalManaUsed: Fr.ZERO,
|
|
60
|
+
});
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
/**
|
|
@@ -84,11 +81,17 @@ export async function makeTXEBlock(
|
|
|
84
81
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
85
82
|
|
|
86
83
|
// Update the archive tree with this block's header hash
|
|
87
|
-
await worldTrees.updateArchive(header
|
|
84
|
+
await worldTrees.updateArchive(header);
|
|
88
85
|
|
|
89
86
|
// Get the new archive state after updating
|
|
90
87
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
91
88
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
92
89
|
|
|
93
|
-
|
|
90
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint.
|
|
91
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
92
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
93
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
94
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
95
|
+
|
|
96
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
94
97
|
}
|
|
@@ -4,16 +4,12 @@ import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
|
4
4
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
5
5
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
|
-
export async function makeTxEffect(
|
|
8
|
-
noteCache: ExecutionNoteCache,
|
|
9
|
-
protocolNullifier: Fr,
|
|
10
|
-
txBlockNumber: BlockNumber,
|
|
11
|
-
): Promise<TxEffect> {
|
|
7
|
+
export async function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect> {
|
|
12
8
|
const txEffect = TxEffect.empty();
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
|
|
10
|
+
noteCache.finish();
|
|
16
11
|
|
|
12
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
17
13
|
txEffect.noteHashes = await Promise.all(
|
|
18
14
|
noteCache
|
|
19
15
|
.getAllNotes()
|
|
@@ -28,10 +24,6 @@ export async function makeTxEffect(
|
|
|
28
24
|
// Nullifiers are already siloed
|
|
29
25
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
30
26
|
|
|
31
|
-
if (usedProtocolNullifierForNonces) {
|
|
32
|
-
txEffect.nullifiers.unshift(protocolNullifier);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|
|
36
28
|
|
|
37
29
|
return txEffect;
|