@aztec/txe 0.0.1-commit.f146247c → 0.0.1-commit.f1b29a41e

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.
Files changed (62) hide show
  1. package/dest/index.d.ts +1 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +88 -54
  4. package/dest/oracle/interfaces.d.ts +29 -28
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +12 -12
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -23
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +126 -51
  12. package/dest/rpc_translator.d.ts +88 -83
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +303 -158
  15. package/dest/state_machine/archiver.d.ts +3 -3
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +9 -8
  18. package/dest/state_machine/dummy_p2p_client.d.ts +18 -13
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +33 -18
  21. package/dest/state_machine/global_variable_builder.d.ts +3 -3
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +1 -1
  24. package/dest/state_machine/index.d.ts +8 -5
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +19 -10
  27. package/dest/state_machine/mock_epoch_cache.d.ts +19 -3
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +36 -2
  30. package/dest/state_machine/synchronizer.d.ts +5 -5
  31. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  32. package/dest/state_machine/synchronizer.js +3 -3
  33. package/dest/txe_session.d.ts +10 -6
  34. package/dest/txe_session.d.ts.map +1 -1
  35. package/dest/txe_session.js +93 -25
  36. package/dest/util/encoding.d.ts +69 -1
  37. package/dest/util/encoding.d.ts.map +1 -1
  38. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  39. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  40. package/dest/util/txe_public_contract_data_source.js +6 -25
  41. package/dest/utils/block_creation.d.ts +1 -1
  42. package/dest/utils/block_creation.d.ts.map +1 -1
  43. package/dest/utils/block_creation.js +3 -1
  44. package/package.json +15 -15
  45. package/src/index.ts +89 -52
  46. package/src/oracle/interfaces.ts +32 -31
  47. package/src/oracle/txe_oracle_public_context.ts +12 -12
  48. package/src/oracle/txe_oracle_top_level_context.ts +143 -97
  49. package/src/rpc_translator.ts +344 -175
  50. package/src/state_machine/archiver.ts +8 -5
  51. package/src/state_machine/dummy_p2p_client.ts +46 -24
  52. package/src/state_machine/global_variable_builder.ts +7 -1
  53. package/src/state_machine/index.ts +33 -9
  54. package/src/state_machine/mock_epoch_cache.ts +47 -3
  55. package/src/state_machine/synchronizer.ts +4 -4
  56. package/src/txe_session.ts +106 -72
  57. package/src/util/txe_public_contract_data_source.ts +10 -38
  58. package/src/utils/block_creation.ts +3 -1
  59. package/dest/util/txe_contract_store.d.ts +0 -12
  60. package/dest/util/txe_contract_store.d.ts.map +0 -1
  61. package/dest/util/txe_contract_store.js +0 -22
  62. package/src/util/txe_contract_store.ts +0 -36
@@ -3,10 +3,14 @@ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
4
  import { KeyStore } from '@aztec/key-store';
