@aztec/pxe 0.81.0 → 0.82.0

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 (72) hide show
  1. package/dest/config/package_info.js +1 -1
  2. package/dest/entrypoints/server/utils.d.ts +15 -7
  3. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  4. package/dest/entrypoints/server/utils.js +17 -9
  5. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
  6. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  7. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  8. package/dest/private_kernel/index.d.ts +3 -0
  9. package/dest/private_kernel/index.d.ts.map +1 -0
  10. package/dest/private_kernel/index.js +2 -0
  11. package/dest/{kernel_prover/kernel_prover.d.ts → private_kernel/private_kernel_execution_prover.d.ts} +13 -14
  12. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  13. package/dest/{kernel_prover/kernel_prover.js → private_kernel/private_kernel_execution_prover.js} +64 -64
  14. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  15. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  16. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  17. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +5 -5
  18. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  19. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +2 -2
  20. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -16
  21. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
  22. package/dest/pxe_oracle_interface/pxe_oracle_interface.js +11 -32
  23. package/dest/pxe_service/pxe_service.d.ts +13 -27
  24. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  25. package/dest/pxe_service/pxe_service.js +207 -235
  26. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -2
  27. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  28. package/dest/storage/contract_data_provider/contract_data_provider.js +6 -1
  29. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -2
  30. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  31. package/dest/storage/index.d.ts +1 -2
  32. package/dest/storage/index.d.ts.map +1 -1
  33. package/dest/storage/index.js +1 -2
  34. package/dest/storage/metadata.d.ts +2 -0
  35. package/dest/storage/metadata.d.ts.map +1 -0
  36. package/dest/storage/metadata.js +1 -0
  37. package/package.json +15 -15
  38. package/src/config/package_info.ts +1 -1
  39. package/src/entrypoints/server/utils.ts +25 -11
  40. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +4 -4
  41. package/src/private_kernel/index.ts +2 -0
  42. package/src/{kernel_prover/kernel_prover.ts → private_kernel/private_kernel_execution_prover.ts} +76 -71
  43. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  44. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +6 -5
  45. package/src/pxe_oracle_interface/pxe_oracle_interface.ts +25 -40
  46. package/src/pxe_service/pxe_service.ts +279 -293
  47. package/src/storage/contract_data_provider/contract_data_provider.ts +11 -2
  48. package/src/storage/contract_data_provider/private_functions_tree.ts +2 -2
  49. package/src/storage/index.ts +1 -3
  50. package/src/storage/metadata.ts +1 -0
  51. package/dest/kernel_oracle/index.d.ts.map +0 -1
  52. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  53. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  54. package/dest/kernel_prover/index.d.ts +0 -3
  55. package/dest/kernel_prover/index.d.ts.map +0 -1
  56. package/dest/kernel_prover/index.js +0 -2
  57. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  58. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  59. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  60. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  61. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  62. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  63. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  64. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  65. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  66. package/src/kernel_prover/index.ts +0 -2
  67. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  68. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  69. /package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.js +0 -0
  70. /package/dest/{kernel_prover → private_kernel}/hints/index.d.ts +0 -0
  71. /package/dest/{kernel_prover → private_kernel}/hints/index.js +0 -0
  72. /package/src/{kernel_prover → private_kernel}/hints/index.ts +0 -0
@@ -114,7 +114,12 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
114
114
  * @returns The corresponding function's artifact as an object.
115
115
  */ async getFunctionArtifact(contractAddress, selector) {
116
116
  const tree = await this.getTreeForAddress(contractAddress);
117
- return tree.getFunctionArtifact(selector);
117
+ const contractArtifact = tree.getArtifact();
118
+ const functionArtifact = await tree.getFunctionArtifact(selector);
119
+ return {
120
+ ...functionArtifact,
121
+ contractName: contractArtifact.name
122
+ };
118
123
  }
