@aztec/txe 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed
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 +5 -5
- 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 +2 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +86 -24
- package/dest/rpc_translator.d.ts +14 -8
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +58 -34
- package/dest/state_machine/archiver.d.ts +2 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +7 -6
- package/dest/state_machine/dummy_p2p_client.d.ts +9 -8
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +15 -12
- package/dest/state_machine/index.d.ts +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +30 -16
- package/dest/state_machine/mock_epoch_cache.d.ts +6 -2
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +6 -1
- 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 +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +69 -11
- package/dest/utils/block_creation.d.ts +5 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +7 -5
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +8 -10
- package/src/oracle/txe_oracle_top_level_context.ts +104 -72
- package/src/rpc_translator.ts +60 -28
- package/src/state_machine/archiver.ts +6 -8
- package/src/state_machine/dummy_p2p_client.ts +21 -15
- package/src/state_machine/index.ts +48 -19
- package/src/state_machine/mock_epoch_cache.ts +7 -1
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +74 -66
- package/src/utils/block_creation.ts +8 -6
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type
|
|
5
|
-
import {
|
|
6
|
-
import { L2BlockNew } from '@aztec/stdlib/block';
|
|
6
|
+
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
7
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
8
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
9
11
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
12
|
|
|
11
13
|
import { TXEArchiver } from './archiver.js';
|
|
@@ -23,13 +25,16 @@ export class TXEStateMachine {
|
|
|
23
25
|
public synchronizer: TXESynchronizer,
|
|
24
26
|
public archiver: TXEArchiver,
|
|
25
27
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
|
+
public contractSyncService: ContractSyncService,
|
|
26
29
|
) {}
|
|
27
30
|
|
|
28
|
-
public static async create(
|
|
29
|
-
|
|
31
|
+
public static async create(
|
|
32
|
+
archiver: TXEArchiver,
|
|
33
|
+
anchorBlockStore: AnchorBlockStore,
|
|
34
|
+
contractStore: ContractStore,
|
|
35
|
+
noteStore: NoteStore,
|
|
36
|
+
) {
|
|
30
37
|
const synchronizer = await TXESynchronizer.create();
|
|
31
|
-
const anchorBlockStore = new AnchorBlockStore(db);
|
|
32
|
-
|
|
33
38
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
34
39
|
|
|
35
40
|
const log = createLogger('txe_node');
|
|
@@ -55,18 +60,39 @@ export class TXEStateMachine {
|
|
|
55
60
|
log,
|
|
56
61
|
);
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
const contractSyncService = new ContractSyncService(
|
|
64
|
+
node,
|
|
65
|
+
contractStore,
|
|
66
|
+
noteStore,
|
|
67
|
+
createLogger('txe:contract_sync'),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
|
|
59
71
|
}
|
|
60
72
|
|
|
61
|
-
public async handleL2Block(block:
|
|
62
|
-
// Create a checkpoint from the block
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
public async handleL2Block(block: L2Block) {
|
|
74
|
+
// Create a checkpoint from the block manually.
|
|
75
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
76
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
77
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
|
|
78
|
+
const checkpoint = new Checkpoint(
|
|
79
|
+
block.archive,
|
|
80
|
+
CheckpointHeader.from({
|
|
81
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
82
|
+
inHash: Fr.ZERO,
|
|
83
|
+
blobsHash: Fr.ZERO,
|
|
84
|
+
blockHeadersHash: Fr.ZERO,
|
|
85
|
+
epochOutHash: Fr.ZERO,
|
|
86
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
87
|
+
timestamp: block.header.globalVariables.timestamp,
|
|
88
|
+
coinbase: block.header.globalVariables.coinbase,
|
|
89
|
+
feeRecipient: block.header.globalVariables.feeRecipient,
|
|
90
|
+
gasFees: block.header.globalVariables.gasFees,
|
|
91
|
+
totalManaUsed: block.header.totalManaUsed,
|
|
92
|
+
}),
|
|
93
|
+
[block],
|
|
94
|
+
checkpointNumber,
|
|
95
|
+
);
|
|
70
96
|
|
|
71
97
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
72
98
|
checkpoint,
|
|
@@ -77,10 +103,13 @@ export class TXEStateMachine {
|
|
|
77
103
|
),
|
|
78
104
|
[],
|
|
79
105
|
);
|
|
106
|
+
// Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
|
|
107
|
+
this.contractSyncService.wipe();
|
|
108
|
+
|
|
80
109
|
await Promise.all([
|
|
81
|
-
this.synchronizer.handleL2Block(block),
|
|
110
|
+
this.synchronizer.handleL2Block(block),
|
|
82
111
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
83
|
-
this.anchorBlockStore.setHeader(block.header),
|
|
112
|
+
this.anchorBlockStore.setHeader(block.header),
|
|
84
113
|
]);
|
|
85
114
|
}
|
|
86
115
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
2
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
@@ -16,11 +17,12 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
getEpochAndSlotNow(): EpochAndSlot {
|
|
20
|
+
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
20
21
|
return {
|
|
21
22
|
epoch: EpochNumber.ZERO,
|
|
22
23
|
slot: SlotNumber(0),
|
|
23
24
|
ts: 0n,
|
|
25
|
+
nowMs: 0n,
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -63,4 +65,8 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
63
65
|
filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
|
|
64
66
|
return Promise.resolve([]);
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
getL1Constants(): L1RollupConstants {
|
|
70
|
+
return EmptyL1RollupConstants;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
@@ -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 {
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -23,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
23
23
|
return new this(nativeWorldStateService);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
public async handleL2Block(block:
|
|
26
|
+
public async handleL2Block(block: L2Block) {
|
|
27
27
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
28
28
|
block,
|
|
29
29
|
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
|
package/src/txe_session.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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,
|
|
10
11
|
JobCoordinator,
|
|
11
12
|
NoteService,
|
|
@@ -49,6 +50,7 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
|
|
|
49
50
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
50
51
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
51
52
|
import { RPCTranslator } from './rpc_translator.js';
|
|
53
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
52
54
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
53
55
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
54
56
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
@@ -152,7 +154,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
152
154
|
const addressStore = new AddressStore(store);
|
|
153
155
|
const privateEventStore = new PrivateEventStore(store);
|
|
154
156
|
const contractStore = new TXEContractStore(store);
|
|
155
|
-
const noteStore =
|
|
157
|
+
const noteStore = new NoteStore(store);
|
|
156
158
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
157
159
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
158
160
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -162,7 +164,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
162
164
|
|
|
163
165
|
// Create job coordinator and register staged stores
|
|
164
166
|
const jobCoordinator = new JobCoordinator(store);
|
|
165
|
-
jobCoordinator.registerStores([
|
|
167
|
+
jobCoordinator.registerStores([
|
|
168
|
+
capsuleStore,
|
|
169
|
+
senderTaggingStore,
|
|
170
|
+
recipientTaggingStore,
|
|
171
|
+
privateEventStore,
|
|
172
|
+
noteStore,
|
|
173
|
+
]);
|
|
166
174
|
|
|
167
175
|
// Register protocol contracts.
|
|
168
176
|
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
@@ -170,7 +178,9 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
170
178
|
await contractStore.addContractInstance(instance);
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
const
|
|
181
|
+
const archiver = new TXEArchiver(store);
|
|
182
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
183
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
174
184
|
|
|
175
185
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
176
186
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
@@ -306,16 +316,14 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
306
316
|
): Promise<PrivateContextInputs> {
|
|
307
317
|
this.exitTopLevelState();
|
|
308
318
|
|
|
309
|
-
await new NoteService(
|
|
310
|
-
this.noteStore,
|
|
311
|
-
this.stateMachine.node,
|
|
312
|
-
this.stateMachine.anchorBlockStore,
|
|
313
|
-
).syncNoteNullifiers(contractAddress);
|
|
314
|
-
|
|
315
319
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
316
320
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
317
321
|
// a single transaction with the effects of what was done in the test.
|
|
318
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
|
+
);
|
|
319
327
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
320
328
|
|
|
321
329
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
@@ -331,30 +339,30 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
331
339
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
332
340
|
|
|
333
341
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
334
|
-
this.oracleHandler = new PrivateExecutionOracle(
|
|
335
|
-
Fr.ZERO,
|
|
336
|
-
new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
337
|
-
new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
338
|
-
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!,
|
|
339
347
|
utilityExecutor,
|
|
340
|
-
[],
|
|
341
|
-
[],
|
|
342
|
-
new HashedValuesCache(),
|
|
348
|
+
authWitnesses: [],
|
|
349
|
+
capsules: [],
|
|
350
|
+
executionCache: new HashedValuesCache(),
|
|
343
351
|
noteCache,
|
|
344
352
|
taggingIndexCache,
|
|
345
|
-
this.contractStore,
|
|
346
|
-
this.noteStore,
|
|
347
|
-
this.keyStore,
|
|
348
|
-
this.addressStore,
|
|
349
|
-
this.stateMachine.node,
|
|
350
|
-
this.
|
|
351
|
-
this.
|
|
352
|
-
this.
|
|
353
|
-
this.
|
|
354
|
-
this.
|
|
355
|
-
this.
|
|
356
|
-
this.currentJobId,
|
|
357
|
-
);
|
|
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
|
+
});
|
|
358
366
|
|
|
359
367
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
360
368
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
@@ -394,6 +402,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
394
402
|
async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
|
|
395
403
|
this.exitTopLevelState();
|
|
396
404
|
|
|
405
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
406
|
+
|
|
397
407
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
398
408
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
399
409
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
@@ -402,28 +412,26 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
402
412
|
await new NoteService(
|
|
403
413
|
this.noteStore,
|
|
404
414
|
this.stateMachine.node,
|
|
405
|
-
|
|
415
|
+
anchorBlockHeader,
|
|
416
|
+
this.currentJobId,
|
|
406
417
|
).syncNoteNullifiers(contractAddress);
|
|
407
418
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
419
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
411
420
|
contractAddress,
|
|
412
|
-
[],
|
|
413
|
-
[],
|
|
421
|
+
authWitnesses: [],
|
|
422
|
+
capsules: [],
|
|
414
423
|
anchorBlockHeader,
|
|
415
|
-
this.contractStore,
|
|
416
|
-
this.noteStore,
|
|
417
|
-
this.keyStore,
|
|
418
|
-
this.addressStore,
|
|
419
|
-
this.stateMachine.node,
|
|
420
|
-
this.
|
|
421
|
-
this.
|
|
422
|
-
this.
|
|
423
|
-
this.
|
|
424
|
-
this.
|
|
425
|
-
|
|
426
|
-
);
|
|
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
|
+
});
|
|
427
435
|
|
|
428
436
|
this.state = { name: 'UTILITY' };
|
|
429
437
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
@@ -491,30 +499,30 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
491
499
|
}
|
|
492
500
|
|
|
493
501
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
494
|
-
return async (call: FunctionCall) => {
|
|
502
|
+
return async (call: FunctionCall, scopes: undefined | AztecAddress[]) => {
|
|
495
503
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
496
504
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
497
505
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
498
506
|
}
|
|
499
507
|
|
|
500
508
|
try {
|
|
501
|
-
const oracle = new UtilityExecutionOracle(
|
|
502
|
-
call.to,
|
|
503
|
-
[],
|
|
504
|
-
[],
|
|
505
|
-
anchorBlock!,
|
|
506
|
-
this.contractStore,
|
|
507
|
-
this.noteStore,
|
|
508
|
-
this.keyStore,
|
|
509
|
-
this.addressStore,
|
|
510
|
-
this.stateMachine.node,
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
this.
|
|
514
|
-
this.
|
|
515
|
-
this.
|
|
516
|
-
|
|
517
|
-
);
|
|
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
|
+
});
|
|
518
526
|
await new WASMSimulator()
|
|
519
527
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
520
528
|
.catch((err: Error) => {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
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,
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
12
12
|
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
@@ -61,7 +61,7 @@ export async function makeTXEBlockHeader(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Creates an
|
|
64
|
+
* Creates an L2Block with proper archive chaining.
|
|
65
65
|
* This function:
|
|
66
66
|
* 1. Gets the current archive state as lastArchive for the header
|
|
67
67
|
* 2. Creates the block header
|
|
@@ -71,13 +71,13 @@ export async function makeTXEBlockHeader(
|
|
|
71
71
|
* @param worldTrees - The world trees to read/write from
|
|
72
72
|
* @param globalVariables - Global variables for the block
|
|
73
73
|
* @param txEffects - Transaction effects to include in the block
|
|
74
|
-
* @returns The created
|
|
74
|
+
* @returns The created L2Block with proper archive chaining
|
|
75
75
|
*/
|
|
76
76
|
export async function makeTXEBlock(
|
|
77
77
|
worldTrees: MerkleTreeWriteOperations,
|
|
78
78
|
globalVariables: GlobalVariables,
|
|
79
79
|
txEffects: TxEffect[],
|
|
80
|
-
): Promise<
|
|
80
|
+
): Promise<L2Block> {
|
|
81
81
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
82
82
|
|
|
83
83
|
// Update the archive tree with this block's header hash
|
|
@@ -87,9 +87,11 @@ export async function makeTXEBlock(
|
|
|
87
87
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
88
88
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
89
89
|
|
|
90
|
-
//
|
|
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.
|
|
91
93
|
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
92
94
|
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
93
95
|
|
|
94
|
-
return new
|
|
96
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
95
97
|
}
|