5
5
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
6
- import type { ProtocolContract } from '@aztec/protocol-contracts';
6
+ import type { AccessScopes } from '@aztec/pxe/client/lazy';
7
7
  import {
8
8
  AddressStore,
9
+ AnchorBlockStore,
10
+ CapsuleService,
9
11
  CapsuleStore,
12
+ ContractStore,
13
+ ContractSyncService,
10
14
  JobCoordinator,
11
15
  NoteService,
12
16
  NoteStore,
@@ -49,10 +53,10 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
49
53
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
50
54
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
51
55
  import { RPCTranslator } from './rpc_translator.js';
56
+ import { TXEArchiver } from './state_machine/archiver.js';
52
57
  import { TXEStateMachine } from './state_machine/index.js';
53
58
  import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
54
59
  import { TXEAccountStore } from './util/txe_account_store.js';
55
- import { TXEContractStore } from './util/txe_contract_store.js';
56
60
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
57
61
  import { makeTxEffect } from './utils/tx_effect_creation.js';
58
62
 
@@ -111,6 +115,10 @@ export interface TXESessionStateHandler {
111
115
  enterPublicState(contractAddress?: AztecAddress): Promise<void>;
112
116
  enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
113
117
  enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
118
+
119
+ // TODO(F-335): Exposing the job info is abstraction breakage - drop the following 2 functions.
120
+ cycleJob(): Promise<string>;
121
+ getCurrentJob(): string;
114
122
  }
115
123
 
116
124
  /**
@@ -129,7 +137,7 @@ export class TXESession implements TXESessionStateHandler {
129
137
  | IPrivateExecutionOracle
130
138
  | IAvmExecutionOracle
131
139
  | ITxeExecutionOracle,
132
- private contractStore: TXEContractStore,
140
+ private contractStore: ContractStore,
133
141
  private noteStore: NoteStore,
134
142
  private keyStore: KeyStore,
135
143
  private addressStore: AddressStore,
@@ -144,14 +152,14 @@ export class TXESession implements TXESessionStateHandler {
144
152
  private chainId: Fr,
145
153
  private version: Fr,
146
154
  private nextBlockTimestamp: bigint,
155
+ private contractSyncService: ContractSyncService,
147
156
  ) {}
148
157
 
149
- static async init(protocolContracts: ProtocolContract[]) {
158
+ static async init(contractStore: ContractStore) {
150
159
  const store = await openTmpStore('txe-session');
151
160
 
152
161
  const addressStore = new AddressStore(store);
153
162
  const privateEventStore = new PrivateEventStore(store);
154
- const contractStore = new TXEContractStore(store);
155
163
  const noteStore = new NoteStore(store);
156
164
  const senderTaggingStore = new SenderTaggingStore(store);
157
165
  const recipientTaggingStore = new RecipientTaggingStore(store);
@@ -170,13 +178,9 @@ export class TXESession implements TXESessionStateHandler {
170
178
  noteStore,
171
179
  ]);
172
180
 
173
- // Register protocol contracts.
174
- for (const { contractClass, instance, artifact } of protocolContracts) {
175
- await contractStore.addContractArtifact(contractClass.id, artifact);
176
- await contractStore.addContractInstance(instance);
177
- }
178
-
179
- const stateMachine = await TXEStateMachine.create(store);
181
+ const archiver = new TXEArchiver(store);
182
+ const anchorBlockStore = new AnchorBlockStore(store);
183
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore, keyStore);
180
184
 
181
185
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
182
186
  const version = new Fr(await stateMachine.node.getVersion());
@@ -184,6 +188,15 @@ export class TXESession implements TXESessionStateHandler {
184
188
 
185
189
  const initialJobId = jobCoordinator.beginJob();
186
190
 
191
+ const logger = createLogger('txe:session');
192
+ const contractSyncService = new ContractSyncService(
193
+ stateMachine.node,
194
+ contractStore,
195
+ noteStore,
196
+ () => keyStore.getAccounts(),
197
+ logger,
198
+ );
199
+
187
200
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
188
201
  stateMachine,
189
202
  contractStore,
@@ -196,16 +209,16 @@ export class TXESession implements TXESessionStateHandler {
196
209
  senderAddressBookStore,
197
210
  capsuleStore,
198
211
  privateEventStore,
199
- initialJobId,
200
212
  nextBlockTimestamp,
201
213
  version,
202
214
  chainId,
203
215
  new Map(),
216
+ contractSyncService,
204
217
  );
205
- await topLevelOracleHandler.txeAdvanceBlocksBy(1);
218
+ await topLevelOracleHandler.advanceBlocksBy(1);
206
219
 
207
220
  return new TXESession(
208
- createLogger('txe:session'),
221
+ logger,
209
222
  stateMachine,
210
223
  topLevelOracleHandler,
211
224
  contractStore,
@@ -223,6 +236,7 @@ export class TXESession implements TXESessionStateHandler {
223
236
  version,
224
237
  chainId,
225
238
  nextBlockTimestamp,
239
+ contractSyncService,
226
240
  );
227
241
  }
228
242
 
@@ -257,6 +271,17 @@ export class TXESession implements TXESessionStateHandler {
257
271
  }
258
272
  }
259
273
 
274
+ getCurrentJob(): string {
275
+ return this.currentJobId;
276
+ }
277
+
278
+ /** Commits the current job and begins a new one. Returns the new job ID. */
279
+ async cycleJob(): Promise<string> {
280
+ await this.jobCoordinator.commitJob(this.currentJobId);
281
+ this.currentJobId = this.jobCoordinator.beginJob();
282
+ return this.currentJobId;
283
+ }
284
+
260
285
  async enterTopLevelState() {
261
286
  switch (this.state.name) {
262
287
  case 'PRIVATE': {
@@ -280,8 +305,7 @@ export class TXESession implements TXESessionStateHandler {
280
305
  }
281
306
 
282
307
  // Commit all staged stores from the job that was just completed, then begin a new job
283
- await this.jobCoordinator.commitJob(this.currentJobId);
284
- this.currentJobId = this.jobCoordinator.beginJob();
308
+ await this.cycleJob();
285
309
 
286
310
  this.oracleHandler = new TXEOracleTopLevelContext(
287
311
  this.stateMachine,
@@ -295,11 +319,11 @@ export class TXESession implements TXESessionStateHandler {
295
319
  this.senderAddressBookStore,
296
320
  this.capsuleStore,
297
321
  this.privateEventStore,
298
- this.currentJobId,
299
322
  this.nextBlockTimestamp,
300
323
  this.version,
301
324
  this.chainId,
302
325
  this.authwits,
326
+ this.contractSyncService,
303
327
  );
304
328
 
305
329
  this.state = { name: 'TOP_LEVEL' };
@@ -319,6 +343,7 @@ export class TXESession implements TXESessionStateHandler {
319
343
 
320
344
  await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
321
345
  contractAddress,
346
+ 'ALL_SCOPES',
322
347
  );
323
348
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
324
349
 
@@ -335,29 +360,32 @@ export class TXESession implements TXESessionStateHandler {
335
360
  const taggingIndexCache = new ExecutionTaggingIndexCache();
336
361
 
337
362
  const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
338
- this.oracleHandler = new PrivateExecutionOracle(
339
- Fr.ZERO,
340
- new TxContext(this.chainId, this.version, GasSettings.empty()),
341
- new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
342
- anchorBlock!,
363
+ this.oracleHandler = new PrivateExecutionOracle({
364
+ argsHash: Fr.ZERO,
365
+ txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
366
+ callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
367
+ anchorBlockHeader: anchorBlock!,
343
368
  utilityExecutor,
344
- [],
345
- [],
346
- new HashedValuesCache(),
369
+ authWitnesses: [],
370
+ capsules: [],
371
+ executionCache: new HashedValuesCache(),
347
372
  noteCache,
348
373
  taggingIndexCache,
349
- this.contractStore,
350
- this.noteStore,
351
- this.keyStore,
352
- this.addressStore,
353
- this.stateMachine.node,
354
- this.senderTaggingStore,
355
- this.recipientTaggingStore,
356
- this.senderAddressBookStore,
357
- this.capsuleStore,
358
- this.privateEventStore,
359
- this.currentJobId,
360
- );
374
+ contractStore: this.contractStore,
375
+ noteStore: this.noteStore,
376
+ keyStore: this.keyStore,
377
+ addressStore: this.addressStore,
378
+ aztecNode: this.stateMachine.node,
379
+ senderTaggingStore: this.senderTaggingStore,
380
+ recipientTaggingStore: this.recipientTaggingStore,
381
+ senderAddressBookStore: this.senderAddressBookStore,
382
+ capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
383
+ privateEventStore: this.privateEventStore,
384
+ contractSyncService: this.stateMachine.contractSyncService,
385
+ jobId: this.currentJobId,
386
+ scopes: 'ALL_SCOPES',
387
+ messageContextService: this.stateMachine.messageContextService,
388
+ });
361
389
 
362
390
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
363
391
  // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
@@ -409,24 +437,27 @@ export class TXESession implements TXESessionStateHandler {
409
437
  this.stateMachine.node,
410
438
  anchorBlockHeader,
411
439
  this.currentJobId,
412
- ).syncNoteNullifiers(contractAddress);
440
+ ).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
413
441
 
414
- this.oracleHandler = new UtilityExecutionOracle(
442
+ this.oracleHandler = new UtilityExecutionOracle({
415
443
  contractAddress,
416
- [],
417
- [],
444
+ authWitnesses: [],
445
+ capsules: [],
418
446
  anchorBlockHeader,
419
- this.contractStore,
420
- this.noteStore,
421
- this.keyStore,
422
- this.addressStore,
423
- this.stateMachine.node,
424
- this.recipientTaggingStore,
425
- this.senderAddressBookStore,
426
- this.capsuleStore,
427
- this.privateEventStore,
428
- this.currentJobId,
429
- );
447
+ contractStore: this.contractStore,
448
+ noteStore: this.noteStore,
449
+ keyStore: this.keyStore,
450
+ addressStore: this.addressStore,
451
+ aztecNode: this.stateMachine.node,
452
+ recipientTaggingStore: this.recipientTaggingStore,
453
+ senderAddressBookStore: this.senderAddressBookStore,
454
+ capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
455
+ privateEventStore: this.privateEventStore,
456
+ messageContextService: this.stateMachine.messageContextService,
457
+ contractSyncService: this.contractSyncService,
458
+ jobId: this.currentJobId,
459
+ scopes: 'ALL_SCOPES',
460
+ });
430
461
 
431
462
  this.state = { name: 'UTILITY' };
432
463
  this.logger.debug(`Entered state ${this.state.name}`);
@@ -439,8 +470,8 @@ export class TXESession implements TXESessionStateHandler {
439
470
 
440
471
  // Note that while all public and private contexts do is build a single block that we then process when exiting
441
472
  // those, the top level context performs a large number of actions not captured in the following 'close' call. Among
442
- // others, it will create empty blocks (via `txeAdvanceBlocksBy` and `deploy`), create blocks with transactions via
443
- // `txePrivateCallNewFlow` and `txePublicCallNewFlow`, add accounts to PXE via `txeAddAccount`, etc. This is a
473
+ // others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
474
+ // `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
444
475
  // slight inconsistency in the working model of this class, but is not too bad.
445
476
  // TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
446
477
  // level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
@@ -494,29 +525,32 @@ export class TXESession implements TXESessionStateHandler {
494
525
  }
495
526
 
496
527
  private utilityExecutorForContractSync(anchorBlock: any) {
497
- return async (call: FunctionCall) => {
528
+ return async (call: FunctionCall, scopes: AccessScopes) => {
498
529
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
499
530
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
500
531
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
501
532
  }
502
533
 
503
534
  try {
504
- const oracle = new UtilityExecutionOracle(
505
- call.to,
506
- [],
507
- [],
508
- anchorBlock!,
509
- this.contractStore,
510
- this.noteStore,
511
- this.keyStore,
512
- this.addressStore,
513
- this.stateMachine.node,
514
- this.recipientTaggingStore,
515
- this.senderAddressBookStore,
516
- this.capsuleStore,
517
- this.privateEventStore,
518
- this.currentJobId,
519
- );
535
+ const oracle = new UtilityExecutionOracle({
536
+ contractAddress: call.to,
537
+ authWitnesses: [],
538
+ capsules: [],
539
+ anchorBlockHeader: anchorBlock!,
540
+ contractStore: this.contractStore,
541
+ noteStore: this.noteStore,
542
+ keyStore: this.keyStore,
543
+ addressStore: this.addressStore,
544
+ aztecNode: this.stateMachine.node,
545
+ recipientTaggingStore: this.recipientTaggingStore,
546
+ senderAddressBookStore: this.senderAddressBookStore,
547
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
548
+ privateEventStore: this.privateEventStore,
549
+ messageContextService: this.stateMachine.messageContextService,
550
+ contractSyncService: this.contractSyncService,
551
+ jobId: this.currentJobId,
552
+ scopes,
553
+ });
520
554
  await new WASMSimulator()
521
555
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
522
556
  .catch((err: Error) => {
@@ -1,19 +1,11 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ContractStore } from '@aztec/pxe/server';
4
- import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
4
+ import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import {
7
- type ContractClassPublic,
8
- type ContractDataSource,
9
- type ContractInstanceWithAddress,
10
- computePrivateFunctionsRoot,
11
- computePublicBytecodeCommitment,
12
- getContractClassPrivateFunctionFromArtifact,
13
- } from '@aztec/stdlib/contract';
6
+ import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
14
7
 
15
8
  export class TXEPublicContractDataSource implements ContractDataSource {
16
- #privateFunctionsRoot: Map<string, Buffer> = new Map();
17
9
  constructor(
18
10
  private blockNumber: BlockNumber,
19
11
  private contractStore: ContractStore,
@@ -24,42 +16,22 @@ export class TXEPublicContractDataSource implements ContractDataSource {
24
16
  }
25
17
 
26
18
  async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
27
- const contractClass = await this.contractStore.getContractClass(id);
19
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
28
20
  if (!contractClass) {
29
21
  return;
30
22
  }
31
- const artifact = await this.contractStore.getContractArtifact(id);
32
- if (!artifact) {
33
- return;
34
- }
35
-
36
- let privateFunctionsRoot;
37
- if (!this.#privateFunctionsRoot.has(id.toString())) {
38
- const privateFunctions = await Promise.all(
39
- artifact.functions
40
- .filter(fn => fn.functionType === FunctionType.PRIVATE)
41
- .map(fn => getContractClassPrivateFunctionFromArtifact(fn)),
42
- );
43
- privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
44
- this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
45
- } else {
46
- privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString())!);
47
- }
48
-
49
23
  return {
50
- id,
51
- artifactHash: contractClass!.artifactHash,
52
- packedBytecode: contractClass!.packedBytecode,
53
- privateFunctionsRoot,
54
- version: contractClass!.version,
55
- privateFunctions: [],
56
- utilityFunctions: [],
24
+ id: contractClass.id,
25
+ artifactHash: contractClass.artifactHash,
26
+ packedBytecode: contractClass.packedBytecode,
27
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
28
+ version: contractClass.version,
57
29
  };
58
30
  }
59
31
 
60
32
  async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
61
- const contractClass = await this.contractStore.getContractClass(id);
62
- return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
33
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
34
+ return contractClass?.publicBytecodeCommitment;
63
35
  }
64
36
 
65
37
  async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
@@ -87,7 +87,9 @@ 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
- // L2Block requires checkpointNumber and indexWithinCheckpoint
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
 
@@ -1,12 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
- import { Fr } from '@aztec/aztec.js/fields';
3
- import { ContractStore } from '@aztec/pxe/server';
4
- export type ContractArtifactWithHash = ContractArtifact & {
5
- artifactHash: Fr;
6
- };
7
- export declare class TXEContractStore extends ContractStore {
8
- #private;
9
- addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
10
- getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
11
- }
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbC90eGVfY29udHJhY3Rfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUMsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWxELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLGdCQUFpQixTQUFRLGFBQWE7O0lBRzNCLG1CQUFtQixDQUN2QyxFQUFFLEVBQUUsRUFBRSxFQUNOLFFBQVEsRUFBRSxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUtmO0lBRXFCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsRUFBRSxHQUNsQixPQUFPLENBQUMsZ0JBQWdCLEdBQUcsd0JBQXdCLEdBQUcsU0FBUyxDQUFDLENBUWxFO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"txe_contract_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,gBAAiB,SAAQ,aAAa;;IAG3B,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC,CAKf;IAEqB,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAQlE;CACF"}
@@ -1,22 +0,0 @@
1
- import { Fr } from '@aztec/aztec.js/fields';
2
- import { ContractStore } from '@aztec/pxe/server';
3
- /*
4
- * A contract store that stores contract artifacts with their hashes. Since
5
- * TXE typically deploys the same contract again and again for multiple tests, caching
6
- * the *very* expensive artifact hash computation improves testing speed significantly.
7
- */ export class TXEContractStore extends ContractStore {
8
- #artifactHashes = new Map();
9
- async addContractArtifact(id, artifact) {
10
- if ('artifactHash' in artifact) {
11
- this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
12
- }
13
- await super.addContractArtifact(id, artifact);
14
- }
15
- async getContractArtifact(contractClassId) {
16
- const artifact = await super.getContractArtifact(contractClassId);
17
- if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
18
- artifact.artifactHash = Fr.fromBuffer(this.#artifactHashes.get(contractClassId.toString()));
19
- }
20
- return artifact;
21
- }
22
- }
@@ -1,36 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
- import { Fr } from '@aztec/aztec.js/fields';
3
- import { ContractStore } from '@aztec/pxe/server';
4
-
5
- export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
6
-
7
- /*
8
- * A contract store that stores contract artifacts with their hashes. Since
9
- * TXE typically deploys the same contract again and again for multiple tests, caching
10
- * the *very* expensive artifact hash computation improves testing speed significantly.
11
- */
12
- export class TXEContractStore extends ContractStore {
13
- #artifactHashes: Map<string, Buffer> = new Map();
14
-
15
- public override async addContractArtifact(
16
- id: Fr,
17
- artifact: ContractArtifact | ContractArtifactWithHash,
18
- ): Promise<void> {
19
- if ('artifactHash' in artifact) {
20
- this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
21
- }
22
- await super.addContractArtifact(id, artifact);
23
- }
24
-
25
- public override async getContractArtifact(
26
- contractClassId: Fr,
27
- ): Promise<ContractArtifact | ContractArtifactWithHash | undefined> {
28
- const artifact = await super.getContractArtifact(contractClassId);
29
- if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
30
- (artifact as ContractArtifactWithHash).artifactHash = Fr.fromBuffer(
31
- this.#artifactHashes.get(contractClassId.toString())!,
32
- );
33
- }
34
- return artifact;
35
- }
36
- }