@aztec/txe 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1

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 (89) hide show
  1. package/dest/bin/index.d.ts +1 -1
  2. package/dest/bin/index.js +1 -1
  3. package/dest/index.d.ts +1 -1
  4. package/dest/index.d.ts.map +1 -1
  5. package/dest/index.js +5 -2
  6. package/dest/oracle/interfaces.d.ts +55 -0
  7. package/dest/oracle/interfaces.d.ts.map +1 -0
  8. package/dest/oracle/interfaces.js +3 -0
  9. package/dest/oracle/txe_oracle_public_context.d.ts +11 -11
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +30 -32
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +57 -0
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
  14. package/dest/oracle/txe_oracle_top_level_context.js +432 -0
  15. package/dest/{txe_service/txe_service.d.ts → rpc_translator.d.ts} +40 -31
  16. package/dest/rpc_translator.d.ts.map +1 -0
  17. package/dest/{txe_service/txe_service.js → rpc_translator.js} +172 -125
  18. package/dest/state_machine/archiver.d.ts +18 -9
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +21 -4
  21. package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +6 -0
  24. package/dest/state_machine/global_variable_builder.d.ts +3 -15
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +3 -22
  27. package/dest/state_machine/index.d.ts +2 -2
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +8 -6
  30. package/dest/state_machine/mock_epoch_cache.d.ts +6 -5
  31. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  32. package/dest/state_machine/mock_epoch_cache.js +8 -7
  33. package/dest/state_machine/synchronizer.d.ts +5 -4
  34. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  35. package/dest/state_machine/synchronizer.js +5 -4
  36. package/dest/txe_session.d.ts +36 -46
  37. package/dest/txe_session.d.ts.map +1 -1
  38. package/dest/txe_session.js +200 -82
  39. package/dest/util/encoding.d.ts +24 -24
  40. package/dest/util/encoding.d.ts.map +1 -1
  41. package/dest/util/encoding.js +1 -1
  42. package/dest/util/expected_failure_error.d.ts +1 -1
  43. package/dest/util/expected_failure_error.d.ts.map +1 -1
  44. package/dest/util/txe_account_data_provider.d.ts +1 -1
  45. package/dest/util/txe_account_data_provider.d.ts.map +1 -1
  46. package/dest/util/txe_contract_data_provider.d.ts +3 -2
  47. package/dest/util/txe_contract_data_provider.d.ts.map +1 -1
  48. package/dest/util/txe_contract_data_provider.js +1 -1
  49. package/dest/util/txe_public_contract_data_source.d.ts +8 -6
  50. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  51. package/dest/util/txe_public_contract_data_source.js +14 -12
  52. package/dest/utils/block_creation.d.ts +14 -0
  53. package/dest/utils/block_creation.d.ts.map +1 -0
  54. package/dest/utils/block_creation.js +24 -0
  55. package/dest/utils/tx_effect_creation.d.ts +6 -0
  56. package/dest/utils/tx_effect_creation.d.ts.map +1 -0
  57. package/dest/utils/tx_effect_creation.js +16 -0
  58. package/package.json +18 -17
  59. package/src/bin/index.ts +1 -1
  60. package/src/index.ts +5 -8
  61. package/src/oracle/interfaces.ts +84 -0
  62. package/src/oracle/txe_oracle_public_context.ts +38 -71
  63. package/src/oracle/txe_oracle_top_level_context.ts +667 -0
  64. package/src/{txe_service/txe_service.ts → rpc_translator.ts} +222 -128
  65. package/src/state_machine/archiver.ts +33 -13
  66. package/src/state_machine/dummy_p2p_client.ts +10 -1
  67. package/src/state_machine/global_variable_builder.ts +7 -41
  68. package/src/state_machine/index.ts +10 -8
  69. package/src/state_machine/mock_epoch_cache.ts +12 -11
  70. package/src/state_machine/synchronizer.ts +8 -7
  71. package/src/txe_session.ts +305 -92
  72. package/src/util/encoding.ts +1 -1
  73. package/src/util/txe_contract_data_provider.ts +2 -1
  74. package/src/util/txe_public_contract_data_source.ts +16 -13
  75. package/src/utils/block_creation.ts +64 -0
  76. package/src/utils/tx_effect_creation.ts +38 -0
  77. package/dest/oracle/txe_oracle.d.ts +0 -124
  78. package/dest/oracle/txe_oracle.d.ts.map +0 -1
  79. package/dest/oracle/txe_oracle.js +0 -770
  80. package/dest/oracle/txe_typed_oracle.d.ts +0 -42
  81. package/dest/oracle/txe_typed_oracle.d.ts.map +0 -1
  82. package/dest/oracle/txe_typed_oracle.js +0 -83
  83. package/dest/txe_constants.d.ts +0 -2
  84. package/dest/txe_constants.d.ts.map +0 -1
  85. package/dest/txe_constants.js +0 -7
  86. package/dest/txe_service/txe_service.d.ts.map +0 -1
  87. package/src/oracle/txe_oracle.ts +0 -1287
  88. package/src/oracle/txe_typed_oracle.ts +0 -142
  89. package/src/txe_constants.ts +0 -9