119
124
  /**
120
125
  * Retrieves the artifact of a specified function within a given contract.
@@ -3,7 +3,7 @@
3
3
  import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
6
- import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
6
+ import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/stdlib/abi';
7
7
  import { type ContractClassWithId } from '@aztec/stdlib/contract';
8
8
  /**
9
9
  * Represents a Merkle tree of functions for a particular Contract Class.
@@ -25,7 +25,7 @@ export declare class PrivateFunctionsTree {
25
25
  * @param selector - The function selector.
26
26
  * @returns The artifact object containing relevant information about the targeted function.
27
27
  */
28
- getFunctionArtifact(selector: FunctionSelector): Promise<import("@aztec/stdlib/abi").FunctionArtifact>;
28
+ getFunctionArtifact(selector: FunctionSelector): Promise<FunctionArtifact>;
29
29
  /**
30
30
  * Retrieve the bytecode of a function in the contract by its function selector.
31
31
  * The function selector is a unique identifier for each function in a contract.
@@ -1 +1 @@
1
- {"version":3,"file":"private_functions_tree.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/private_functions_tree.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAGX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAoB,OAAO,CAAC,aAAa;IAFtF,OAAO,CAAC,IAAI,CAAC,CAAa;IAE1B,OAAO;WAEM,MAAM,CAAC,QAAQ,EAAE,gBAAgB;IAK9C;;;;;;;OAOG;IACU,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB;IAkB3D;;;;;;;OAOG;IACU,WAAW,CAAC,QAAQ,EAAE,gBAAgB;IAKnD;;;;;;OAMG;IACI,mBAAmB;IAI1B,yCAAyC;IAClC,gBAAgB;IAIvB,qCAAqC;IAC9B,WAAW;IAIlB;;OAEG;IACI,kBAAkB;IAIzB;;;;;;;;OAQG;IACU,4BAA4B,CACvC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC;YAiB5C,OAAO;CAOtB"}
1
+ {"version":3,"file":"private_functions_tree.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/private_functions_tree.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAGX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAoB,OAAO,CAAC,aAAa;IAFtF,OAAO,CAAC,IAAI,CAAC,CAAa;IAE1B,OAAO;WAEM,MAAM,CAAC,QAAQ,EAAE,gBAAgB;IAK9C;;;;;;;OAOG;IACU,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkBvF;;;;;;;OAOG;IACU,WAAW,CAAC,QAAQ,EAAE,gBAAgB;IAKnD;;;;;;OAMG;IACI,mBAAmB;IAI1B,yCAAyC;IAClC,gBAAgB;IAIvB,qCAAqC;IAC9B,WAAW;IAIlB;;OAEG;IACI,kBAAkB;IAIzB;;;;;;;;OAQG;IACU,4BAA4B,CACvC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC;YAiB5C,OAAO;CAOtB"}
@@ -1,10 +1,9 @@
1
1
  export * from './address_data_provider/index.js';
2
- export * from './auth_witness_data_provider/index.js';
3
2
  export * from './capsule_data_provider/index.js';
4
3
  export * from './contract_data_provider/index.js';
5
4
  export * from './note_data_provider/index.js';
6
5
  export * from './sync_data_provider/index.js';
7
6
  export * from './tagging_data_provider/index.js';
8
7
  export * from './data_provider.js';
9
- export declare const PXE_DATA_SCHEMA_VERSION = 2;
8
+ export * from './metadata.js';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AAEnC,eAAO,MAAM,uBAAuB,IAAI,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
@@ -1,9 +1,8 @@
1
1
  export * from './address_data_provider/index.js';
2
- export * from './auth_witness_data_provider/index.js';
3
2
  export * from './capsule_data_provider/index.js';
4
3
  export * from './contract_data_provider/index.js';
5
4
  export * from './note_data_provider/index.js';
6
5
  export * from './sync_data_provider/index.js';
7
6
  export * from './tagging_data_provider/index.js';
8
7
  export * from './data_provider.js';
9
- export const PXE_DATA_SCHEMA_VERSION = 2;
8
+ export * from './metadata.js';
@@ -0,0 +1,2 @@
1
+ export declare const PXE_DATA_SCHEMA_VERSION = 2;
2
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/storage/metadata.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export const PXE_DATA_SCHEMA_VERSION = 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.81.0",
3
+ "version": "0.82.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/entrypoints/server/index.js",
@@ -59,19 +59,19 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@aztec/bb-prover": "0.81.0",
63
- "@aztec/bb.js": "0.81.0",
64
- "@aztec/builder": "0.81.0",
65
- "@aztec/constants": "0.81.0",
66
- "@aztec/ethereum": "0.81.0",
67
- "@aztec/foundation": "0.81.0",
68
- "@aztec/key-store": "0.81.0",
69
- "@aztec/kv-store": "0.81.0",
70
- "@aztec/noir-protocol-circuits-types": "0.81.0",
71
- "@aztec/noir-types": "0.81.0",
72
- "@aztec/protocol-contracts": "0.81.0",
73
- "@aztec/simulator": "0.81.0",
74
- "@aztec/stdlib": "0.81.0",
62
+ "@aztec/bb-prover": "0.82.0",
63
+ "@aztec/bb.js": "0.82.0",
64
+ "@aztec/builder": "0.82.0",
65
+ "@aztec/constants": "0.82.0",
66
+ "@aztec/ethereum": "0.82.0",
67
+ "@aztec/foundation": "0.82.0",
68
+ "@aztec/key-store": "0.82.0",
69
+ "@aztec/kv-store": "0.82.0",
70
+ "@aztec/noir-protocol-circuits-types": "0.82.0",
71
+ "@aztec/noir-types": "0.82.0",
72
+ "@aztec/protocol-contracts": "0.82.0",
73
+ "@aztec/simulator": "0.82.0",
74
+ "@aztec/stdlib": "0.82.0",
75
75
  "@msgpack/msgpack": "^3.0.0-beta2",
76
76
  "koa": "^2.14.2",
77
77
  "koa-router": "^12.0.0",
@@ -81,7 +81,7 @@
81
81
  "viem": "2.23.7"
82
82
  },
83
83
  "devDependencies": {
84
- "@aztec/noir-contracts.js": "0.81.0",
84
+ "@aztec/noir-contracts.js": "0.82.0",
85
85
  "@jest/globals": "^29.5.0",
86
86
  "@types/jest": "^29.5.0",
87
87
  "@types/lodash.omit": "^4.5.7",
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '0.1.0', name: '@aztec/pxe' };
2
+ return { version: '0.82.0', name: '@aztec/pxe' };
3
3
  }
@@ -5,28 +5,43 @@ import { createLogger } from '@aztec/foundation/log';
5
5
  import { createStore } from '@aztec/kv-store/lmdb-v2';
6
6
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
7
7
  import { type SimulationProvider, WASMSimulator } from '@aztec/simulator/client';
8
- import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
8
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
9
9
 
10
10
  import type { PXEServiceConfig } from '../../config/index.js';
11
11
  import { PXEService } from '../../pxe_service/pxe_service.js';
12
- import { PXE_DATA_SCHEMA_VERSION } from './index.js';
12
+ import { PXE_DATA_SCHEMA_VERSION } from '../../storage/index.js';
13
13
 
14
14
  /**
15
- * Create and start an PXEService instance with the given AztecNode.
16
- * If no keyStore or database is provided, it will use KeyStore and MemoryDB as default values.
17
- * Returns a Promise that resolves to the started PXEService instance.
15
+ * Create and start an PXEService instance with the given AztecNode and config.
18
16
  *
19
17
  * @param aztecNode - The AztecNode instance to be used by the server.
20
18
  * @param config - The PXE Service Config to use
21
- * @param useLogSuffix - (Optional) Log suffix for PXE's logger.
22
- * @param proofCreator - An optional proof creator to use in place of any other configuration
19
+ * @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
23
20
  * @returns A Promise that resolves to the started PXEService instance.
24
21
  */
