@aztec/txe 0.0.1-commit.6d3c34e → 0.0.1-commit.7cf39cb55
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/constants.d.ts +1 -2
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +0 -1
- 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 +102 -35
- 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 -69
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +36 -178
- package/dest/state_machine/dummy_p2p_client.d.ts +11 -8
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +21 -12
- 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 +8 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +11 -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 +90 -17
- 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 -4
- 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/constants.ts +0 -1
- 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 +123 -82
- package/src/rpc_translator.ts +78 -52
- package/src/state_machine/archiver.ts +37 -234
- package/src/state_machine/dummy_p2p_client.ts +29 -15
- package/src/state_machine/index.ts +48 -11
- package/src/state_machine/mock_epoch_cache.ts +11 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +93 -73
- 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,
|
|
@@ -43,11 +45,12 @@ import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
|
43
45
|
|
|
44
46
|
import { z } from 'zod';
|
|
45
47
|
|
|
46
|
-
import { DEFAULT_ADDRESS
|
|
48
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
47
49
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
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,37 +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
|
-
|
|
341
|
-
);
|
|
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
|
+
});
|
|
342
366
|
|
|
343
367
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
344
368
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
345
369
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
346
370
|
// will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
|
|
347
371
|
// execution finishes.
|
|
348
|
-
this.state = { name: 'PRIVATE', nextBlockGlobalVariables,
|
|
372
|
+
this.state = { name: 'PRIVATE', nextBlockGlobalVariables, noteCache, taggingIndexCache };
|
|
349
373
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
350
374
|
|
|
351
375
|
return (this.oracleHandler as PrivateExecutionOracle).getPrivateContextInputs();
|
|
@@ -378,6 +402,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
378
402
|
async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
|
|
379
403
|
this.exitTopLevelState();
|
|
380
404
|
|
|
405
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
406
|
+
|
|
381
407
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
382
408
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
383
409
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
@@ -386,28 +412,26 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
386
412
|
await new NoteService(
|
|
387
413
|
this.noteStore,
|
|
388
414
|
this.stateMachine.node,
|
|
389
|
-
|
|
415
|
+
anchorBlockHeader,
|
|
416
|
+
this.currentJobId,
|
|
390
417
|
).syncNoteNullifiers(contractAddress);
|
|
391
418
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
419
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
395
420
|
contractAddress,
|
|
396
|
-
[],
|
|
397
|
-
[],
|
|
421
|
+
authWitnesses: [],
|
|
422
|
+
capsules: [],
|
|
398
423
|
anchorBlockHeader,
|
|
399
|
-
this.contractStore,
|
|
400
|
-
this.noteStore,
|
|
401
|
-
this.keyStore,
|
|
402
|
-
this.addressStore,
|
|
403
|
-
this.stateMachine.node,
|
|
404
|
-
this.
|
|
405
|
-
this.
|
|
406
|
-
this.
|
|
407
|
-
this.
|
|
408
|
-
this.
|
|
409
|
-
|
|
410
|
-
);
|
|
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
|
+
});
|
|
411
435
|
|
|
412
436
|
this.state = { name: 'UTILITY' };
|
|
413
437
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
@@ -442,11 +466,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
442
466
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
443
467
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
444
468
|
|
|
445
|
-
const txEffect = await makeTxEffect(
|
|
446
|
-
this.state.noteCache,
|
|
447
|
-
this.state.protocolNullifier,
|
|
448
|
-
this.state.nextBlockGlobalVariables.blockNumber,
|
|
449
|
-
);
|
|
469
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
450
470
|
|
|
451
471
|
// We build a block holding just this transaction
|
|
452
472
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
@@ -479,30 +499,30 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
479
499
|
}
|
|
480
500
|
|
|
481
501
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
482
|
-
return async (call: FunctionCall) => {
|
|
502
|
+
return async (call: FunctionCall, scopes: undefined | AztecAddress[]) => {
|
|
483
503
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
484
504
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
485
505
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
486
506
|
}
|
|
487
507
|
|
|
488
508
|
try {
|
|
489
|
-
const oracle = new UtilityExecutionOracle(
|
|
490
|
-
call.to,
|
|
491
|
-
[],
|
|
492
|
-
[],
|
|
493
|
-
anchorBlock!,
|
|
494
|
-
this.contractStore,
|
|
495
|
-
this.noteStore,
|
|
496
|
-
this.keyStore,
|
|
497
|
-
this.addressStore,
|
|
498
|
-
this.stateMachine.node,
|
|
499
|
-
this.
|
|
500
|
-
this.
|
|
501
|
-
this.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
504
|
-
|
|
505
|
-
);
|
|
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
|
+
scopes,
|
|
525
|
+
});
|
|
506
526
|
await new WASMSimulator()
|
|
507
527
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
508
528
|
.catch((err: Error) => {
|
|
@@ -4,12 +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
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
12
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
12
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
@@ -46,21 +46,18 @@ export async function insertTxEffectIntoWorldTrees(
|
|
|
46
46
|
export async function makeTXEBlockHeader(
|
|
47
47
|
worldTrees: MerkleTreeWriteOperations,
|
|
48
48
|
globalVariables: GlobalVariables,
|
|
49
|
-
): Promise<
|
|
49
|
+
): Promise<BlockHeader> {
|
|
50
50
|
const stateReference = await worldTrees.getStateReference();
|
|
51
51
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
52
52
|
|
|
53
|
-
return
|
|
54
|
-
new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
55
|
-
Fr.ZERO,
|
|
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;
|