@aztec/txe 0.0.1-commit.c7c42ec → 0.0.1-commit.c949de6bc

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 (68) hide show
  1. package/dest/constants.d.ts +3 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +2 -0
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +82 -50
  7. package/dest/oracle/interfaces.d.ts +6 -5
  8. package/dest/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +6 -6
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +8 -7
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  14. package/dest/oracle/txe_oracle_top_level_context.js +123 -38
  15. package/dest/rpc_translator.d.ts +21 -15
  16. package/dest/rpc_translator.d.ts.map +1 -1
  17. package/dest/rpc_translator.js +92 -55
  18. package/dest/state_machine/archiver.d.ts +20 -67
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +59 -178
  21. package/dest/state_machine/dummy_p2p_client.d.ts +20 -15
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +39 -24
  24. package/dest/state_machine/global_variable_builder.d.ts +2 -2
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +1 -1
  27. package/dest/state_machine/index.d.ts +5 -5
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +35 -12
  30. package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
  31. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  32. package/dest/state_machine/mock_epoch_cache.js +14 -7
  33. package/dest/state_machine/synchronizer.d.ts +3 -3
  34. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  35. package/dest/txe_session.d.ts +12 -7
  36. package/dest/txe_session.d.ts.map +1 -1
  37. package/dest/txe_session.js +122 -28
  38. package/dest/util/encoding.d.ts +17 -17
  39. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  40. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  41. package/dest/util/txe_public_contract_data_source.js +5 -22
  42. package/dest/utils/block_creation.d.ts +4 -4
  43. package/dest/utils/block_creation.d.ts.map +1 -1
  44. package/dest/utils/block_creation.js +18 -5
  45. package/dest/utils/tx_effect_creation.d.ts +2 -3
  46. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  47. package/dest/utils/tx_effect_creation.js +3 -6
  48. package/package.json +16 -16
  49. package/src/constants.ts +3 -0
  50. package/src/index.ts +83 -49
  51. package/src/oracle/interfaces.ts +8 -3
  52. package/src/oracle/txe_oracle_public_context.ts +6 -8
  53. package/src/oracle/txe_oracle_top_level_context.ts +163 -79
  54. package/src/rpc_translator.ts +97 -56
  55. package/src/state_machine/archiver.ts +54 -220
  56. package/src/state_machine/dummy_p2p_client.ts +55 -32
  57. package/src/state_machine/global_variable_builder.ts +1 -1
  58. package/src/state_machine/index.ts +49 -11
  59. package/src/state_machine/mock_epoch_cache.ts +15 -11
  60. package/src/state_machine/synchronizer.ts +2 -2
  61. package/src/txe_session.ts +151 -71
  62. package/src/util/txe_public_contract_data_source.ts +10 -36
  63. package/src/utils/block_creation.ts +19 -16
  64. package/src/utils/tx_effect_creation.ts +3 -11
  65. package/dest/util/txe_contract_store.d.ts +0 -12
  66. package/dest/util/txe_contract_store.d.ts.map +0 -1
  67. package/dest/util/txe_contract_store.js +0 -22
  68. package/src/util/txe_contract_store.ts +0 -36
@@ -150,7 +150,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
150
150
  error_kind: "custom";
151
151
  } & import("@aztec/stdlib/abi").AbiType) | undefined>;