25
- export async function createPXEService(
22
+ export function createPXEService(
26
23
  aztecNode: AztecNode,
27
24
  config: PXEServiceConfig,
28
25
  useLogSuffix: string | boolean | undefined = undefined,
29
- proofCreator?: PrivateKernelProver,
26
+ ) {
27
+ const simulationProvider = new WASMSimulator();
28
+ return createPXEServiceWithSimulationProvider(aztecNode, simulationProvider, config, useLogSuffix);
29
+ }
30
+
31
+ /**
32
+ * Create and start an PXEService instance with the given AztecNode, SimulationProvider and config.
33
+ *
34
+ * @param aztecNode - The AztecNode instance to be used by the server.
35
+ * @param simulationProvider - The SimulationProvider to use
36
+ * @param config - The PXE Service Config to use
37
+ * @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
38
+ * @returns A Promise that resolves to the started PXEService instance.
39
+ */
40
+ export async function createPXEServiceWithSimulationProvider(
41
+ aztecNode: AztecNode,
42
+ simulationProvider: SimulationProvider,
43
+ config: PXEServiceConfig,
44
+ useLogSuffix: string | boolean | undefined = undefined,
30
45
  ) {
31
46
  const logSuffix =
32
47
  typeof useLogSuffix === 'boolean' ? (useLogSuffix ? randomBytes(3).toString('hex') : undefined) : useLogSuffix;
@@ -44,8 +59,7 @@ export async function createPXEService(
44
59
  createLogger('pxe:data:lmdb'),
45
60
  );
46
61
 
47
- const simulationProvider = new WASMSimulator();
48
- const prover = proofCreator ?? (await createProver(config, simulationProvider, logSuffix));
62
+ const prover = await createProver(config, simulationProvider, logSuffix);
49
63
  const protocolContractsProvider = new BundledProtocolContractsProvider();
50
64
  const pxe = await PXEService.create(
51
65
  aztecNode,
@@ -43,7 +43,7 @@ import {
43
43
  } from '@aztec/stdlib/kernel';
44
44
  import { type PrivateCallExecutionResult, collectNested } from '@aztec/stdlib/tx';
45
45
 
46
- import type { ProvingDataOracle } from '../proving_data_oracle.js';
46
+ import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
47
47
 
48
48
  function collectNestedReadRequests(
49
49
  executionStack: PrivateCallExecutionResult[],
@@ -57,7 +57,7 @@ function collectNestedReadRequests(
57
57
  });
58
58
  }
59
59
 
60
- function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) {
60
+ function getNullifierMembershipWitnessResolver(oracle: PrivateKernelOracle) {
61
61
  return async (nullifier: Fr) => {
62
62
  const res = await oracle.getNullifierMembershipWitness(nullifier);
63
63
  if (!res) {
@@ -74,7 +74,7 @@ function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) {
74
74
 
75
75
  async function getMasterSecretKeysAndAppKeyGenerators(
76
76
  keyValidationRequests: Tuple<ScopedKeyValidationRequestAndGenerator, typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX>,
77
- oracle: ProvingDataOracle,
77
+ oracle: PrivateKernelOracle,
78
78
  ) {
79
79
  const keysHints = [];
80
80
  for (let i = 0; i < keyValidationRequests.length; ++i) {
@@ -144,7 +144,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
144
144
  }
145
145
  }
146
146
 
147
- async build(oracle: ProvingDataOracle, noteHashLeafIndexMap: Map<bigint, bigint>) {
147
+ async build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>) {
148
148
  if (privateKernelResetDimensionNames.every(name => !this.requestedDimensions[name])) {
149
149
  throw new Error('Reset is not required.');
150
150
  }
@@ -0,0 +1,2 @@
1
+ export * from './private_kernel_execution_prover.js';
2
+ export * from './private_kernel_oracle.js';
@@ -6,7 +6,6 @@ import { assertLength } from '@aztec/foundation/serialize';
6
6
  import { pushTestData } from '@aztec/foundation/testing';
7
7
  import { Timer } from '@aztec/foundation/timer';
8
8
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
9
- import type { WitnessMap } from '@aztec/noir-types';
10
9
  import { getProtocolContractLeafAndMembershipWitness, protocolContractTreeRoot } from '@aztec/protocol-contracts';
11
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
11
  import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
@@ -14,8 +13,10 @@ import { hashVK } from '@aztec/stdlib/hash';
14
13
  import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
15
14
  import {
16
15
  PrivateCallData,
16
+ type PrivateExecutionStep,
17
17
  PrivateKernelCircuitPublicInputs,
18
18
  PrivateKernelData,
19
+ type PrivateKernelExecutionProofOutput,
19
20
  PrivateKernelInitCircuitPrivateInputs,
20
21
  PrivateKernelInnerCircuitPrivateInputs,
21
22
  type PrivateKernelSimulateOutput,
@@ -37,32 +38,32 @@ import {
37
38
  import { VerificationKeyAsFields } from '@aztec/stdlib/vks';
38
39
 
39
40
  import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
40
- import type { ProvingDataOracle } from './proving_data_oracle.js';
41
+ import type { PrivateKernelOracle } from './private_kernel_oracle.js';
41
42
 
42
- const NULL_PROVE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
43
+ const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
43
44
  publicInputs: PrivateKernelCircuitPublicInputs.empty(),
44
45
  verificationKey: VerificationKeyAsFields.makeEmpty(CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS),
45
46
  outputWitness: new Map(),
46
47
  bytecode: Buffer.from([]),
47
48
  };
48
49
 
49
- export type ProvingConfig = {
50
+ export interface PrivateKernelExecutionProverConfig {
50
51
  simulate: boolean;
51
52
  skipFeeEnforcement: boolean;
52
- profile: boolean;
53
- };
53
+ profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
54
+ }
54
55
 
55
56
  /**
56
- * The KernelProver class is responsible for generating kernel proofs.
57
- * It takes a transaction request, its signature, and the simulation result as inputs, and outputs a proof
58
- * along with output notes. The class interacts with a ProvingDataOracle to fetch membership witnesses and
59
- * constructs private call data based on the execution results.
57
+ * The PrivateKernelSequencer class is responsible for taking a transaction request and sequencing the
58
+ * the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
59
+ * The result can be a client IVC proof of the private transaction portion, or just a simulation that can e.g.
60
+ * inform state tree updates.
60
61
  */
61
- export class KernelProver {
62
- private log = createLogger('pxe:kernel-prover');
62
+ export class PrivateKernelExecutionProver {
63
+ private log = createLogger('pxe:private-kernel-execution-prover');
63
64
 
64
65
  constructor(
65
- private oracle: ProvingDataOracle,
66
+ private oracle: PrivateKernelOracle,
66
67
  private proofCreator: PrivateKernelProver,
67
68
  private fakeProofs = false,
68
69
  ) {}
@@ -77,19 +78,18 @@ export class KernelProver {
77
78
  * @param executionResult - The execution result object containing nested executions and preimages.
78
79
  * @param profile - Set true to profile the gate count for each circuit
79
80
  * @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
80
- * TODO(#7368) this should be refactored to not recreate the ACIR bytecode now that it operates on a program stack
81
81
  */
82
- async prove(
82
+ async proveWithKernels(
83
83
  txRequest: TxRequest,
84
84
  executionResult: PrivateExecutionResult,
85
- { simulate, skipFeeEnforcement, profile }: ProvingConfig = {
85
+ { simulate, skipFeeEnforcement, profileMode }: PrivateKernelExecutionProverConfig = {
86
86
  simulate: false,
87
87
  skipFeeEnforcement: false,
88
- profile: false,
88
+ profileMode: 'none',
89
89
  },
90
- ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
90
+ ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
91
91
  const skipProofGeneration = this.fakeProofs || simulate;
92
- const generateWitnesses = !skipProofGeneration || profile;
92
+ const generateWitnesses = !skipProofGeneration || profileMode !== 'none';
93
93
 
94
94
  const timer = new Timer();
95
95
 
@@ -98,15 +98,9 @@ export class KernelProver {
98
98
  const executionStack = [executionResult.entrypoint];
99
99
  let firstIteration = true;
100
100
 
101
- let output = NULL_PROVE_OUTPUT;
101
+ let output = NULL_SIMULATE_OUTPUT;
102
102
 
103
- const gateCounts: { circuitName: string; gateCount: number }[] = [];
104
- const addGateCount = async (circuitName: string, bytecode: Buffer) => {
105
- const gateCount = (await this.proofCreator.computeGateCountForCircuit(bytecode, circuitName)) as number;
106
- gateCounts.push({ circuitName, gateCount });
107
-
108
- this.log.debug(`Gate count for ${circuitName} - ${gateCount}`);
109
- };
103
+ const executionSteps: PrivateExecutionStep[] = [];
110
104
 
111
105
  const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
112
106
  const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
@@ -114,9 +108,6 @@ export class KernelProver {
114
108
  const hasPublicCalls =
115
109
  enqueuedPublicFunctions.length > 0 || !collectPublicTeardownFunctionCall(executionResult).isEmpty();
116
110
  const validationRequestsSplitCounter = hasPublicCalls ? getFinalMinRevertibleSideEffectCounter(executionResult) : 0;
117
- // vector of gzipped bincode acirs
118
- const acirs: Buffer[] = [];
119
- const witnessStack: WitnessMap[] = [];
120
111
 
121
112
  while (executionStack.length) {
122
113
  if (!firstIteration) {
@@ -128,16 +119,14 @@ export class KernelProver {
128
119
  );
129
120
  while (resetBuilder.needsReset()) {
130
121
  const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
131
- output = generateWitnesses
132
- ? await this.proofCreator.generateResetOutput(privateInputs)
133
- : await this.proofCreator.simulateReset(privateInputs);
134
- // TODO(#7368) consider refactoring this redundant bytecode pushing
135
- acirs.push(output.bytecode);
136
- witnessStack.push(output.outputWitness);
137
- if (profile) {
138
- await addGateCount('private_kernel_reset', output.bytecode);
139
- }
140
-
122
+ output = simulate
123
+ ? await this.proofCreator.simulateReset(privateInputs)
124
+ : await this.proofCreator.generateResetOutput(privateInputs);
125
+ executionSteps.push({
126
+ functionName: 'private_kernel_reset',
127
+ bytecode: output.bytecode,
128
+ witness: output.outputWitness,
129
+ });
141
130
  resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
142
131
  output,
143
132
  executionStack,
@@ -156,13 +145,11 @@ export class KernelProver {
156
145
  currentExecution.publicInputs.callContext.functionSelector,
157
146
  );
158
147
 
159
- // TODO(#7368): This used to be associated with getDebugFunctionName
160
- // TODO(#7368): Is there any way to use this with client IVC proving?
161
- acirs.push(currentExecution.acir);
162
- witnessStack.push(currentExecution.partialWitness);
163
- if (profile) {
164
- await addGateCount(functionName as string, currentExecution.acir);
165
- }
148
+ executionSteps.push({
149
+ functionName: functionName!,
150
+ bytecode: currentExecution.acir,
151
+ witness: currentExecution.partialWitness,
152
+ });
166
153
 
167
154
  const privateCallData = await this.createPrivateCallData(currentExecution);
168
155
 
@@ -185,11 +172,11 @@ export class KernelProver {
185
172
  ? await this.proofCreator.generateInitOutput(proofInput)
186
173
  : await this.proofCreator.simulateInit(proofInput);
187
174
 
188
- acirs.push(output.bytecode);
189
- witnessStack.push(output.outputWitness);
190
- if (profile) {
191
- await addGateCount('private_kernel_init', output.bytecode);
192
- }
175
+ executionSteps.push({
176
+ functionName: 'private_kernel_init',
177
+ bytecode: output.bytecode,
178
+ witness: output.outputWitness,
179
+ });
193
180
  } else {
194
181
  const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
195
182
  const previousKernelData = new PrivateKernelData(
@@ -206,11 +193,11 @@ export class KernelProver {
206
193
  ? await this.proofCreator.generateInnerOutput(proofInput)
207
194
  : await this.proofCreator.simulateInner(proofInput);
208
195
 
209
- acirs.push(output.bytecode);
210
- witnessStack.push(output.outputWitness);
211
- if (profile) {
212
- await addGateCount('private_kernel_inner', output.bytecode);
213
- }
196
+ executionSteps.push({
197
+ functionName: 'private_kernel_inner',
198
+ bytecode: output.bytecode,
199
+ witness: output.outputWitness,
200
+ });
214
201
  }
215
202
  firstIteration = false;
216
203
  }
@@ -228,11 +215,11 @@ export class KernelProver {
228
215
  ? await this.proofCreator.generateResetOutput(privateInputs)
229
216
  : await this.proofCreator.simulateReset(privateInputs);
230
217
 
231
- acirs.push(output.bytecode);
232
- witnessStack.push(output.outputWitness);
233
- if (profile) {
234
- await addGateCount('private_kernel_reset', output.bytecode);
235
- }
218
+ executionSteps.push({
219
+ functionName: 'private_kernel_reset',
220
+ bytecode: output.bytecode,
221
+ witness: output.outputWitness,
222
+ });
236
223
 
237
224
  resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
238
225
  output,
@@ -269,26 +256,44 @@ export class KernelProver {
269
256
  ? await this.proofCreator.generateTailOutput(privateInputs)
270
257
  : await this.proofCreator.simulateTail(privateInputs);
271
258
 
272
- acirs.push(tailOutput.bytecode);
273
- witnessStack.push(tailOutput.outputWitness);
274
- if (profile) {
275
- await addGateCount('private_kernel_tail', tailOutput.bytecode);
276
- tailOutput.profileResult = { gateCounts };
259
+ executionSteps.push({
260
+ functionName: 'private_kernel_tail',
261
+ bytecode: tailOutput.bytecode,
262
+ witness: tailOutput.outputWitness,
263
+ });
264
+
265
+ if (profileMode == 'gates' || profileMode == 'full') {
266
+ for (const entry of executionSteps) {
267
+ const gateCount = await this.proofCreator.computeGateCountForCircuit(entry.bytecode, entry.functionName);
268
+ entry.gateCount = gateCount;
269
+ }
270
+ }
271
+ if (profileMode === 'gates') {
272
+ for (const entry of executionSteps) {
273
+ // These buffers are often a few megabytes in size - prevent accidentally serializing them if not requested.
274
+ entry.bytecode = Buffer.from([]);
275
+ entry.witness = new Map();
276
+ }
277
277
  }
278
278
 
279
279
  if (generateWitnesses) {
280
280
  this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
281
281
  }
282
282
 
283
+ let clientIvcProof: ClientIvcProof;
283
284
  // TODO(#7368) how do we 'bincode' encode these inputs?
284
285
  if (!skipProofGeneration) {
285
- const ivcProof = await this.proofCreator.createClientIvcProof(acirs, witnessStack);
286
- tailOutput.clientIvcProof = ivcProof;
286
+ clientIvcProof = await this.proofCreator.createClientIvcProof(executionSteps);
287
287
  } else {
288
- tailOutput.clientIvcProof = ClientIvcProof.random();
288
+ clientIvcProof = ClientIvcProof.random();
289
289
  }
290
290
 
291
- return tailOutput;
291
+ return {
292
+ publicInputs: tailOutput.publicInputs,
293
+ executionSteps,
294
+ clientIvcProof,
295
+ verificationKey: tailOutput.verificationKey,
296
+ };
292
297
  }
293
298
 
294
299
  private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult) {
@@ -1,6 +1,6 @@
1
- import type { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
3
- import type { MembershipWitness } from '@aztec/foundation/trees';
3
+ import { MembershipWitness } from '@aztec/foundation/trees';
4
4
  import type { FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
@@ -9,10 +9,10 @@ import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
9
9
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
10
10
 
11
11
  /**
12
- * Provides functionality to fetch membership witnesses for verification keys,
13
- * contract addresses, and function selectors in their respective merkle trees.
12
+ * Provides functionality needed by the private kernel for interacting with our state trees.
13
+ * This is either PrivateKernelOracleImpl, or a mocked test implementation.
14
14
  */
15
- export interface ProvingDataOracle {
15
+ export interface PrivateKernelOracle {
16
16
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
17
17
  getContractAddressPreimage(address: AztecAddress): Promise<{
18
18
  saltedInitializationHash: Fr;
@@ -27,13 +27,7 @@ export interface ProvingDataOracle {
27
27
  ): Promise<{ artifactHash: Fr; publicBytecodeCommitment: Fr; privateFunctionsRoot: Fr }>;
28
28
 
29
29
  /**
30
- * Retrieve the function membership witness for the given contract class and function selector.
31
- * The function membership witness represents a proof that the function belongs to the specified contract.
32
- * Throws an error if the contract address or function selector is unknown.
33
- *
34
- * @param contractClassId - The id of the class.
35
- * @param selector - The function selector.
36
- * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
30
+ * Returns a membership witness with the sibling path and leaf index in our private functions tree.
37
31
  */
38
32
  getFunctionMembershipWitness(
39
33
  contractClassId: Fr,
@@ -41,30 +35,21 @@ export interface ProvingDataOracle {
41
35
  ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
42
36
 
43
37
  /**
44
- * Retrieve the membership witness corresponding to a verification key.
45
- * This function currently returns a random membership witness of the specified height,
46
- * which is a placeholder implementation until a concrete membership witness calculation
47
- * is implemented.
48
- *
49
- * @param vk - The VerificationKey for which the membership witness is needed.
50
- * @returns A Promise that resolves to the MembershipWitness instance.
38
+ * Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
39
+ * Used to validate the previous kernel's verification key.
51
40
  */
52
41
  getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
53
42
 
54
43
  /**
55
- * Get the note membership witness for a note in the note hash tree at the given leaf index.
56
- *
57
- * @param leafIndex - The leaf index of the note in the note hash tree.
58
- * @returns the MembershipWitness for the note.
59
- */
60
- getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
44
+ * Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
45
+ */ getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
61
46
 
47
+ /**
48
+ * Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
49
+ */
62
50
  getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
63
-
64
51
  /**
65
- * Get the root of the note hash tree.
66
- *
67
- * @returns the root of the note hash tree.
52
+ * Returns the root of our note hash merkle tree.
68
53
  */
69
54
  getNoteHashTreeRoot(): Promise<Fr>;
70
55
 
@@ -77,7 +62,10 @@ export interface ProvingDataOracle {
77
62
  */
78
63
  getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
79
64
 
65
+ /** Use debug data to get the function name corresponding to a selector. */
80
66
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
81
67
 
68
+ /** Returns a membership witness and leaf index to our public data indexed merkle tree,
69
+ * along with an associated SharedMutable containing the class ID to update. */
82
70
  getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
83
71
  }
@@ -1,4 +1,4 @@
1
- import { type NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import type { Tuple } from '@aztec/foundation/serialize';
@@ -17,15 +17,16 @@ import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/
17
17
  import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
18
18
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
19
19
 
20
- import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
21
- import type { ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js';
20
+ import type { ContractDataProvider } from '../storage/index.js';
21
+ import type { PrivateKernelOracle } from './private_kernel_oracle.js';
22
22
 
23
23
  // TODO: Block number should not be "latest".
24
24
  // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
25
25
  /**
26
26
  * A data oracle that provides information needed for simulating a transaction.
27
27
  */
28
- export class KernelOracle implements ProvingDataOracle {
28
+
29
+ export class PrivateKernelOracleImpl implements PrivateKernelOracle {
29
30
  constructor(
30
31
  private contractDataProvider: ContractDataProvider,
31
32
  private keyStore: KeyStore,
@@ -94,7 +95,7 @@ export class KernelOracle implements ProvingDataOracle {
94
95
  ProtocolContractAddress.ContractInstanceDeployer,
95
96
  sharedMutableHashSlot,
96
97
  );
97
- const updatedClassIdWitness = await this.node.getPublicDataTreeWitness(this.blockNumber, hashLeafSlot);
98
+ const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
98
99
 
99
100
  if (!updatedClassIdWitness) {
100
101
  throw new Error(`No public data tree witness found for ${hashLeafSlot}`);