@@ -1 +1 @@
1
- {"version":3,"file":"txe_contract_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,uBAAwB,SAAQ,oBAAoB;;IAGzC,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC;IAOM,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC;CASpE"}
1
+ {"version":3,"file":"txe_contract_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,uBAAwB,SAAQ,oBAAoB;;IAGzC,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,4 +1,4 @@
1
- import { Fr } from '@aztec/aztec.js';
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
2
  import { ContractDataProvider } from '@aztec/pxe/server';
3
3
  /*
4
4
  * A contract data provider that stores contract artifacts with their hashes. Since
@@ -1,13 +1,15 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ContractDataProvider } from '@aztec/pxe/server';
2
4
  import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
3
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
6
  import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
- import type { TXE } from '../oracle/txe_oracle.js';
6
7
  export declare class TXEPublicContractDataSource implements ContractDataSource {
7
8
  #private;
8
- private txeOracle;
9
- constructor(txeOracle: TXE);
10
- getBlockNumber(): Promise<number>;
9
+ private blockNumber;
10
+ private contractDataProvider;
11
+ constructor(blockNumber: BlockNumber, contractDataProvider: ContractDataProvider);
12
+ getBlockNumber(): Promise<BlockNumber>;
11
13
  getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
12
14
  getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
13
15
  getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
@@ -16,4 +18,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
16
18
  getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
17
19
  registerContractFunctionSignatures(_signatures: []): Promise<void>;
18
20
  }
19
- //# sourceMappingURL=txe_public_contract_data_source.d.ts.map
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDOUQsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQWdCLE1BQU0sbUJBQW1CLENBQUM7QUFDMUYsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxFQUNMLEtBQUssbUJBQW1CLEVBQ3hCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssMkJBQTJCLEVBSWpDLE1BQU0sd0JBQXdCLENBQ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AAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,2BAA4B,YAAW,kBAAkB;;IAGlE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,oBAAoB;IAF9B,YACU,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAChD;IAEJ,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAgCvE;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,22 +1,24 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { FunctionType } from '@aztec/stdlib/abi';
3
3
  import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
4
4
  export class TXEPublicContractDataSource {
5
- txeOracle;
5
+ blockNumber;
6
+ contractDataProvider;
6
7
  #privateFunctionsRoot;
7
- constructor(txeOracle){
8
- this.txeOracle = txeOracle;
8
+ constructor(blockNumber, contractDataProvider){
9
+ this.blockNumber = blockNumber;
10
+ this.contractDataProvider = contractDataProvider;
9
11
  this.#privateFunctionsRoot = new Map();
10
12
  }
11
13
  getBlockNumber() {
12
- return this.txeOracle.utilityGetBlockNumber();
14
+ return Promise.resolve(this.blockNumber);
13
15
  }
14
16
  async getContractClass(id) {
15
- const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
17
+ const contractClass = await this.contractDataProvider.getContractClass(id);
16
18
  if (!contractClass) {
17
19
  return;
18
20
  }
19
- const artifact = await this.txeOracle.getContractDataProvider().getContractArtifact(id);
21
+ const artifact = await this.contractDataProvider.getContractArtifact(id);
20
22
  if (!artifact) {
21
23
  return;
22
24
  }
@@ -39,11 +41,11 @@ export class TXEPublicContractDataSource {
39
41
  };
40
42
  }
41
43
  async getBytecodeCommitment(id) {
42
- const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
44
+ const contractClass = await this.contractDataProvider.getContractClass(id);
43
45
  return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
44
46
  }
45
47
  async getContract(address) {
46
- const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
48
+ const instance = await this.contractDataProvider.getContractInstance(address);
47
49
  return instance && {
48
50
  ...instance,
49
51
  address
@@ -53,11 +55,11 @@ export class TXEPublicContractDataSource {
53
55
  throw new Error('Method not implemented.');
54
56
  }
55
57
  async getContractArtifact(address) {
56
- const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
57
- return instance && this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
58
+ const instance = await this.contractDataProvider.getContractInstance(address);
59
+ return instance && this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
58
60
  }
59
61
  async getDebugFunctionName(address, selector) {
60
- return await this.txeOracle.getContractDataProvider().getDebugFunctionName(address, selector);
62
+ return await this.contractDataProvider.getDebugFunctionName(address, selector);
61
63
  }
62
64
  registerContractFunctionSignatures(_signatures) {
63
65
  return Promise.resolve();
@@ -0,0 +1,14 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { L2BlockHeader } from '@aztec/stdlib/block';
4
+ import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
5
+ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
6
+ /**
7
+ * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
8
+ * @param blockNumber The number for the block in which there is a single transaction.
9
+ * @returns The transaction request hash.
10
+ */
11
+ export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
12
+ export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
13
+ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<L2BlockHeader>;
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUVwRCxPQUFPLEVBQXdDLEtBQUsseUJBQXlCLEVBQUUsTUFBTSxxQkFBcUIsQ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TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
+ import { padArrayEnd } from '@aztec/foundation/collection';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { L2BlockHeader } from '@aztec/stdlib/block';
5
+ import { makeContentCommitment } from '@aztec/stdlib/testing';
6
+ import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
7
+ /**
8
+ * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
9
+ * @param blockNumber The number for the block in which there is a single transaction.
10
+ * @returns The transaction request hash.
11
+ */ export function getSingleTxBlockRequestHash(blockNumber) {
12
+ return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
13
+ }
14
+ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
15
+ await worldTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
16
+ await worldTrees.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((nullifier)=>nullifier.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
17
+ await worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(txEffect.l2ToL1Msgs, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
18
+ // We do not need to add public data writes because we apply them as we go.
19
+ }
20
+ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
21
+ const stateReference = await worldTrees.getStateReference();
22
+ 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
+ }
@@ -0,0 +1,6 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
4
+ 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=
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
3
+ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
4
+ export async function makeTxEffect(noteCache, protocolNullifier, txBlockNumber) {
5
+ const txEffect = TxEffect.empty();
6
+ const { usedProtocolNullifierForNonces } = noteCache.finish();
7
+ const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
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
+ // Nullifiers are already siloed
10
+ txEffect.nullifiers = noteCache.getAllNullifiers();
11
+ if (usedProtocolNullifierForNonces) {
12
+ txEffect.nullifiers.unshift(protocolNullifier);
13
+ }
14
+ txEffect.txHash = new TxHash(new Fr(txBlockNumber));
15
+ return txEffect;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "3.0.0-canary.a9708bd",
3
+ "version": "3.0.0-devnet.2-patch.1",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "bin": "./dest/bin/index.js",
@@ -12,8 +12,8 @@
12
12
  "tsconfig": "./tsconfig.json"
13
13
  },
14
14
  "scripts": {
15
- "build": "yarn clean && tsc -b",
16
- "build:dev": "tsc -b --watch",
15
+ "build": "yarn clean && ../scripts/tsc.sh",
16
+ "build:dev": "../scripts/tsc.sh --watch",
17
17
  "clean": "rm -rf ./dest .tsbuildinfo",
18
18
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
19
19
  "dev": "LOG_LEVEL=\"debug; trace: simulator:state_manager; info: json-rpc:proxy\" node ./dest/bin/index.js",
@@ -61,26 +61,27 @@
61
61
  ]
62
62
  },