152
152
  }>, z.ZodObject<{
153
- bytecode: import("../../../foundation/dest/schemas/types.js").ZodFor<Buffer<ArrayBufferLike>>;
153
+ bytecode: import("@aztec/foundation/schemas").ZodFor<Buffer<ArrayBufferLike>>;
154
154
  verificationKey: z.ZodOptional<z.ZodString>;
155
155
  debugSymbols: z.ZodString;
156
156
  debug: z.ZodOptional<z.ZodObject<{
@@ -656,27 +656,27 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
656
656
  }>;
657
657
  }>, z.ZodIntersection<z.ZodObject<{
658
658
  version: z.ZodLiteral<1>;
659
- salt: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
660
- deployer: import("../../../foundation/dest/schemas/types.js").ZodFor<AztecAddress>;
661
- currentContractClassId: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
662
- originalContractClassId: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
663
- initializationHash: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
659
+ salt: import("@aztec/foundation/schemas").ZodFor<Fr>;
660
+ deployer: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
661
+ currentContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
662
+ originalContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
663
+ initializationHash: import("@aztec/foundation/schemas").ZodFor<Fr>;
664
664
  publicKeys: z.ZodEffects<z.ZodObject<{
665
- masterNullifierPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
666
- masterIncomingViewingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
667
- masterOutgoingViewingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
668
- masterTaggingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
665
+ masterNullifierPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
666
+ masterIncomingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
667
+ masterOutgoingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
668
+ masterTaggingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
669
669
  }, "strip", z.ZodTypeAny, {
670
- masterNullifierPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
671
- masterIncomingViewingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
672
- masterOutgoingViewingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
673
- masterTaggingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
670
+ masterNullifierPublicKey: import("@aztec/foundation/schemas").Point;
671
+ masterIncomingViewingPublicKey: import("@aztec/foundation/schemas").Point;
672
+ masterOutgoingViewingPublicKey: import("@aztec/foundation/schemas").Point;
673
+ masterTaggingPublicKey: import("@aztec/foundation/schemas").Point;
674
674
  }, {
675
675
  masterNullifierPublicKey: string;
676
676
  masterIncomingViewingPublicKey: string;
677
677
  masterOutgoingViewingPublicKey: string;
678
678
  masterTaggingPublicKey: string;
679
- }>, import("../../../stdlib/dest/keys/public_keys.js").PublicKeys, {
679
+ }>, import("@aztec/stdlib/keys").PublicKeys, {
680
680
  masterNullifierPublicKey: string;
681
681
  masterIncomingViewingPublicKey: string;
682
682
  masterOutgoingViewingPublicKey: string;
@@ -689,7 +689,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
689
689
  currentContractClassId: Fr;
690
690
  originalContractClassId: Fr;
691
691
  initializationHash: Fr;
692
- publicKeys: import("../../../stdlib/dest/keys/public_keys.js").PublicKeys;
692
+ publicKeys: import("@aztec/stdlib/keys").PublicKeys;
693
693
  }, {
694
694
  version: 1;
695
695
  salt?: any;
@@ -704,7 +704,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
704
704
  masterTaggingPublicKey: string;
705
705
  };
706
706
  }>, z.ZodObject<{
707
- address: import("../../../foundation/dest/schemas/types.js").ZodFor<AztecAddress>;
707
+ address: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
708
708
  }, "strip", z.ZodTypeAny, {
709
709
  address: AztecAddress;
710
710
  }, {
@@ -3,9 +3,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ContractStore } from '@aztec/pxe/server';
4
4
  import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
6
+ import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
7
7
  export declare class TXEPublicContractDataSource implements ContractDataSource {
8
- #private;
9
8
  private blockNumber;
10
9
  private contractStore;
11
10
  constructor(blockNumber: BlockNumber, contractStore: ContractStore);
@@ -18,4 +17,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
18
17
  getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
19
18
  registerContractFunctionSignatures(_signatures: []): Promise<void>;
20
19
  }
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQ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,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEnH,qBAAa,2BAA4B,YAAW,kBAAkB;IAElE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IAFvB,YACU,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAClC;IAEJ,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAcvE;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAG3D;IAEK,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGzF;IAED,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEnC;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAGtF;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEzG;IAED,kCAAkC,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;CACF"}
@@ -1,48 +1,31 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { FunctionType } from '@aztec/stdlib/abi';
3
- import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
4
1
  export class TXEPublicContractDataSource {
5
2
  blockNumber;
6
3
  contractStore;
7
- #privateFunctionsRoot;
8
4
  constructor(blockNumber, contractStore){
9
5
  this.blockNumber = blockNumber;
10
6
  this.contractStore = contractStore;
11
- this.#privateFunctionsRoot = new Map();
12
7
  }
13
8
  getBlockNumber() {
14
9
  return Promise.resolve(this.blockNumber);
15
10
  }
16
11
  async getContractClass(id) {
17
- const contractClass = await this.contractStore.getContractClass(id);
12
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
18
13
  if (!contractClass) {
19
14
  return;
20
15
  }
21
- const artifact = await this.contractStore.getContractArtifact(id);
22
- if (!artifact) {
23
- return;
24
- }
25
- let privateFunctionsRoot;
26
- if (!this.#privateFunctionsRoot.has(id.toString())) {
27
- const privateFunctions = await Promise.all(artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE).map((fn)=>getContractClassPrivateFunctionFromArtifact(fn)));
28
- privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
29
- this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
30
- } else {
31
- privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString()));
32
- }
33
16
  return {
34
- id,
17
+ id: contractClass.id,
35
18
  artifactHash: contractClass.artifactHash,
36
19
  packedBytecode: contractClass.packedBytecode,
37
- privateFunctionsRoot,
20
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
38
21
  version: contractClass.version,
39
22
  privateFunctions: [],
40
23
  utilityFunctions: []
41
24
  };
