@aztec/txe 0.0.0-test.1 → 0.0.1-commit.023c3e5

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 (100) hide show
  1. package/dest/bin/index.d.ts +1 -1
  2. package/dest/bin/index.js +3 -2
  3. package/dest/constants.d.ts +3 -0
  4. package/dest/constants.d.ts.map +1 -0
  5. package/dest/constants.js +2 -0
  6. package/dest/index.d.ts +1 -1
  7. package/dest/index.d.ts.map +1 -1
  8. package/dest/index.js +81 -51
  9. package/dest/oracle/interfaces.d.ts +57 -0
  10. package/dest/oracle/interfaces.d.ts.map +1 -0
  11. package/dest/oracle/interfaces.js +3 -0
  12. package/dest/oracle/txe_oracle_public_context.d.ts +34 -0
  13. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
  14. package/dest/oracle/txe_oracle_public_context.js +122 -0
  15. package/dest/oracle/txe_oracle_top_level_context.d.ts +66 -0
  16. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
  17. package/dest/oracle/txe_oracle_top_level_context.js +471 -0
  18. package/dest/rpc_translator.d.ts +252 -0
  19. package/dest/rpc_translator.d.ts.map +1 -0
  20. package/dest/rpc_translator.js +679 -0
  21. package/dest/state_machine/archiver.d.ts +31 -0
  22. package/dest/state_machine/archiver.d.ts.map +1 -0
  23. package/dest/state_machine/archiver.js +85 -0
  24. package/dest/state_machine/dummy_p2p_client.d.ts +55 -0
  25. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
  26. package/dest/state_machine/dummy_p2p_client.js +141 -0
  27. package/dest/state_machine/global_variable_builder.d.ts +11 -0
  28. package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
  29. package/dest/state_machine/global_variable_builder.js +22 -0
  30. package/dest/state_machine/index.d.ts +16 -0
  31. package/dest/state_machine/index.d.ts.map +1 -0
  32. package/dest/state_machine/index.js +63 -0
  33. package/dest/state_machine/mock_epoch_cache.d.ts +27 -0
  34. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
  35. package/dest/state_machine/mock_epoch_cache.js +54 -0
  36. package/dest/state_machine/synchronizer.d.ts +33 -0
  37. package/dest/state_machine/synchronizer.d.ts.map +1 -0
  38. package/dest/state_machine/synchronizer.js +59 -0
  39. package/dest/txe_session.d.ts +75 -0
  40. package/dest/txe_session.d.ts.map +1 -0
  41. package/dest/txe_session.js +302 -0
  42. package/dest/util/encoding.d.ts +641 -24
  43. package/dest/util/encoding.d.ts.map +1 -1
  44. package/dest/util/encoding.js +66 -11
  45. package/dest/util/expected_failure_error.d.ts +1 -1
  46. package/dest/util/expected_failure_error.d.ts.map +1 -1
  47. package/dest/util/txe_account_store.d.ts +10 -0
  48. package/dest/util/txe_account_store.d.ts.map +1 -0
  49. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  50. package/dest/util/txe_contract_store.d.ts +12 -0
  51. package/dest/util/txe_contract_store.d.ts.map +1 -0
  52. package/dest/util/txe_contract_store.js +22 -0
  53. package/dest/util/txe_public_contract_data_source.d.ts +12 -11
  54. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  55. package/dest/util/txe_public_contract_data_source.js +37 -58
  56. package/dest/utils/block_creation.d.ts +28 -0
  57. package/dest/utils/block_creation.d.ts.map +1 -0
  58. package/dest/utils/block_creation.js +56 -0
  59. package/dest/utils/tx_effect_creation.d.ts +5 -0
  60. package/dest/utils/tx_effect_creation.d.ts.map +1 -0
  61. package/dest/utils/tx_effect_creation.js +13 -0
  62. package/package.json +30 -24
  63. package/src/bin/index.ts +3 -2
  64. package/src/constants.ts +3 -0
  65. package/src/index.ts +105 -74
  66. package/src/oracle/interfaces.ts +86 -0
  67. package/src/oracle/txe_oracle_public_context.ts +158 -0
  68. package/src/oracle/txe_oracle_top_level_context.ts +744 -0
  69. package/src/rpc_translator.ts +1098 -0
  70. package/src/state_machine/archiver.ts +95 -0
  71. package/src/state_machine/dummy_p2p_client.ts +209 -0
  72. package/src/state_machine/global_variable_builder.ts +38 -0
  73. package/src/state_machine/index.ts +100 -0
  74. package/src/state_machine/mock_epoch_cache.ts +67 -0
  75. package/src/state_machine/synchronizer.ts +88 -0
  76. package/src/txe_session.ts +539 -0
  77. package/src/util/encoding.ts +85 -11
  78. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  79. package/src/util/txe_contract_store.ts +36 -0
  80. package/src/util/txe_public_contract_data_source.ts +43 -58
  81. package/src/utils/block_creation.ts +95 -0
  82. package/src/utils/tx_effect_creation.ts +30 -0
  83. package/dest/node/txe_node.d.ts +0 -358
  84. package/dest/node/txe_node.d.ts.map +0 -1
  85. package/dest/node/txe_node.js +0 -504
  86. package/dest/oracle/txe_oracle.d.ts +0 -152
  87. package/dest/oracle/txe_oracle.d.ts.map +0 -1
  88. package/dest/oracle/txe_oracle.js +0 -833
  89. package/dest/txe_service/txe_service.d.ts +0 -212
  90. package/dest/txe_service/txe_service.d.ts.map +0 -1
  91. package/dest/txe_service/txe_service.js +0 -572
  92. package/dest/util/txe_account_data_provider.d.ts +0 -10
  93. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  94. package/dest/util/txe_world_state_db.d.ts +0 -14
  95. package/dest/util/txe_world_state_db.d.ts.map +0 -1
  96. package/dest/util/txe_world_state_db.js +0 -27
  97. package/src/node/txe_node.ts +0 -725
  98. package/src/oracle/txe_oracle.ts +0 -1241
  99. package/src/txe_service/txe_service.ts +0 -749
  100. package/src/util/txe_world_state_db.ts +0 -38
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/util/encoding.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,2BAA2B,EAAqC,MAAM,wBAAwB,CAAC;AA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { hexToBuffer } from '@aztec/foundation/string';
3
3
  import { ContractArtifactSchema } from '@aztec/stdlib/abi';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -16,7 +16,7 @@ export function fromArray(obj) {
16
16
  /**
17
17
  * Converts an array of Noir unsigned integers to a single tightly-packed buffer.
18
18
  * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
19
- * @returns
19
+ * @returns A buffer where each byte is correctly represented as a single byte in the buffer.
20
20
  */ export function fromUintArray(obj, uintBitSize) {
21
21
  if (uintBitSize % 8 !== 0) {
22
22
  throw new Error(`u${uintBitSize} is not a supported type in Noir`);
@@ -24,12 +24,43 @@ export function fromArray(obj) {
24
24
  const uintByteSize = uintBitSize / 8;
25
25
  return Buffer.concat(obj.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
26
26
  }
27
- export function toSingle(obj) {
28
- return obj.toString().slice(2);
27
+ /**
28
+ * Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
29
+ * translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
30
+ *
31
+ * @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
32
+ * @param length The length of the BoundedVec (i.e. BoundedVec::len())
33
+ * @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
34
+ * @returns A buffer containing the unsigned integers tightly packed
35
+ */ export function fromUintBoundedVec(storage, length, uintBitSize) {
36
+ if (uintBitSize % 8 !== 0) {
37
+ throw new Error(`u${uintBitSize} is not a supported type in Noir`);
38
+ }
39
+ const uintByteSize = uintBitSize / 8;
40
+ const boundedStorage = storage.slice(0, fromSingle(length).toNumber());
41
+ return Buffer.concat(boundedStorage.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
42
+ }
43
+ // Just like toACVMField in yarn-project/simulator/src/private/acvm/serialize.ts but returns a ForeignCallSingle
44
+ // instead of an ACVMField.
45
+ export function toSingle(value) {
46
+ let valueAsField;
47
+ if (Buffer.isBuffer(value)) {
48
+ valueAsField = Fr.fromBuffer(value);
49
+ } else if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'bigint') {
50
+ valueAsField = new Fr(value);
51
+ } else if (typeof value === 'string') {
52
+ valueAsField = Fr.fromHexString(value);
53
+ } else {
54
+ valueAsField = value;
55
+ }
56
+ return valueAsField.toString().slice(2);
29
57
  }
30
58
  export function toArray(objs) {
31
59
  return objs.map((obj)=>obj.toString());
32
60
  }
61
+ export function toSingleOrArray(value) {
62
+ return Array.isArray(value) ? value.map(toSingle) : toSingle(value);
63
+ }
33
64
  export function bufferToU8Array(buffer) {
34
65
  return toArray(Array.from(buffer).map((byte)=>new Fr(byte)));
35
66
  }
@@ -37,24 +68,48 @@ export function bufferToU8Array(buffer) {
37
68
  * Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
38
69
  * If the input array is shorter than the maxLen, it pads the result with zeros,
39
70
  * so that nr can correctly coerce this result into a BoundedVec.
40
- * @param array
71
+ * @param bVecStorage - The array underlying the BoundedVec.
41
72
  * @param maxLen - the max length of the BoundedVec.
42
73
  * @returns a tuple representing a BoundedVec.
43
- */ export function arrayToBoundedVec(array, maxLen) {
44
- if (array.length > maxLen) {
45
- throw new Error(`Array of length ${array.length} larger than maxLen ${maxLen}`);
74
+ */ export function arrayToBoundedVec(bVecStorage, maxLen) {
75
+ if (bVecStorage.length > maxLen) {
76
+ throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
46
77
  }
47
- const lengthDiff = maxLen - array.length;
78
+ const lengthDiff = maxLen - bVecStorage.length;
48
79
  // We pad the array to the maxLen of the BoundedVec.
49
80
  const zeroPaddingArray = toArray(Array(lengthDiff).fill(new Fr(0)));
50
81
  // These variable names match with the BoundedVec members in nr:
51
- const storage = array.concat(zeroPaddingArray);
52
- const len = toSingle(new Fr(array.length));
82
+ const storage = bVecStorage.concat(zeroPaddingArray);
83
+ const len = toSingle(new Fr(bVecStorage.length));
53
84
  return [
54
85
  storage,
55
86
  len
56
87
  ];
57
88
  }
89
+ /**
90
+ * Converts an array of arrays representing Noir BoundedVec of nested arrays into its Noir serialized form.
91
+ * @param bVecStorage - The array underlying the BoundedVec.
92
+ * @param maxLen - The max length of the BoundedVec (max num of the nested arrays in the BoundedVec).
93
+ * @param nestedArrayLength - The length of the nested arrays (each nested array has to have the same length).
94
+ * @returns Serialized BoundedVec following Noir intrinsic serialization.
95
+ */ export function arrayOfArraysToBoundedVecOfArrays(bVecStorage, maxLen, nestedArrayLength) {
96
+ if (bVecStorage.length > maxLen) {
97
+ throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
98
+ }
99
+ // Check that all nested arrays have length nestedArrayLength
100
+ if (!bVecStorage.every((nestedArray)=>nestedArray.length === nestedArrayLength)) {
101
+ throw new Error(`Nested array length passed in from Noir does not correspond to the length obtained in TS: ${nestedArrayLength} !== ${bVecStorage[0].length}`);
102
+ }
103
+ const flattenedStorage = bVecStorage.flat();
104
+ const numFieldsToPad = maxLen * nestedArrayLength - flattenedStorage.length;
105
+ const flattenedStorageWithPadding = flattenedStorage.concat(Array(numFieldsToPad).fill(new Fr(0)));
106
+ // At last we get the actual length of the BoundedVec and return the values.
107
+ const len = toSingle(new Fr(bVecStorage.length));
108
+ return [
109
+ flattenedStorageWithPadding,
110
+ len
111
+ ];
112
+ }
58
113
  export function toForeignCallResult(obj) {
59
114
  return {
60
115
  values: obj
@@ -1,4 +1,4 @@
1
1
  export declare class ExpectedFailureError extends Error {
2
2
  constructor(message: string);
3
3
  }
4
- //# sourceMappingURL=expected_failure_error.d.ts.map
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZWN0ZWRfZmFpbHVyZV9lcnJvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvZXhwZWN0ZWRfZmFpbHVyZV9lcnJvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxxQkFBYSxvQkFBcUIsU0FBUSxLQUFLO0lBQzdDLFlBQVksT0FBTyxFQUFFLE1BQU0sRUFFMUI7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"expected_failure_error.d.ts","sourceRoot":"","sources":["../../src/util/expected_failure_error.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAG5B"}
1
+ {"version":3,"file":"expected_failure_error.d.ts","sourceRoot":"","sources":["../../src/util/expected_failure_error.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { CompleteAddress } from '@aztec/stdlib/contract';
4
+ export declare class TXEAccountStore {
5
+ #private;
6
+ constructor(store: AztecAsyncKVStore);
7
+ getAccount(key: AztecAddress): Promise<CompleteAddress>;
8
+ setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9hY2NvdW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RCxxQkFBYSxlQUFlOztJQUcxQixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txe_account_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,eAAe;;IAG1B,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { CompleteAddress } from '@aztec/stdlib/contract';
2
- export class TXEAccountDataProvider {
2
+ export class TXEAccountStore {
3
3
  #accounts;
4
4
  constructor(store){
5
5
  this.#accounts = store.openMap('accounts');
@@ -0,0 +1,12 @@
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==
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,22 @@
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,20 +1,21 @@
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 { ContractStore } 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
- import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress, type PublicFunction } from '@aztec/stdlib/contract';
5
- import type { TXE } from '../oracle/txe_oracle.js';
6
+ import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
6
7
  export declare class TXEPublicContractDataSource implements ContractDataSource {
7
- private txeOracle;
8
- constructor(txeOracle: TXE);
9
- getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise<PublicFunction | undefined>;
10
- getBlockNumber(): Promise<number>;
8
+ #private;
9
+ private blockNumber;
10
+ private contractStore;
11
+ constructor(blockNumber: BlockNumber, contractStore: ContractStore);
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>;
14
16
  getContractClassIds(): Promise<Fr[]>;
15
17
  getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined>;
16
- getContractFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
17
- registerContractFunctionSignatures(_address: AztecAddress, _signatures: []): Promise<void>;
18
- addContractClass(_contractClass: ContractClassPublic): Promise<void>;
18
+ getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
19
+ registerContractFunctionSignatures(_signatures: []): Promise<void>;
19
20
  }
20
- //# sourceMappingURL=txe_public_contract_data_source.d.ts.map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T0FBTyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FHM0Q7SUFFSyxXQUFXLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsMkJBQTJCLEdBQUcsU0FBUyxDQUFDLENBR3pGO0lBRUQsbUJBQW1CLElBQUksT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBRW5DO0lBRUssbUJBQW1CLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsZ0JBQWdCLEdBQUcsU0FBUyxDQUFDLENBR3RGO0lBRUssb0JBQW9CLENBQUMsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FFekc7SUFFRCxrQ0FBa0MsQ0FBQyxXQUFXLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFakU7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAEnD,qBAAa,2BAA4B,YAAW,kBAAkB;IACxD,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,GAAG;IAE5B,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAA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,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,2BAA4B,YAAW,kBAAkB;;IAGlE,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,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,56 +1,52 @@
1
- import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { PrivateFunctionsTree } from '@aztec/pxe/server';
4
- import { FunctionSelector } from '@aztec/stdlib/abi';
5
- import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { FunctionType } from '@aztec/stdlib/abi';
3
+ import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
6
4
  export class TXEPublicContractDataSource {
7
- txeOracle;
8
- constructor(txeOracle){
9
- this.txeOracle = txeOracle;
10
- }
11
- async getPublicFunction(address, selector) {
12
- const bytecode = await this.txeOracle.getContractDataProvider().getBytecode(address, selector);
13
- if (!bytecode) {
14
- return undefined;
15
- }
16
- return {
17
- bytecode,
18
- selector
19
- };
5
+ blockNumber;
6
+ contractStore;
7
+ #privateFunctionsRoot;
8
+ constructor(blockNumber, contractStore){
9
+ this.blockNumber = blockNumber;
10
+ this.contractStore = contractStore;
11
+ this.#privateFunctionsRoot = new Map();
20
12
  }
21
13
  getBlockNumber() {
22
- return this.txeOracle.getBlockNumber();
14
+ return Promise.resolve(this.blockNumber);
23
15
  }
24
16
  async getContractClass(id) {
25
- const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
26
- const artifact = await this.txeOracle.getContractDataProvider().getContractArtifact(id);
27
- const tree = await PrivateFunctionsTree.create(artifact);
28
- const privateFunctionsRoot = await tree.getFunctionTreeRoot();
29
- const publicFunctions = [];
30
- if (contractClass.packedBytecode.length > 0) {
31
- publicFunctions.push({
32
- selector: FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
33
- bytecode: contractClass.packedBytecode
34
- });
17
+ const contractClass = await this.contractStore.getContractClass(id);
18
+ if (!contractClass) {
19
+ return;
20
+ }
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()));
35
32
  }
36
33
  return {
37
34
  id,
38
35
  artifactHash: contractClass.artifactHash,
39
36
  packedBytecode: contractClass.packedBytecode,
40
- publicFunctions: publicFunctions,
41
- privateFunctionsRoot: new Fr(privateFunctionsRoot.root),
37
+ privateFunctionsRoot,
42
38
  version: contractClass.version,
43
39
  privateFunctions: [],
44
- unconstrainedFunctions: []
40
+ utilityFunctions: []
45
41
  };
46
42
  }
47
43
  async getBytecodeCommitment(id) {
48
- const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
49
- return computePublicBytecodeCommitment(contractClass.packedBytecode);
44
+ const contractClass = await this.contractStore.getContractClass(id);
45
+ return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
50
46
  }
51
47
  async getContract(address) {
52
- const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
53
- return {
48
+ const instance = await this.contractStore.getContractInstance(address);
49
+ return instance && {
54
50
  ...instance,
55
51
  address
56
52
  };
@@ -59,30 +55,13 @@ export class TXEPublicContractDataSource {
59
55
  throw new Error('Method not implemented.');
60
56
  }
61
57
  async getContractArtifact(address) {
62
- const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
63
- return this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
64
- }
65
- async getContractFunctionName(address, selector) {
66
- const artifact = await this.getContractArtifact(address);
67
- if (!artifact) {
68
- return undefined;
69
- }
70
- const functionSelectorsAndNames = await Promise.all(artifact.functions.map(async (f)=>({
71
- name: f.name,
72
- selector: await FunctionSelector.fromNameAndParameters({
73
- name: f.name,
74
- parameters: f.parameters
75
- })
76
- })));
77
- const func = functionSelectorsAndNames.find((f)=>f.selector.equals(selector));
78
- return Promise.resolve(func?.name);
58
+ const instance = await this.contractStore.getContractInstance(address);
59
+ return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
79
60
  }
80
- registerContractFunctionSignatures(_address, _signatures) {
81
- return Promise.resolve();
61
+ async getDebugFunctionName(address, selector) {
62
+ return await this.contractStore.getDebugFunctionName(address, selector);
82
63
  }
83
- // TODO(#10007): Remove this method.
84
- addContractClass(_contractClass) {
85
- // We don't really need to do anything for the txe here
64
+ registerContractFunctionSignatures(_signatures) {
86
65
  return Promise.resolve();
87
66
  }
88
67
  }
@@ -0,0 +1,28 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { L2Block } from '@aztec/stdlib/block';
4
+ import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
5
+ import { BlockHeader, 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<BlockHeader>;
14
+ /**
15
+ * Creates an L2Block with proper archive chaining.
16
+ * This function:
17
+ * 1. Gets the current archive state as lastArchive for the header
18
+ * 2. Creates the block header
19
+ * 3. Updates the archive tree with the header hash
20
+ * 4. Gets the new archive state for the block's archive
21
+ *
22
+ * @param worldTrees - The world trees to read/write from
23
+ * @param globalVariables - Global variables for the block
24
+ * @param txEffects - Transaction effects to include in the block
25
+ * @returns The created L2Block with proper archive chaining
26
+ */
27
+ export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQ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AAO,EAAQ,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAelB"}
@@ -0,0 +1,56 @@
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';
3
+ import { padArrayEnd } from '@aztec/foundation/collection';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { Body, L2Block } from '@aztec/stdlib/block';
6
+ import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
7
+ import { BlockHeader } from '@aztec/stdlib/tx';
8
+ /**
9
+ * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
10
+ * @param blockNumber The number for the block in which there is a single transaction.
11
+ * @returns The transaction request hash.
12
+ */ export function getSingleTxBlockRequestHash(blockNumber) {
13
+ return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
14
+ }
15
+ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
16
+ await worldTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
17
+ await worldTrees.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((nullifier)=>nullifier.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
18
+ await worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(txEffect.l2ToL1Msgs, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
19
+ // We do not need to add public data writes because we apply them as we go.
20
+ }
21
+ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
22
+ const stateReference = await worldTrees.getStateReference();
23
+ const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
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
+ });
32
+ }
33
+ /**
34
+ * Creates an L2Block with proper archive chaining.
35
+ * This function:
36
+ * 1. Gets the current archive state as lastArchive for the header
37
+ * 2. Creates the block header
38
+ * 3. Updates the archive tree with the header hash
39
+ * 4. Gets the new archive state for the block's archive
40
+ *
41
+ * @param worldTrees - The world trees to read/write from
42
+ * @param globalVariables - Global variables for the block
43
+ * @param txEffects - Transaction effects to include in the block
44
+ * @returns The created L2Block with proper archive chaining
45
+ */ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
46
+ const header = await makeTXEBlockHeader(worldTrees, globalVariables);
47
+ // Update the archive tree with this block's header hash
48
+ await worldTrees.updateArchive(header);
49
+ // Get the new archive state after updating
50
+ const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
51
+ const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
52
+ // L2Block requires checkpointNumber and indexWithinCheckpoint
53
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
54
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
55
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
56
+ }
@@ -0,0 +1,5 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
3
+ import { TxEffect } from '@aztec/stdlib/tx';
4
+ export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRS9ELE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUVwRCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0F1Qi9HIn0=
@@ -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;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"}
@@ -0,0 +1,13 @@
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, txBlockNumber) {
5
+ const txEffect = TxEffect.empty();
6
+ noteCache.finish();
7
+ const nonceGenerator = noteCache.getNonceGenerator();
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
+ txEffect.txHash = new TxHash(new Fr(txBlockNumber));
12
+ return txEffect;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "0.0.0-test.1",
3
+ "version": "0.0.1-commit.023c3e5",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "bin": "./dest/bin/index.js",
@@ -12,13 +12,11 @@
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
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
19
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
20
18
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
21
- "dev": "LOG_LEVEL=debug node ./dest/bin/index.js",
19
+ "dev": "LOG_LEVEL=\"debug; trace: simulator:state_manager; info: json-rpc:proxy\" node ./dest/bin/index.js",
22
20
  "start": "node --no-warnings ./dest/bin/index.js"
23
21
  },
24
22
  "inherits": [
@@ -56,30 +54,38 @@
56
54
  "testTimeout": 120000,
57
55
  "setupFiles": [
58
56
  "../../foundation/src/jest/setup.mjs"
57
+ ],
58
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
59
+ "setupFilesAfterEnv": [
60
+ "../../foundation/src/jest/setupAfterEnv.mjs"
59
61
  ]
60
62
  },
61
63
  "dependencies": {
62
- "@aztec/accounts": "0.0.0-test.1",
63
- "@aztec/aztec.js": "0.0.0-test.1",
64
- "@aztec/constants": "0.0.0-test.1",
65
- "@aztec/foundation": "0.0.0-test.1",
66
- "@aztec/key-store": "0.0.0-test.1",
67
- "@aztec/kv-store": "0.0.0-test.1",
68
- "@aztec/protocol-contracts": "0.0.0-test.1",
69
- "@aztec/pxe": "0.0.0-test.1",
70
- "@aztec/simulator": "0.0.0-test.1",
71
- "@aztec/stdlib": "0.0.0-test.1",
72
- "@aztec/world-state": "0.0.0-test.1",
64
+ "@aztec/accounts": "0.0.1-commit.023c3e5",
65
+ "@aztec/archiver": "0.0.1-commit.023c3e5",
66
+ "@aztec/aztec-node": "0.0.1-commit.023c3e5",
67
+ "@aztec/aztec.js": "0.0.1-commit.023c3e5",
68
+ "@aztec/bb-prover": "0.0.1-commit.023c3e5",
69
+ "@aztec/constants": "0.0.1-commit.023c3e5",
70
+ "@aztec/foundation": "0.0.1-commit.023c3e5",
71
+ "@aztec/key-store": "0.0.1-commit.023c3e5",
72
+ "@aztec/kv-store": "0.0.1-commit.023c3e5",
73
+ "@aztec/protocol-contracts": "0.0.1-commit.023c3e5",
74
+ "@aztec/pxe": "0.0.1-commit.023c3e5",
75
+ "@aztec/simulator": "0.0.1-commit.023c3e5",
76
+ "@aztec/stdlib": "0.0.1-commit.023c3e5",
77
+ "@aztec/world-state": "0.0.1-commit.023c3e5",
73
78
  "zod": "^3.23.8"
74
79
  },
75
80
  "devDependencies": {
76
- "@jest/globals": "^29.5.0",
77
- "@types/jest": "^29.5.0",
78
- "@types/node": "^18.7.23",
79
- "jest": "^29.5.0",
80
- "jest-mock-extended": "^3.0.3",
81
+ "@jest/globals": "^30.0.0",
82
+ "@types/jest": "^30.0.0",
83
+ "@types/node": "^22.15.17",
84
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
85
+ "jest": "^30.0.0",
86
+ "jest-mock-extended": "^4.0.0",
81
87
  "ts-node": "^10.9.1",
82
- "typescript": "^5.0.4"
88
+ "typescript": "^5.3.3"
83
89
  },
84
90
  "files": [
85
91
  "dest",
@@ -88,6 +94,6 @@
88
94
  ],
89
95
  "types": "./dest/index.d.ts",
90
96
  "engines": {
91
- "node": ">=18"
97
+ "node": ">=20.10"
92
98
  }
93
99
  }
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';
@@ -20,11 +20,12 @@ async function main() {
20
20
  process.exit(0);
21
21
  });
22
22
 
23
- const logger = createLogger('txe:service');
23
+ const logger = createLogger('txe:rpc');
24
24
  logger.info(`Setting up TXE...`);
25
25
 
26
26
  const txeServer = createTXERpcServer(logger);
27
27
  const { port } = await startHttpRpcServer(txeServer, {
28
+ host: '127.0.0.1',
28
29
  port: TXE_PORT,
29
30
  timeoutMs: 1e3 * 60 * 5,
30
31
  });
@@ -0,0 +1,3 @@
1
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+
3
+ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);