63
63
  "dependencies": {
64
- "@aztec/accounts": "3.0.0-canary.a9708bd",
65
- "@aztec/archiver": "3.0.0-canary.a9708bd",
66
- "@aztec/aztec-node": "3.0.0-canary.a9708bd",
67
- "@aztec/aztec.js": "3.0.0-canary.a9708bd",
68
- "@aztec/bb-prover": "3.0.0-canary.a9708bd",
69
- "@aztec/constants": "3.0.0-canary.a9708bd",
70
- "@aztec/foundation": "3.0.0-canary.a9708bd",
71
- "@aztec/key-store": "3.0.0-canary.a9708bd",
72
- "@aztec/kv-store": "3.0.0-canary.a9708bd",
73
- "@aztec/protocol-contracts": "3.0.0-canary.a9708bd",
74
- "@aztec/pxe": "3.0.0-canary.a9708bd",
75
- "@aztec/simulator": "3.0.0-canary.a9708bd",
76
- "@aztec/stdlib": "3.0.0-canary.a9708bd",
77
- "@aztec/world-state": "3.0.0-canary.a9708bd",
64
+ "@aztec/accounts": "3.0.0-devnet.2-patch.1",
65
+ "@aztec/archiver": "3.0.0-devnet.2-patch.1",
66
+ "@aztec/aztec-node": "3.0.0-devnet.2-patch.1",
67
+ "@aztec/aztec.js": "3.0.0-devnet.2-patch.1",
68
+ "@aztec/bb-prover": "3.0.0-devnet.2-patch.1",
69
+ "@aztec/constants": "3.0.0-devnet.2-patch.1",
70
+ "@aztec/foundation": "3.0.0-devnet.2-patch.1",
71
+ "@aztec/key-store": "3.0.0-devnet.2-patch.1",
72
+ "@aztec/kv-store": "3.0.0-devnet.2-patch.1",
73
+ "@aztec/protocol-contracts": "3.0.0-devnet.2-patch.1",
74
+ "@aztec/pxe": "3.0.0-devnet.2-patch.1",
75
+ "@aztec/simulator": "3.0.0-devnet.2-patch.1",
76
+ "@aztec/stdlib": "3.0.0-devnet.2-patch.1",
77
+ "@aztec/world-state": "3.0.0-devnet.2-patch.1",
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
85
  "jest": "^30.0.0",
85
86
  "jest-mock-extended": "^4.0.0",
86
87
  "ts-node": "^10.9.1",
package/src/bin/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
- import { createLogger } from '@aztec/aztec.js';
2
+ import { createLogger } from '@aztec/aztec.js/log';
3
3
  import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
4
4
 
5
5
  import { createTXERpcServer } from '../index.js';
package/src/index.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
+ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js/abi';
3
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
4
  import {
3
- AztecAddress,
4
5
  type ContractInstanceWithAddress,
5
- Fr,
6
- type NoirCompiledContract,
7
- PublicKeys,
8
- deriveKeys,
9
6
  getContractInstanceFromInstantiationParams,
10
- loadContractArtifact,
11
- } from '@aztec/aztec.js';
7
+ } from '@aztec/aztec.js/contracts';
8
+ import { Fr } from '@aztec/aztec.js/fields';
9
+ import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
12
10
  import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