42
25
  }
43
26
  async getBytecodeCommitment(id) {
44
- const contractClass = await this.contractStore.getContractClass(id);
45
- return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
27
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
28
+ return contractClass?.publicBytecodeCommitment;
46
29
  }
47
30
  async getContract(address) {
48
31
  const instance = await this.contractStore.getContractInstance(address);
@@ -1,8 +1,8 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { L2Block, L2BlockHeader } from '@aztec/stdlib/block';
3
+ import { L2Block } from '@aztec/stdlib/block';
4
4
  import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
5
- import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
5
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
6
6
  /**
7
7
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
8
8
  * @param blockNumber The number for the block in which there is a single transaction.
@@ -10,7 +10,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
10
10
  */
11
11
  export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
12
12
  export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
13
- export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<L2BlockHeader>;
13
+ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
14
14
  /**
15
15
  * Creates an L2Block with proper archive chaining.
16
16
  * This function:
@@ -25,4 +25,4 @@ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations
25
25
  * @returns The created L2Block with proper archive chaining
26
26
  */
27
27
  export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBUSxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFFbkUsT0FBTyxFQUF3QyxLQUFLLHlCQUF5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AC,CAiBlB"}
@@ -1,9 +1,10 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
2
3
  import { padArrayEnd } from '@aztec/foundation/collection';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
5
- import { makeContentCommitment } from '@aztec/stdlib/testing';
5
+ import { Body, L2Block } from '@aztec/stdlib/block';
6
6
  import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
7
+ import { BlockHeader } from '@aztec/stdlib/tx';
7
8
  /**
8
9
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
9
10
  * @param blockNumber The number for the block in which there is a single transaction.
@@ -20,7 +21,14 @@ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
20
21
  export async function makeTXEBlockHeader(worldTrees, globalVariables) {
21
22
  const stateReference = await worldTrees.getStateReference();
22
23
  const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
23
- return new L2BlockHeader(new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)), makeContentCommitment(), stateReference, globalVariables, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO);
24
+ return BlockHeader.from({
25
+ lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
26
+ spongeBlobHash: Fr.ZERO,
27
+ state: stateReference,
28
+ globalVariables,
29
+ totalFees: Fr.ZERO,
30
+ totalManaUsed: Fr.ZERO
31
+ });
24
32
  }
25
33
  /**
26
34
  * Creates an L2Block with proper archive chaining.
@@ -37,9 +45,14 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
37
45
  */ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
38
46
  const header = await makeTXEBlockHeader(worldTrees, globalVariables);
39
47
  // Update the archive tree with this block's header hash
40
- await worldTrees.updateArchive(header.toBlockHeader());
48
+ await worldTrees.updateArchive(header);
41
49
  // Get the new archive state after updating
42
50
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
43
51
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
44
- return new L2Block(newArchive, header, new Body(txEffects));
52
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
53
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
54
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
55
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
56
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
57
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
45
58
  }
@@ -1,6 +1,5 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
4
3
  import { TxEffect } from '@aztec/stdlib/tx';