13
11
  import type { Logger } from '@aztec/foundation/log';
14
12
  import { type ProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
@@ -55,7 +53,6 @@ type TXEForeignCallInput = {
55
53
  inputs: ForeignCallArgs;
56
54
  };
57
55
 
58
- // TODO: why does the zod validation in the txe dispatcher not reject invalid function names?
59
56
  const TXEForeignCallInputSchema = z.object({
60
57
  // eslint-disable-next-line camelcase
61
58
  session_id: z.number().int().nonnegative(),
@@ -0,0 +1,84 @@
1
+ import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
+ import { CompleteAddress } from '@aztec/aztec.js/addresses';
3
+ import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
4
+ import { TxHash } from '@aztec/aztec.js/tx';
5
+ import { BlockNumber } from '@aztec/foundation/branded-types';
6
+ import type { Fr } from '@aztec/foundation/curves/bn254';
7
+ import type { FunctionSelector } from '@aztec/stdlib/abi';
8
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
+ import type { UInt64 } from '@aztec/stdlib/types';
10
+
11
+ // These interfaces complement the ones defined in PXE, and combined with those contain the full list of oracles used by
12
+ // aztec-nr. In particular, these include the ones needed to run Brillig code associated to #[external("public")] functions that has
13
+ // not been transpiled (e.g. in the context of a Noir test) as well as the ones associated with managing the state of
14
+ // such a Noir test (deploying contracts, manipulating block time, making calls, etc) - the so called 'top level test
15
+ // context'.
16
+
17
+ /**
18
+ * Oracle methods associated with the execution of an Aztec #[external("public")] function.
19
+ *
20
+ * Note that real contracts have their Brillig calls to these be transpiled into opcodes, the oracles are only executed
21
+ * as such when running the original Brillig code, e.g. when invoking functions that interact with a PublicContext
22
+ * directly in a Noir test.
23
+ */
24
+ export interface IAvmExecutionOracle {
25
+ isAvm: true;
26
+
27
+ avmOpcodeAddress(): Promise<AztecAddress>;
28
+ avmOpcodeSender(): Promise<AztecAddress>;
29
+ avmOpcodeBlockNumber(): Promise<BlockNumber>;
30
+ avmOpcodeTimestamp(): Promise<bigint>;
31
+ avmOpcodeIsStaticCall(): Promise<boolean>;
32
+ avmOpcodeChainId(): Promise<Fr>;
33
+ avmOpcodeVersion(): Promise<Fr>;
34
+ avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
35
+ avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
36
+ avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean>;
37
+ avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
38
+ avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
39
+ }
40
+
41
+ /**
42
+ * Oracle methods associated with the execution of an Aztec Noir test.
43
+ */
44
+ export interface ITxeExecutionOracle {
45
+ isTxe: true;
46
+
47
+ txeGetNextBlockNumber(): Promise<BlockNumber>;
48
+ txeGetNextBlockTimestamp(): Promise<UInt64>;
49
+ txeAdvanceBlocksBy(blocks: number): Promise<void>;
50
+ txeAdvanceTimestampBy(duration: UInt64): void;
51
+ txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: Fr): Promise<void>;
52
+ txeCreateAccount(secret: Fr): Promise<CompleteAddress>;
53
+ txeAddAccount(
54
+ artifact: ContractArtifact,
55
+ instance: ContractInstanceWithAddress,
56
+ secret: Fr,
57
+ ): Promise<CompleteAddress>;
58
+ txeAddAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
59
+ txeGetLastBlockTimestamp(): Promise<bigint>;
60
+ txeGetLastTxEffects(): Promise<{
61
+ txHash: TxHash;
62
+ noteHashes: Fr[];
63
+ nullifiers: Fr[];
64
+ }>;
65
+ txePrivateCallNewFlow(
66
+ from: AztecAddress,
67
+ targetContractAddress: AztecAddress,
68
+ functionSelector: FunctionSelector,
69
+ args: Fr[],
70
+ argsHash: Fr,
71
+ isStaticCall: boolean,
72
+ ): Promise<Fr[]>;
73
+ txeSimulateUtilityFunction(
74
+ targetContractAddress: AztecAddress,
75
+ functionSelector: FunctionSelector,
76
+ args: Fr[],
77
+ ): Promise<Fr[]>;
78
+ txePublicCallNewFlow(
79
+ from: AztecAddress,
80
+ targetContractAddress: AztecAddress,
81
+ calldata: Fr[],
82
+ isStaticCall: boolean,
83
+ ): Promise<Fr[]>;
84
+ }
@@ -1,30 +1,25 @@
1
- import {
2
- MAX_NOTE_HASHES_PER_TX,
3
- MAX_NULLIFIERS_PER_TX,
4
- NULLIFIER_SUBTREE_HEIGHT,
5
- NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
6
- } from '@aztec/constants';
7
- import { padArrayEnd } from '@aztec/foundation/collection';
8
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
9
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
10
4
  import { PublicDataWrite } from '@aztec/stdlib/avm';
11
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
6
  import { Body, L2Block } from '@aztec/stdlib/block';
13
7
  import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
14
- import { makeAppendOnlyTreeSnapshot, makeContentCommitment } from '@aztec/stdlib/testing';
8
+ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
15
9
  import {
16
- AppendOnlyTreeSnapshot,
17
10
  MerkleTreeId,
18
11
  type MerkleTreeWriteOperations,
19
12
  PublicDataTreeLeaf,
20
13
  PublicDataTreeLeafPreimage,
21
14
  } from '@aztec/stdlib/trees';
22
- import { BlockHeader, GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
23
- import type { UInt32 } from '@aztec/stdlib/types';
15
+ import { GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
16
+
17
+ import { insertTxEffectIntoWorldTrees, makeTXEBlockHeader } from '../utils/block_creation.js';
18
+ import type { IAvmExecutionOracle } from './interfaces.js';
24
19
 
25
- import { TXETypedOracle } from './txe_typed_oracle.js';
20
+ export class TXEOraclePublicContext implements IAvmExecutionOracle {
21
+ isAvm = true as const;
26
22
 
27
- export class TXEOraclePublicContext extends TXETypedOracle {
28
23
  private logger: Logger;
29
24
  private transientUniqueNoteHashes: Fr[] = [];
30
25
  private transientSiloedNullifiers: Fr[] = [];
@@ -32,80 +27,85 @@ export class TXEOraclePublicContext extends TXETypedOracle {
32
27
 
33
28
  constructor(
34
29
  private contractAddress: AztecAddress,
35
- private worldTrees: MerkleTreeWriteOperations,
30
+ private forkedWorldTrees: MerkleTreeWriteOperations,
36
31
  private txRequestHash: Fr,
37
32
  private globalVariables: GlobalVariables,
38
33
  ) {
39
- super();
40
34
  this.logger = createLogger('txe:public_context');
41
35
 
42
- this.logger.debug('Entering PublicContext', {
36
+ this.logger.debug('Entering Public Context', {
43
37
  contractAddress,
44
38
  blockNumber: globalVariables.blockNumber,
45
39
  timestamp: globalVariables.timestamp,
46
40
  });
47
41
  }
48
42
 
49
- override avmOpcodeAddress(): Promise<AztecAddress> {
43
+ avmOpcodeAddress(): Promise<AztecAddress> {
50
44
  return Promise.resolve(this.contractAddress);
51
45
  }
52
46
 
53
- override avmOpcodeBlockNumber(): Promise<UInt32> {
47
+ avmOpcodeSender(): Promise<AztecAddress> {
48
+ return Promise.resolve(AztecAddress.ZERO); // todo: change?
49
+ }
50
+
51
+ avmOpcodeBlockNumber(): Promise<BlockNumber> {
54
52
  return Promise.resolve(this.globalVariables.blockNumber);
55
53
  }
56
54
 
57
- override avmOpcodeTimestamp(): Promise<bigint> {
55
+ avmOpcodeTimestamp(): Promise<bigint> {
58
56
  return Promise.resolve(this.globalVariables.timestamp);
59
57
  }
60
58
 
61
- override avmOpcodeIsStaticCall(): Promise<boolean> {
59
+ avmOpcodeIsStaticCall(): Promise<boolean> {
62
60
  return Promise.resolve(false);
63
61
  }
64
62
 
65
- override avmOpcodeChainId(): Promise<Fr> {
63
+ avmOpcodeChainId(): Promise<Fr> {
66
64
  return Promise.resolve(this.globalVariables.chainId);
67
65
  }
68
66
 
69
- override avmOpcodeVersion(): Promise<Fr> {
67
+ avmOpcodeVersion(): Promise<Fr> {
70
68
  return Promise.resolve(this.globalVariables.version);
71
69
  }
72
70
 
73
- override async avmOpcodeEmitNullifier(nullifier: Fr) {
71
+ async avmOpcodeEmitNullifier(nullifier: Fr) {
74
72
  const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
75
73
  this.transientSiloedNullifiers.push(siloedNullifier);
76
74
  }
77
75
 
78
- override async avmOpcodeEmitNoteHash(noteHash: Fr) {
76
+ async avmOpcodeEmitNoteHash(noteHash: Fr) {
79
77
  const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
80
78
  // TODO: make the note hash unique - they are only siloed right now
81
79
  this.transientUniqueNoteHashes.push(siloedNoteHash);
82
80
  }
83
81
 
84
- override async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean> {
82
+ async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean> {
85
83
  const nullifier = await siloNullifier(targetAddress, innerNullifier!);
86
84
 
87
- const treeIndex = (await this.worldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]))[0];
85
+ const treeIndex = (
86
+ await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()])
87
+ )[0];
88
88
  const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(nullifier));
89
89
 
90
90
  return treeIndex !== undefined || transientIndex !== undefined;
91
91
  }
92
92
 
93
- override async avmOpcodeStorageWrite(slot: Fr, value: Fr) {
93
+ async avmOpcodeStorageWrite(slot: Fr, value: Fr) {
94
94
  this.logger.debug('AVM storage write', { slot, value });
95
95
 
96
96
  const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
97
97
 
98
98
  this.publicDataWrites.push(dataWrite);
99
99
 
100
- await this.worldTrees.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
100
+ await this.forkedWorldTrees.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
101
101
  new PublicDataTreeLeaf(dataWrite.leafSlot, dataWrite.value).toBuffer(),
102
102
  ]);
103
103
  }
104
104
 
105
- override async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
105
+ async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
106
106
  const leafSlot = await computePublicDataTreeLeafSlot(this.contractAddress, slot);
107
107
 
108
- const lowLeafResult = await this.worldTrees.getPreviousValueIndex(
108
+ const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
109
109
  MerkleTreeId.PUBLIC_DATA_TREE,
110
110
  leafSlot.toBigInt(),
111
111
  );
@@ -114,7 +114,7 @@ export class TXEOraclePublicContext extends TXETypedOracle {
114
114
  !lowLeafResult || !lowLeafResult.alreadyPresent
115
115
  ? Fr.ZERO
116
116
  : (
117
- (await this.worldTrees.getLeafPreimage(
117
+ (await this.forkedWorldTrees.getLeafPreimage(
118
118
  MerkleTreeId.PUBLIC_DATA_TREE,
119
119
  lowLeafResult.index,
120
120
  )) as PublicDataTreeLeafPreimage
@@ -126,20 +126,20 @@ export class TXEOraclePublicContext extends TXETypedOracle {
126
126
  }
127
127
 
128
128
  async close(): Promise<L2Block> {
129
- this.logger.debug('Exiting PublicContext, building block with collected side effects', {
129
+ this.logger.debug('Exiting Public Context, building block with collected side effects', {
130
130
  blockNumber: this.globalVariables.blockNumber,
131
131
  });
132
132
 
133
133
  const txEffect = this.makeTxEffect();
134
- await this.insertSideEffectIntoWorldTrees(txEffect);
134
+ await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
135
135
 
136
136
  const block = new L2Block(
137
- makeAppendOnlyTreeSnapshot(this.globalVariables.blockNumber),
138
- await this.makeBlockHeader(),
137
+ makeAppendOnlyTreeSnapshot(),
138
+ await makeTXEBlockHeader(this.forkedWorldTrees, this.globalVariables),
139
139
  new Body([txEffect]),
140
140
  );
141
141
 
142
- await this.worldTrees.close();
142
+ await this.forkedWorldTrees.close();
143
143
 
144
144
  this.logger.debug('Exited PublicContext with built block', {
145
145
  blockNumber: block.number,
@@ -162,37 +162,4 @@ export class TXEOraclePublicContext extends TXETypedOracle {
162
162
 
163
163
  return txEffect;
164
164
  }
165
-
166
- private async insertSideEffectIntoWorldTrees(txEffect: TxEffect) {
167
- const l1ToL2Messages = Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero);
168
-
169
- await this.worldTrees.appendLeaves(
170
- MerkleTreeId.NOTE_HASH_TREE,
171
- padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
172
- );
173
-
174
- await this.worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
175
-
176
- // We do not need to add public data writes because we apply them as we go.
177
-
178
- await this.worldTrees.batchInsert(
179
- MerkleTreeId.NULLIFIER_TREE,
180
- padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(nullifier => nullifier.toBuffer()),
181
- NULLIFIER_SUBTREE_HEIGHT,
182
- );
183
- }
184
-
185
- private async makeBlockHeader(): Promise<BlockHeader> {
186
- const stateReference = await this.worldTrees.getStateReference();
187
- const archiveInfo = await this.worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
188
-
189
- return new BlockHeader(
190
- new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
191
- makeContentCommitment(),
192
- stateReference,
193
- this.globalVariables,
194
- Fr.ZERO,
195
- Fr.ZERO,
196
- );
197
- }
198
165
  }