5
- export declare function makeTxEffect(noteCache: ExecutionNoteCache, protocolNullifier: Fr, txBlockNumber: BlockNumber): Promise<TxEffect>;
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUUvRCxPQUFPLEVBQUUsUUFBUSxFQUFVLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsd0JBQXNCLFlBQVksQ0FDaEMsU0FBUyxFQUFFLGtCQUFrQixFQUM3QixpQkFBaUIsRUFBRSxFQUFFLEVBQ3JCLGFBQWEsRUFBRSxXQUFXLEdBQ3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0EyQm5CIn0=
4
+ export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRS9ELE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUVwRCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0F1Qi9HIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAChC,SAAS,EAAE,kBAAkB,EAC7B,iBAAiB,EAAE,EAAE,EACrB,aAAa,EAAE,WAAW,GACzB,OAAO,CAAC,QAAQ,CAAC,CA2BnB"}
1
+ {"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuB/G"}
@@ -1,16 +1,13 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
3
3
  import { TxEffect, TxHash } from '@aztec/stdlib/tx';
4
- export async function makeTxEffect(noteCache, protocolNullifier, txBlockNumber) {
4
+ export async function makeTxEffect(noteCache, txBlockNumber) {
5
5
  const txEffect = TxEffect.empty();
6
- const { usedProtocolNullifierForNonces } = noteCache.finish();
7
- const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
6
+ noteCache.finish();
7
+ const nonceGenerator = noteCache.getNonceGenerator();
8
8
  txEffect.noteHashes = await Promise.all(noteCache.getAllNotes().map(async (pendingNote, i)=>computeUniqueNoteHash(await computeNoteHashNonce(nonceGenerator, i), await siloNoteHash(pendingNote.note.contractAddress, pendingNote.noteHashForConsumption))));
9
9
  // Nullifiers are already siloed
10
10
  txEffect.nullifiers = noteCache.getAllNullifiers();
11
- if (usedProtocolNullifierForNonces) {
12
- txEffect.nullifiers.unshift(protocolNullifier);
13
- }
14
11
  txEffect.txHash = new TxHash(new Fr(txBlockNumber));
15
12
  return txEffect;
16
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "0.0.1-commit.c7c42ec",
3
+ "version": "0.0.1-commit.c949de6bc",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "bin": "./dest/bin/index.js",
@@ -61,27 +61,27 @@
61
61
  ]
62
62
  },
63
63
  "dependencies": {
64
- "@aztec/accounts": "0.0.1-commit.c7c42ec",
65
- "@aztec/archiver": "0.0.1-commit.c7c42ec",
66
- "@aztec/aztec-node": "0.0.1-commit.c7c42ec",
67
- "@aztec/aztec.js": "0.0.1-commit.c7c42ec",
68
- "@aztec/bb-prover": "0.0.1-commit.c7c42ec",
69
- "@aztec/constants": "0.0.1-commit.c7c42ec",
70
- "@aztec/foundation": "0.0.1-commit.c7c42ec",
71
- "@aztec/key-store": "0.0.1-commit.c7c42ec",
72
- "@aztec/kv-store": "0.0.1-commit.c7c42ec",
73
- "@aztec/protocol-contracts": "0.0.1-commit.c7c42ec",
74
- "@aztec/pxe": "0.0.1-commit.c7c42ec",
75
- "@aztec/simulator": "0.0.1-commit.c7c42ec",
76
- "@aztec/stdlib": "0.0.1-commit.c7c42ec",
77
- "@aztec/world-state": "0.0.1-commit.c7c42ec",
64
+ "@aztec/accounts": "0.0.1-commit.c949de6bc",
65
+ "@aztec/archiver": "0.0.1-commit.c949de6bc",
66
+ "@aztec/aztec-node": "0.0.1-commit.c949de6bc",
67
+ "@aztec/aztec.js": "0.0.1-commit.c949de6bc",
68
+ "@aztec/bb-prover": "0.0.1-commit.c949de6bc",
69
+ "@aztec/constants": "0.0.1-commit.c949de6bc",
70
+ "@aztec/foundation": "0.0.1-commit.c949de6bc",
71
+ "@aztec/key-store": "0.0.1-commit.c949de6bc",
72
+ "@aztec/kv-store": "0.0.1-commit.c949de6bc",
73
+ "@aztec/protocol-contracts": "0.0.1-commit.c949de6bc",
74
+ "@aztec/pxe": "0.0.1-commit.c949de6bc",
75
+ "@aztec/simulator": "0.0.1-commit.c949de6bc",
76
+ "@aztec/stdlib": "0.0.1-commit.c949de6bc",
77
+ "@aztec/world-state": "0.0.1-commit.c949de6bc",
78
78
  "zod": "^3.23.8"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@jest/globals": "^30.0.0",
82
82
  "@types/jest": "^30.0.0",
83
83
  "@types/node": "^22.15.17",
84
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
84
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
85
85
  "jest": "^30.0.0",
86
86
  "jest-mock-extended": "^4.0.0",
87
87
  "ts-node": "^10.9.1",
@@ -0,0 +1,3 @@
1
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+
3
+ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
package/src/index.ts CHANGED
@@ -9,9 +9,12 @@ import { Fr } from '@aztec/aztec.js/fields';
9
9
  import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
10
10
  import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
11
11
  import type { Logger } from '@aztec/foundation/log';
12
- import { type ProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
12
+ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
13
+ import { protocolContractNames } from '@aztec/protocol-contracts';
13
14
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
15
+ import { ContractStore } from '@aztec/pxe/server';
14
16
  import { computeArtifactHash } from '@aztec/stdlib/contract';
17
+ import type { ContractArtifactWithHash } from '@aztec/stdlib/contract';
15
18
  import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
16
19
  import { zodFor } from '@aztec/stdlib/schemas';
17
20
 
@@ -33,18 +36,24 @@ import {
33
36
  fromSingle,
34
37
  toSingle,
35
38
  } from './util/encoding.js';
36
- import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
37
39
 
38
40
  const sessions = new Map<number, TXESession>();
39
41
 
40
42
  /*
41
43
  * TXE typically has to load the same contract artifacts over and over again for multiple tests,
42
- * so we cache them here to avoid both loading them from disk repeatedly and computing their artifact hashes
44
+ * so we cache them here to avoid loading from disk repeatedly.
45
+ *
46
+ * The in-flight map coalesces concurrent requests for the same cache key so that
47
+ * computeArtifactHash (very expensive) is only run once even under parallelism.
43
48
  */
44
49
  const TXEArtifactsCache = new Map<
45
50
  string,
46
51
  { artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }
47
52
  >();
53
+ const TXEArtifactsCacheInFlight = new Map<
54
+ string,
55
+ Promise<{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }>
56
+ >();
48
57
 
49
58
  type TXEForeignCallInput = {
50
59
  session_id: number;
@@ -68,7 +77,7 @@ const TXEForeignCallInputSchema = zodFor<TXEForeignCallInput>()(
68
77
  );
69
78
 
70
79
  class TXEDispatcher {
71
- private protocolContracts!: ProtocolContract[];
80
+ private contractStore!: ContractStore;
72
81
 
73
82
  constructor(private logger: Logger) {}
74
83
 
@@ -135,29 +144,36 @@ class TXEDispatcher {
135
144
  this.logger.debug(`Using cached artifact for ${cacheKey}`);
136
145
  ({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
137
146
  } else {
138
- this.logger.debug(`Loading compiled artifact ${artifactPath}`);
139
- const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8')) as NoirCompiledContract;
140
- const artifactWithoutHash = loadContractArtifact(artifactJSON);
141
- artifact = {
142
- ...artifactWithoutHash,
143
- // Artifact hash is *very* expensive to compute, so we do it here once
144
- // and the TXE contract data provider can cache it
145
- artifactHash: await computeArtifactHash(artifactWithoutHash),
146
- };
147
- this.logger.debug(
148
- `Deploy ${
149
- artifact.name
150
- } with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`,
151
- );
152
- instance = await getContractInstanceFromInstantiationParams(artifact, {
153
- constructorArgs: decodedArgs,
154
- skipArgsDecoding: true,
155
- salt: Fr.ONE,
156
- publicKeys,
157
- constructorArtifact: initializer ? initializer : undefined,
158
- deployer: AztecAddress.ZERO,
159
- });
160
- TXEArtifactsCache.set(cacheKey, { artifact, instance });
147
+ if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
148
+ this.logger.debug(`Loading compiled artifact ${artifactPath}`);
149
+ const compute = async () => {
150
+ const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8')) as NoirCompiledContract;
151
+ const artifactWithoutHash = loadContractArtifact(artifactJSON);
152
+ const computedArtifact: ContractArtifactWithHash = {
153
+ ...artifactWithoutHash,
154
+ // Artifact hash is *very* expensive to compute, so we do it here once
155
+ // and the TXE contract data provider can cache it
156
+ artifactHash: await computeArtifactHash(artifactWithoutHash),
157
+ };
158
+ this.logger.debug(
159
+ `Deploy ${computedArtifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`,
160
+ );
161
+ const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
162
+ constructorArgs: decodedArgs,
163
+ skipArgsDecoding: true,
164
+ salt: Fr.ONE,
165
+ publicKeys,
166
+ constructorArtifact: initializer ? initializer : undefined,
167
+ deployer: AztecAddress.ZERO,
168
+ });
169
+ const result = { artifact: computedArtifact, instance: computedInstance };
170
+ TXEArtifactsCache.set(cacheKey, result);
171
+ TXEArtifactsCacheInFlight.delete(cacheKey);
172
+ return result;
173
+ };
174
+ TXEArtifactsCacheInFlight.set(cacheKey, compute());
175
+ }
176
+ ({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
161
177
  }
162
178
 
163
179
  inputs.splice(0, 1, artifact, instance, toSingle(secret));
@@ -175,23 +191,35 @@ class TXEDispatcher {
175
191
  this.logger.debug(`Using cached artifact for ${cacheKey}`);
176
192
  ({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
177
193
  } else {
178
- const keys = await deriveKeys(secret);
179
- const args = [keys.publicKeys.masterIncomingViewingPublicKey.x, keys.publicKeys.masterIncomingViewingPublicKey.y];
180
- artifact = {
181
- ...SchnorrAccountContractArtifact,
182
- // Artifact hash is *very* expensive to compute, so we do it here once
183
- // and the TXE contract data provider can cache it
184
- artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact),
185
- };
186
- instance = await getContractInstanceFromInstantiationParams(artifact, {
187
- constructorArgs: args,
188
- skipArgsDecoding: true,
189
- salt: Fr.ONE,
190
- publicKeys: keys.publicKeys,
191
- constructorArtifact: 'constructor',
192
- deployer: AztecAddress.ZERO,
193
- });
194
- TXEArtifactsCache.set(cacheKey, { artifact, instance });
194
+ if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
195
+ const compute = async () => {
196
+ const keys = await deriveKeys(secret);
197
+ const args = [
198
+ keys.publicKeys.masterIncomingViewingPublicKey.x,
199
+ keys.publicKeys.masterIncomingViewingPublicKey.y,
200
+ ];
201
+ const computedArtifact: ContractArtifactWithHash = {
202
+ ...SchnorrAccountContractArtifact,
203
+ // Artifact hash is *very* expensive to compute, so we do it here once
204
+ // and the TXE contract data provider can cache it
205
+ artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact),
206
+ };
207
+ const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
208
+ constructorArgs: args,
209
+ skipArgsDecoding: true,
210
+ salt: Fr.ONE,
211
+ publicKeys: keys.publicKeys,
212
+ constructorArtifact: 'constructor',
213
+ deployer: AztecAddress.ZERO,
214
+ });
215
+ const result = { artifact: computedArtifact, instance: computedInstance };
216
+ TXEArtifactsCache.set(cacheKey, result);
217
+ TXEArtifactsCacheInFlight.delete(cacheKey);
218
+ return result;
219
+ };
220
+ TXEArtifactsCacheInFlight.set(cacheKey, compute());
221
+ }
222
+ ({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
195
223
  }
196
224
 
197
225
  inputs.splice(0, 0, artifact, instance);
@@ -204,12 +232,18 @@ class TXEDispatcher {
204
232
 
205
233
  if (!sessions.has(sessionId)) {
206
234
  this.logger.debug(`Creating new session ${sessionId}`);
207
- if (!this.protocolContracts) {
208
- this.protocolContracts = await Promise.all(
209
- protocolContractNames.map(name => new BundledProtocolContractsProvider().getProtocolContractArtifact(name)),
210
- );
235
+ if (!this.contractStore) {
236
+ const kvStore = await openTmpStore('txe-contracts');
237
+ this.contractStore = new ContractStore(kvStore);
238
+ const provider = new BundledProtocolContractsProvider();
239
+ for (const name of protocolContractNames) {
240
+ const { instance, artifact } = await provider.getProtocolContractArtifact(name);
241
+ await this.contractStore.addContractArtifact(artifact);
242
+ await this.contractStore.addContractInstance(instance);
243
+ }
244
+ this.logger.debug('Registered protocol contracts in shared contract store');
211
245
  }
212
- sessions.set(sessionId, await TXESession.init(this.protocolContracts));
246
+ sessions.set(sessionId, await TXESession.init(this.contractStore));
213
247
  }
214
248
 
215
249
  switch (functionName) {
@@ -33,9 +33,9 @@ export interface IAvmExecutionOracle {
33
33
  avmOpcodeVersion(): Promise<Fr>;
34
34
  avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
35
35
  avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
36
- avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean>;
36
+ avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean>;
37
37
  avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
38
- avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
38
+ avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
39
39
  }
40
40
 
41
41
  /**
@@ -71,11 +71,13 @@ export interface ITxeExecutionOracle {
71
71
  args: Fr[],
72
72
  argsHash: Fr,
73
73
  isStaticCall: boolean,
74
+ jobId: string,
74
75
  ): Promise<Fr[]>;
75
- txeSimulateUtilityFunction(
76
+ txeExecuteUtilityFunction(
76
77
  targetContractAddress: AztecAddress,
77
78
  functionSelector: FunctionSelector,
78
79
  args: Fr[],
80
+ jobId: string,
79
81
  ): Promise<Fr[]>;
80
82
  txePublicCallNewFlow(
81
83
  from: AztecAddress,
@@ -83,4 +85,7 @@ export interface ITxeExecutionOracle {
83
85
  calldata: Fr[],
84
86
  isStaticCall: boolean,
85
87
  ): Promise<Fr[]>;
88
+ // TODO(F-335): Drop this from here as it's not a real oracle handler - it's only called from
89
+ // RPCTranslator::txeGetPrivateEvents and never from Noir.
90
+ syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string): Promise<void>;
86
91
  }
@@ -78,13 +78,11 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
78
78
  this.transientUniqueNoteHashes.push(siloedNoteHash);
79
79
  }
80
80
 
81
- async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean> {
82
- const nullifier = await siloNullifier(targetAddress, innerNullifier!);
83
-
81
+ async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
84
82
  const treeIndex = (
85
- await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()])
83
+ await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
86
84
  )[0];
87
- const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(nullifier));
85
+ const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
88
86
 
89
87
  return treeIndex !== undefined || transientIndex !== undefined;
90
88
  }
@@ -101,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
101
99
  ]);
102
100
  }
103
101
 
104
- async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
105
- const leafSlot = await computePublicDataTreeLeafSlot(this.contractAddress, slot);
102
+ async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
103
+ const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
106
104
 
107
105
  const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
108
106
  MerkleTreeId.PUBLIC_DATA_TREE,
@@ -119,7 +117,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
119
117
  )) as PublicDataTreeLeafPreimage
120
118
  ).leaf.value;
121
119
 
122
- this.logger.debug('AVM storage read', { slot, value });
120
+ this.logger.debug('AVM storage read', { slot, contractAddress, value });
123
121
 
124
122
  return value;
125
123
  }