@aztec/stdlib 0.82.0 → 0.82.1-alpha-testnet.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 (76) hide show
  1. package/dest/avm/avm.d.ts +24 -48
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm_circuit_public_inputs.d.ts +18 -36
  4. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  5. package/dest/avm/avm_proving_request.d.ts +27 -54
  6. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  7. package/dest/contract/contract_class.d.ts.map +1 -1
  8. package/dest/contract/contract_class.js +3 -21
  9. package/dest/contract/interfaces/contract_class.d.ts +1 -143
  10. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  11. package/dest/contract/interfaces/contract_class.js +0 -5
  12. package/dest/contract/interfaces/contract_data_source.d.ts +3 -3
  13. package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
  14. package/dest/hash/hash.d.ts +8 -1
  15. package/dest/hash/hash.d.ts.map +1 -1
  16. package/dest/hash/hash.js +12 -1
  17. package/dest/interfaces/archiver.d.ts.map +1 -1
  18. package/dest/interfaces/archiver.js +1 -1
  19. package/dest/interfaces/prover-client.js +1 -1
  20. package/dest/interfaces/proving-job.d.ts +27 -54
  21. package/dest/interfaces/proving-job.d.ts.map +1 -1
  22. package/dest/kernel/public_call_request.d.ts +14 -19
  23. package/dest/kernel/public_call_request.d.ts.map +1 -1
  24. package/dest/kernel/public_call_request.js +19 -20
  25. package/dest/stats/stats.d.ts +1 -1
  26. package/dest/stats/stats.d.ts.map +1 -1
  27. package/dest/tests/factories.d.ts +2 -2
  28. package/dest/tests/factories.d.ts.map +1 -1
  29. package/dest/tests/factories.js +3 -13
  30. package/dest/tests/mocks.d.ts +3 -4
  31. package/dest/tests/mocks.d.ts.map +1 -1
  32. package/dest/tests/mocks.js +13 -48
  33. package/dest/tx/call_context.d.ts +1 -1
  34. package/dest/tx/hashed_values.d.ts +16 -4
  35. package/dest/tx/hashed_values.d.ts.map +1 -1
  36. package/dest/tx/hashed_values.js +26 -9
  37. package/dest/tx/index.d.ts +1 -1
  38. package/dest/tx/index.d.ts.map +1 -1
  39. package/dest/tx/index.js +1 -1
  40. package/dest/tx/private_execution_result.d.ts +6 -26
  41. package/dest/tx/private_execution_result.d.ts.map +1 -1
  42. package/dest/tx/private_execution_result.js +13 -70
  43. package/dest/tx/proven_tx.d.ts.map +1 -1
  44. package/dest/tx/proven_tx.js +2 -4
  45. package/dest/tx/public_call_request_with_calldata.d.ts +41 -0
  46. package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -0
  47. package/dest/tx/public_call_request_with_calldata.js +57 -0
  48. package/dest/tx/simulated_tx.d.ts.map +1 -1
  49. package/dest/tx/simulated_tx.js +2 -4
  50. package/dest/tx/tx.d.ts +16 -20
  51. package/dest/tx/tx.d.ts.map +1 -1
  52. package/dest/tx/tx.js +56 -42
  53. package/dest/tx/tx_execution_request.js +1 -1
  54. package/package.json +6 -6
  55. package/src/contract/contract_class.ts +7 -26
  56. package/src/contract/interfaces/contract_class.ts +2 -18
  57. package/src/contract/interfaces/contract_data_source.ts +3 -3
  58. package/src/hash/hash.ts +15 -1
  59. package/src/interfaces/archiver.ts +1 -4
  60. package/src/interfaces/prover-client.ts +1 -1
  61. package/src/kernel/public_call_request.ts +22 -27
  62. package/src/stats/stats.ts +1 -1
  63. package/src/tests/factories.ts +3 -24
  64. package/src/tests/mocks.ts +28 -80
  65. package/src/tx/hashed_values.ts +29 -9
  66. package/src/tx/index.ts +1 -1
  67. package/src/tx/private_execution_result.ts +9 -81
  68. package/src/tx/proven_tx.ts +2 -10
  69. package/src/tx/public_call_request_with_calldata.ts +72 -0
  70. package/src/tx/simulated_tx.ts +1 -6
  71. package/src/tx/tx.ts +57 -70
  72. package/src/tx/tx_execution_request.ts +1 -1
  73. package/dest/tx/public_execution_request.d.ts +0 -45
  74. package/dest/tx/public_execution_request.d.ts.map +0 -1
  75. package/dest/tx/public_execution_request.js +0 -72
  76. package/src/tx/public_execution_request.ts +0 -97
package/dest/tx/tx.js CHANGED
@@ -8,7 +8,8 @@ import { ContractClassLog } from '../logs/contract_class_log.js';
8
8
  import { Gossipable } from '../p2p/gossipable.js';
9
9
  import { TopicType, createTopicString } from '../p2p/topic_type.js';
10
10
  import { ClientIvcProof } from '../proofs/client_ivc_proof.js';
11
- import { PublicExecutionRequest } from './public_execution_request.js';
11
+ import { HashedValues } from './hashed_values.js';
12
+ import { PublicCallRequestWithCalldata } from './public_call_request_with_calldata.js';
12
13
  import { TxHash } from './tx_hash.js';
13
14
  /**
14
15
  * The interface of an L2 transaction.
@@ -16,25 +17,22 @@ import { TxHash } from './tx_hash.js';
16
17
  data;
17
18
  clientIvcProof;
18
19
  contractClassLogs;
19
- enqueuedPublicFunctionCalls;
20
- publicTeardownFunctionCall;
20
+ publicFunctionCalldata;
21
21
  static p2pTopic;
22
22
  // For memoization
23
23
  txHash;
24
+ calldataMap;
24
25
  constructor(/**
25
26
  * Output of the private kernel circuit for this tx.
26
27
  */ data, /**
27
28
  * Proof from the private kernel circuit.
28
29
  * TODO(#7368): This client IVC object currently contains various VKs that will eventually be more like static data.
29
- *
30
30
  */ clientIvcProof, /**
31
31
  * Contract class logs generated by the tx.
32
32
  */ contractClassLogs, /**
33
- * Enqueued public functions from the private circuit to be run by the sequencer.
34
- */ enqueuedPublicFunctionCalls, /**
35
- * Public function call to be run by the sequencer as part of teardown.
36
- */ publicTeardownFunctionCall){
37
- super(), this.data = data, this.clientIvcProof = clientIvcProof, this.contractClassLogs = contractClassLogs, this.enqueuedPublicFunctionCalls = enqueuedPublicFunctionCalls, this.publicTeardownFunctionCall = publicTeardownFunctionCall;
33
+ * An array of calldata for the enqueued public function calls and the teardown function call.
34
+ */ publicFunctionCalldata){
35
+ super(), this.data = data, this.clientIvcProof = clientIvcProof, this.contractClassLogs = contractClassLogs, this.publicFunctionCalldata = publicFunctionCalldata;
38
36
  }
39
37
  // Gossipable method
40
38
  static{
@@ -45,25 +43,34 @@ import { TxHash } from './tx_hash.js';
45
43
  return new Buffer32((await this.getTxHash()).toBuffer());
46
44
  }
47
45
  hasPublicCalls() {
48
- return this.data.numberOfPublicCallRequests() > 0;
46
+ return this.numberOfPublicCalls() > 0;
49
47
  }
50
- getNonRevertiblePublicExecutionRequests() {
51
- const numRevertible = this.data.numberOfRevertiblePublicCallRequests();
52
- return this.enqueuedPublicFunctionCalls.slice(numRevertible);
48
+ numberOfPublicCalls() {
49
+ return this.data.numberOfPublicCallRequests();
53
50
  }
54
- getRevertiblePublicExecutionRequests() {
55
- const numRevertible = this.data.numberOfRevertiblePublicCallRequests();
56
- return this.enqueuedPublicFunctionCalls.slice(0, numRevertible);
51
+ getNonRevertiblePublicCallRequestsWithCalldata() {
52
+ return this.data.getNonRevertiblePublicCallRequests().map((r)=>this.#combinePublicCallRequestWithCallData(r));
57
53
  }
58
- getPublicTeardownExecutionRequest() {
59
- return this.publicTeardownFunctionCall.isEmpty() ? undefined : this.publicTeardownFunctionCall;
54
+ getRevertiblePublicCallRequestsWithCalldata() {
55
+ return this.data.getRevertiblePublicCallRequests().map((r)=>this.#combinePublicCallRequestWithCallData(r));
60
56
  }
61
- getTotalPublicArgsCount() {
62
- let count = this.enqueuedPublicFunctionCalls.reduce((acc, execRequest)=>acc + execRequest.args.length, 0);
63
- if (!this.publicTeardownFunctionCall.isEmpty()) {
64
- count += this.publicTeardownFunctionCall.args.length;
65
- }
66
- return count;
57
+ getTeardownPublicCallRequestWithCalldata() {
58
+ const request = this.data.getTeardownPublicCallRequest();
59
+ return request ? this.#combinePublicCallRequestWithCallData(request) : undefined;
60
+ }
61
+ getPublicCallRequestsWithCalldata() {
62
+ const teardown = this.data.getTeardownPublicCallRequest();
63
+ const callRequests = [
64
+ ...this.data.getNonRevertiblePublicCallRequests(),
65
+ ...this.data.getRevertiblePublicCallRequests(),
66
+ ...teardown ? [
67
+ teardown
68
+ ] : []
69
+ ];
70
+ return callRequests.map((r)=>this.#combinePublicCallRequestWithCallData(r));
71
+ }
72
+ getTotalPublicCalldataCount() {
73
+ return this.publicFunctionCalldata.reduce((accum, cd)=>accum + cd.values.length, 0);
67
74
  }
68
75
  getGasSettings() {
69
76
  return this.data.constants.txContext.gasSettings;
@@ -74,10 +81,7 @@ import { TxHash } from './tx_hash.js';
74
81
  * @returns An instance of Tx.
75
82
  */ static fromBuffer(buffer) {
76
83
  const reader = BufferReader.asReader(buffer);
77
- return new Tx(reader.readObject(PrivateKernelTailCircuitPublicInputs), reader.readObject(ClientIvcProof), reader.readVectorUint8Prefix(ContractClassLog), reader.readVectorUint8Prefix(PublicExecutionRequest), reader.readObject(PublicExecutionRequest));
78
- }
79
- static newWithTxData(data, publicTeardownExecutionRequest) {
80
- return new Tx(data, ClientIvcProof.empty(), [], [], publicTeardownExecutionRequest ? publicTeardownExecutionRequest : PublicExecutionRequest.empty());
84
+ return new Tx(reader.readObject(PrivateKernelTailCircuitPublicInputs), reader.readObject(ClientIvcProof), reader.readVectorUint8Prefix(ContractClassLog), reader.readVectorUint8Prefix(HashedValues));
81
85
  }
82
86
  /**
83
87
  * Serializes the Tx object into a Buffer.
@@ -87,8 +91,7 @@ import { TxHash } from './tx_hash.js';
87
91
  this.data,
88
92
  this.clientIvcProof,
89
93
  serializeArrayOfBufferableToVector(this.contractClassLogs, 1),
90
- serializeArrayOfBufferableToVector(this.enqueuedPublicFunctionCalls, 1),
91
- this.publicTeardownFunctionCall
94
+ serializeArrayOfBufferableToVector(this.publicFunctionCalldata, 1)
92
95
  ]);
93
96
  }
94
97
  static get schema() {
@@ -96,12 +99,11 @@ import { TxHash } from './tx_hash.js';
96
99
  data: PrivateKernelTailCircuitPublicInputs.schema,
97
100
  clientIvcProof: ClientIvcProof.schema,
98
101
  contractClassLogs: z.array(ContractClassLog.schema),
99
- enqueuedPublicFunctionCalls: z.array(PublicExecutionRequest.schema),
100
- publicTeardownFunctionCall: PublicExecutionRequest.schema
102
+ publicFunctionCalldata: z.array(HashedValues.schema)
101
103
  }).transform(Tx.from);
102
104
  }
103
105
  static from(fields) {
104
- return new Tx(fields.data, fields.clientIvcProof, fields.contractClassLogs, fields.enqueuedPublicFunctionCalls, fields.publicTeardownFunctionCall);
106
+ return new Tx(fields.data, fields.clientIvcProof, fields.contractClassLogs, fields.publicFunctionCalldata);
105
107
  }
106
108
  /**
107
109
  * Gets public logs emitted by this tx.
@@ -158,6 +160,14 @@ import { TxHash } from './tx_hash.js';
158
160
  */ setTxHash(hash) {
159
161
  this.txHash = hash;
160
162
  }
163
+ getCalldataMap() {
164
+ if (!this.calldataMap) {
165
+ const calldataMap = new Map();
166
+ this.publicFunctionCalldata.forEach((cd)=>calldataMap.set(cd.hash.toString(), cd.values));
167
+ this.calldataMap = calldataMap;
168
+ }
169
+ return this.calldataMap;
170
+ }
161
171
  /** Returns stats about this tx. */ async getStats() {
162
172
  return {
163
173
  txHash: (await this.getTxHash()).toString(),
@@ -169,13 +179,11 @@ import { TxHash } from './tx_hash.js';
169
179
  proofSize: this.clientIvcProof.clientIvcProofBuffer.length,
170
180
  size: this.toBuffer().length,
171
181
  feePaymentMethod: // needsSetup? then we pay through a fee payment contract
172
- this.data.forPublic?.needsSetup ? this.data.getNonRevertiblePublicCallRequests().at(-1).functionSelector.toField().toBigInt() === 0x43417bb1n ? 'fpc_public' : 'fpc_private' : 'fee_juice'
182
+ this.data.forPublic?.needsSetup ? 'fpc' : 'fee_juice'
173
183
  };
174
184
  }
175
185
  getSize() {
176
- return this.data.getSize() + this.clientIvcProof.clientIvcProofBuffer.length + arraySerializedSizeOfNonEmpty(this.contractClassLogs) + arraySerializedSizeOfNonEmpty(this.enqueuedPublicFunctionCalls) + arraySerializedSizeOfNonEmpty([
177
- this.publicTeardownFunctionCall
178
- ]);
186
+ return this.data.getSize() + this.clientIvcProof.clientIvcProofBuffer.length + arraySerializedSizeOfNonEmpty(this.contractClassLogs) + this.publicFunctionCalldata.reduce((accum, cd)=>accum + cd.getSize(), 0);
179
187
  }
180
188
  /**
181
189
  * Estimates the tx size based on its private effects. Note that the actual size of the tx
@@ -205,9 +213,8 @@ import { TxHash } from './tx_hash.js';
205
213
  const publicInputs = PrivateKernelTailCircuitPublicInputs.fromBuffer(tx.data.toBuffer());
206
214
  const clientIvcProof = ClientIvcProof.fromBuffer(tx.clientIvcProof.toBuffer());
207
215
  const contractClassLogs = tx.contractClassLogs.map((x)=>ContractClassLog.fromBuffer(x.toBuffer()));
208
- const enqueuedPublicFunctionCalls = tx.enqueuedPublicFunctionCalls.map((x)=>PublicExecutionRequest.fromBuffer(x.toBuffer()));
209
- const publicTeardownFunctionCall = PublicExecutionRequest.fromBuffer(tx.publicTeardownFunctionCall.toBuffer());
210
- const clonedTx = new Tx(publicInputs, clientIvcProof, contractClassLogs, enqueuedPublicFunctionCalls, publicTeardownFunctionCall);
216
+ const publicFunctionCalldata = tx.publicFunctionCalldata.map((cd)=>HashedValues.fromBuffer(cd.toBuffer()));
217
+ const clonedTx = new Tx(publicInputs, clientIvcProof, contractClassLogs, publicFunctionCalldata);
211
218
  if (tx.txHash) {
212
219
  clonedTx.setTxHash(TxHash.fromBuffer(tx.txHash.toBuffer()));
213
220
  }
@@ -221,8 +228,8 @@ import { TxHash } from './tx_hash.js';
221
228
  return new Tx(PrivateKernelTailCircuitPublicInputs.emptyWithNullifier(), randomProof ? ClientIvcProof.random() : ClientIvcProof.empty(), [
222
229
  await ContractClassLog.random()
223
230
  ], [
224
- await PublicExecutionRequest.random()
225
- ], await PublicExecutionRequest.random());
231
+ HashedValues.random()
232
+ ]);
226
233
  }
227
234
  /**
228
235
  * Filters out logs from functions that are not present in the provided kernel output.
@@ -240,6 +247,13 @@ import { TxHash } from './tx_hash.js';
240
247
  */ async filterRevertedLogs() {
241
248
  this.contractClassLogs = await this.getSplitContractClassLogs(false);
242
249
  }
250
+ #combinePublicCallRequestWithCallData(request) {
251
+ const calldataMap = this.getCalldataMap();
252
+ // Assume empty calldata if nothing is given for the hash.
253
+ // The verification of calldata vs hash should be handled outside of this class.
254
+ const calldata = calldataMap.get(request.calldataHash.toString()) ?? [];
255
+ return new PublicCallRequestWithCalldata(request, calldata);
256
+ }
243
257
  }
244
258
  function hasHash(tx) {
245
259
  return tx.hash !== undefined;
@@ -108,7 +108,7 @@ import { TxRequest } from './tx_request.js';
108
108
  }
109
109
  static async random() {
110
110
  return new TxExecutionRequest(await AztecAddress.random(), FunctionSelector.random(), Fr.random(), TxContext.empty(), [
111
- await HashedValues.random()
111
+ HashedValues.random()
112
112
  ], [
113
113
  AuthWitness.random()
114
114
  ], [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "0.82.0",
3
+ "version": "0.82.1-alpha-testnet.1",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -65,11 +65,11 @@
65
65
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/bb.js": "0.82.0",
69
- "@aztec/blob-lib": "0.82.0",
70
- "@aztec/constants": "0.82.0",
71
- "@aztec/ethereum": "0.82.0",
72
- "@aztec/foundation": "0.82.0",
68
+ "@aztec/bb.js": "0.82.1-alpha-testnet.1",
69
+ "@aztec/blob-lib": "0.82.1-alpha-testnet.1",
70
+ "@aztec/constants": "0.82.1-alpha-testnet.1",
71
+ "@aztec/ethereum": "0.82.1-alpha-testnet.1",
72
+ "@aztec/foundation": "0.82.1-alpha-testnet.1",
73
73
  "lodash.chunk": "^4.2.0",
74
74
  "lodash.isequal": "^4.5.0",
75
75
  "lodash.omit": "^4.5.0",
@@ -1,4 +1,3 @@
1
- import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
2
1
  import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
3
2
  import { Fr } from '@aztec/foundation/fields';
4
3
 
@@ -6,7 +5,7 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, Functio
6
5
  import { hashVK } from '../hash/hash.js';
7
6
  import { computeArtifactHash } from './artifact_hash.js';
8
7
  import { type ContractClassIdPreimage, computeContractClassIdWithPreimage } from './contract_class_id.js';
9
- import type { ContractClass, ContractClassWithId, PublicFunction } from './interfaces/index.js';
8
+ import type { ContractClass, ContractClassWithId } from './interfaces/index.js';
10
9
 
11
10
  /** Contract artifact including its artifact hash */
12
11
  type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
@@ -19,32 +18,16 @@ export async function getContractClassFromArtifact(
19
18
  artifact: ContractArtifact | ContractArtifactWithHash,
20
19
  ): Promise<ContractClassWithId & ContractClassIdPreimage> {
21
20
  const artifactHash = 'artifactHash' in artifact ? artifact.artifactHash : await computeArtifactHash(artifact);
22
- const publicFunctions = artifact.functions.filter(f => f.functionType === FunctionType.PUBLIC);
23
- // TODO(#8985): ContractArtifact.functions should ensure that the below only contains the public dispatch function
24
- // So we can likely remove this and just use the below to assign the dispatch.
25
- const artifactPublicFunctions: ContractClass['publicFunctions'] = await Promise.all(
26
- publicFunctions.map(async f => ({
27
- selector: await FunctionSelector.fromNameAndParameters(f.name, f.parameters),
28
- bytecode: f.bytecode,
29
- })),
30
- );
31
-
32
- artifactPublicFunctions.sort(cmpFunctionArtifacts);
33
21
 
34
- let packedBytecode = Buffer.alloc(0);
35
- let dispatchFunction: PublicFunction | undefined = undefined;
36
- if (artifactPublicFunctions.length > 0) {
37
- dispatchFunction = artifactPublicFunctions.find(f =>
38
- f.selector.equals(FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR))),
22
+ const publicFunctions = artifact.functions.filter(f => f.functionType === FunctionType.PUBLIC);
23
+ if (publicFunctions.length > 1) {
24
+ throw new Error(
25
+ `Contract should contain at most one public function artifact. Received ${publicFunctions.length}.`,
39
26
  );
40
- if (!dispatchFunction) {
41
- throw new Error(
42
- `A contract with public functions should define a public_dispatch(Field) function as its public entrypoint. Contract: ${artifact.name}`,
43
- );
44
- }
45
- packedBytecode = dispatchFunction.bytecode;
46
27
  }
47
28
 
29
+ const packedBytecode = publicFunctions[0]?.bytecode ?? Buffer.alloc(0);
30
+
48
31
  const privateFunctions = artifact.functions.filter(f => f.functionType === FunctionType.PRIVATE);
49
32
  const privateArtifactFunctions: ContractClass['privateFunctions'] = await Promise.all(
50
33
  privateFunctions.map(getContractClassPrivateFunctionFromArtifact),
@@ -55,8 +38,6 @@ export async function getContractClassFromArtifact(
55
38
  const contractClass: ContractClass = {
56
39
  version: 1,
57
40
  artifactHash,
58
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Remove public functions.
59
- publicFunctions: dispatchFunction ? [dispatchFunction] : [],
60
41
  packedBytecode,
61
42
  privateFunctions: privateArtifactFunctions,
62
43
  };
@@ -19,9 +19,6 @@ export interface ContractClass {
19
19
  artifactHash: Fr;
20
20
  /** List of individual private functions, constructors included. */
21
21
  privateFunctions: PrivateFunction[];
22
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Remove public functions.
23
- /** Contains the public_dispatch function (and only that) if there's any public code in the contract. */
24
- publicFunctions: PublicFunction[];
25
22
  /** Bytecode for the public_dispatch function, or empty. */
26
23
  packedBytecode: Buffer;
27
24
  }
@@ -49,19 +46,6 @@ const ExecutablePrivateFunctionSchema = PrivateFunctionSchema.and(
49
46
  z.object({ bytecode: schemas.Buffer }),
50
47
  ) satisfies ZodFor<ExecutablePrivateFunction>;
51
48
 
52
- /** Public function definition within a contract class. */
53
- export interface PublicFunction {
54
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
55
- selector: FunctionSelector;
56
- /** Public bytecode. */
57
- bytecode: Buffer;
58
- }
59
-
60
- export const PublicFunctionSchema = z.object({
61
- selector: FunctionSelector.schema,
62
- bytecode: schemas.Buffer,
63
- }) satisfies ZodFor<PublicFunction>;
64
-
65
49
  /** Unconstrained function definition. */
66
50
  export interface UnconstrainedFunction {
67
51
  /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
@@ -124,7 +108,6 @@ export const ContractClassSchema = z.object({
124
108
  version: z.literal(VERSION),
125
109
  artifactHash: schemas.Fr,
126
110
  privateFunctions: z.array(PrivateFunctionSchema),
127
- publicFunctions: z.array(PublicFunctionSchema),
128
111
  packedBytecode: schemas.Buffer,
129
112
  }) satisfies ZodFor<ContractClass>;
130
113
 
@@ -151,7 +134,8 @@ export type ContractClassPublic = {
151
134
  unconstrainedFunctions: UnconstrainedFunctionWithMembershipProof[];
152
135
  } & Pick<ContractClassCommitments, 'id' | 'privateFunctionsRoot'> &
153
136
  Omit<ContractClass, 'privateFunctions'>;
154
- export type ContractClassWithCommitment = ContractClassPublic &
137
+
138
+ export type ContractClassPublicWithCommitment = ContractClassPublic &
155
139
  Pick<ContractClassCommitments, 'publicBytecodeCommitment'>;
156
140
 
157
141
  export const ContractClassPublicSchema = z
@@ -1,6 +1,6 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
2
 
3
- import { FunctionSelector } from '../../abi/index.js';
3
+ import type { FunctionSelector } from '../../abi/index.js';
4
4
  import type { AztecAddress } from '../../aztec-address/index.js';
5
5
  import type { ContractClassPublic } from './contract_class.js';
6
6
  import type { ContractInstanceWithAddress } from './contract_instance.js';
@@ -32,8 +32,8 @@ export interface ContractDataSource {
32
32
  */
33
33
  getContractClassIds(): Promise<Fr[]>;
34
34
 
35
- /** Returns a function's name */
36
- getContractFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
35
+ /** Returns a function's name. It's only available if provided by calling `registerContractFunctionSignatures`. */
36
+ getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
37
37
  /** Registers a function names. Useful for debugging. */
38
38
  registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void>;
39
39
  }
package/src/hash/hash.ts CHANGED
@@ -80,8 +80,9 @@ export function computePublicDataTreeLeafSlot(contractAddress: AztecAddress, sto
80
80
 
81
81
  /**
82
82
  * Computes the hash of a list of arguments.
83
+ * Used for input arguments or return values for private functions, or for authwit creation.
83
84
  * @param args - Arguments to hash.
84
- * @returns Pedersen hash of the arguments.
85
+ * @returns Hash of the arguments.
85
86
  */
86
87
  export function computeVarArgsHash(args: Fr[]): Promise<Fr> {
87
88
  if (args.length === 0) {
@@ -91,6 +92,19 @@ export function computeVarArgsHash(args: Fr[]): Promise<Fr> {
91
92
  return poseidon2HashWithSeparator(args, GeneratorIndex.FUNCTION_ARGS);
92
93
  }
93
94
 
95
+ /**
96
+ * Computes the hash of a public function's calldata.
97
+ * @param calldata - Calldata to hash.
98
+ * @returns Hash of the calldata.
99
+ */
100
+ export function computeCalldataHash(calldata: Fr[]): Promise<Fr> {
101
+ if (calldata.length === 0) {
102
+ return Promise.resolve(Fr.ZERO);
103
+ }
104
+
105
+ return poseidon2HashWithSeparator(calldata, GeneratorIndex.PUBLIC_CALLDATA);
106
+ }
107
+
94
108
  /**
95
109
  * Computes a hash of a secret.
96
110
  * @dev This function is used to generate secrets for the L1 to L2 message flow and for the TransparentNote.
@@ -72,9 +72,6 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
72
72
  registerContractFunctionSignatures: z.function().args(schemas.AztecAddress, z.array(z.string())).returns(z.void()),
73
73
  getL1ToL2Messages: z.function().args(schemas.BigInt).returns(z.array(schemas.Fr)),
74
74
  getL1ToL2MessageIndex: z.function().args(schemas.Fr).returns(schemas.BigInt.optional()),
75
- getContractFunctionName: z
76
- .function()
77
- .args(schemas.AztecAddress, schemas.FunctionSelector)
78
- .returns(optional(z.string())),
75
+ getDebugFunctionName: z.function().args(schemas.AztecAddress, schemas.FunctionSelector).returns(optional(z.string())),
79
76
  getL1Constants: z.function().args().returns(L1RollupConstantsSchema),
80
77
  };
@@ -51,7 +51,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
51
51
  realProofs: {
52
52
  env: 'PROVER_REAL_PROOFS',
53
53
  description: 'Whether to construct real proofs',
54
- ...booleanConfigHelper(),
54
+ ...booleanConfigHelper(true),
55
55
  },
56
56
  proverId: {
57
57
  env: 'PROVER_ID',
@@ -7,8 +7,8 @@ import type { FieldsOf } from '@aztec/foundation/types';
7
7
  import { inspect } from 'util';
8
8
  import { z } from 'zod';
9
9
 
10
- import { FunctionSelector } from '../abi/index.js';
11
10
  import { AztecAddress } from '../aztec-address/index.js';
11
+ import { computeCalldataHash } from '../hash/index.js';
12
12
  import type { UInt32 } from '../types/shared.js';
13
13
 
14
14
  /**
@@ -24,15 +24,14 @@ export class PublicCallRequest {
24
24
  * The contract address being called.
25
25
  */
26
26
  public contractAddress: AztecAddress,
27
- /**
28
- * Function selector of the function being called.
29
- */
30
- public functionSelector: FunctionSelector,
31
27
  /**
32
28
  * Determines whether the call is modifying state.
33
29
  */
34
30
  public isStaticCall: boolean,
35
- public argsHash: Fr,
31
+ /**
32
+ * Hash of the calldata of the function being called.
33
+ */
34
+ public calldataHash: Fr,
36
35
  ) {}
37
36
 
38
37
  static get schema() {
@@ -40,12 +39,11 @@ export class PublicCallRequest {
40
39
  .object({
41
40
  msgSender: AztecAddress.schema,
42
41
  contractAddress: AztecAddress.schema,
43
- functionSelector: FunctionSelector.schema,
44
42
  isStaticCall: z.boolean(),
45
- argsHash: schemas.Fr,
43
+ calldataHash: schemas.Fr,
46
44
  })
47
- .transform(({ msgSender, contractAddress, functionSelector, isStaticCall, argsHash }) => {
48
- return new PublicCallRequest(msgSender, contractAddress, functionSelector, isStaticCall, argsHash);
45
+ .transform(({ msgSender, contractAddress, isStaticCall, calldataHash }) => {
46
+ return new PublicCallRequest(msgSender, contractAddress, isStaticCall, calldataHash);
49
47
  });
50
48
  }
51
49
 
@@ -58,13 +56,7 @@ export class PublicCallRequest {
58
56
  }
59
57
 
60
58
  static getFields(fields: FieldsOf<PublicCallRequest>) {
61
- return [
62
- fields.msgSender,
63
- fields.contractAddress,
64
- fields.functionSelector,
65
- fields.isStaticCall,
66
- fields.argsHash,
67
- ] as const;
59
+ return [fields.msgSender, fields.contractAddress, fields.isStaticCall, fields.calldataHash] as const;
68
60
  }
69
61
 
70
62
  static fromFields(fields: Fr[] | FieldReader): PublicCallRequest {
@@ -72,7 +64,6 @@ export class PublicCallRequest {
72
64
  return new PublicCallRequest(
73
65
  reader.readObject(AztecAddress),
74
66
  reader.readObject(AztecAddress),
75
- reader.readObject(FunctionSelector),
76
67
  reader.readBoolean(),
77
68
  reader.readField(),
78
69
  );
@@ -93,7 +84,6 @@ export class PublicCallRequest {
93
84
  return new PublicCallRequest(
94
85
  reader.readObject(AztecAddress),
95
86
  reader.readObject(AztecAddress),
96
- reader.readObject(FunctionSelector),
97
87
  reader.readBoolean(),
98
88
  reader.readObject(Fr),
99
89
  );
@@ -104,16 +94,12 @@ export class PublicCallRequest {
104
94
  }
105
95
 
106
96
  static empty() {
107
- return new PublicCallRequest(AztecAddress.ZERO, AztecAddress.ZERO, FunctionSelector.empty(), false, Fr.ZERO);
97
+ return new PublicCallRequest(AztecAddress.ZERO, AztecAddress.ZERO, false, Fr.ZERO);
108
98
  }
109
99
 
110
100
  isEmpty(): boolean {
111
101
  return (
112
- this.msgSender.isZero() &&
113
- this.contractAddress.isZero() &&
114
- this.functionSelector.isEmpty() &&
115
- !this.isStaticCall &&
116
- this.argsHash.isEmpty()
102
+ this.msgSender.isZero() && this.contractAddress.isZero() && !this.isStaticCall && this.calldataHash.isEmpty()
117
103
  );
118
104
  }
119
105
 
@@ -121,11 +107,20 @@ export class PublicCallRequest {
121
107
  return `PublicCallRequest {
122
108
  msgSender: ${this.msgSender}
123
109
  contractAddress: ${this.contractAddress}
124
- functionSelector: ${this.functionSelector}
125
110
  isStaticCall: ${this.isStaticCall}
126
- argsHash: ${this.argsHash}
111
+ calldataHash: ${this.calldataHash}
127
112
  }`;
128
113
  }
114
+
115
+ static async fromCalldata(
116
+ msgSender: AztecAddress,
117
+ contractAddress: AztecAddress,
118
+ isStaticCall: boolean,
119
+ calldata: Fr[],
120
+ ) {
121
+ const calldataHash = await computeCalldataHash(calldata);
122
+ return new PublicCallRequest(msgSender, contractAddress, isStaticCall, calldataHash);
123
+ }
129
124
  }
130
125
 
131
126
  export class CountedPublicCallRequest {
@@ -225,7 +225,7 @@ export type TxStats = {
225
225
  /** Serialized size of contract class logs in fields. */
226
226
  contractClassLogSize: number;
227
227
  /** How this tx pays for its fee */
228
- feePaymentMethod: 'fee_juice' | 'fpc_public' | 'fpc_private';
228
+ feePaymentMethod: 'fee_juice' | 'fpc';
229
229
  };
230
230
 
231
231
  /**
@@ -78,7 +78,6 @@ import {
78
78
  type ContractInstanceWithAddress,
79
79
  type ExecutablePrivateFunctionWithMembershipProof,
80
80
  type PrivateFunction,
81
- type PublicFunction,
82
81
  SerializableContractInstance,
83
82
  type UnconstrainedFunctionWithMembershipProof,
84
83
  computeContractClassId,
@@ -523,13 +522,7 @@ function makePrivateCallRequest(seed = 1): PrivateCallRequest {
523
522
  }
524
523
 
525
524
  export function makePublicCallRequest(seed = 1) {
526
- return new PublicCallRequest(
527
- makeAztecAddress(seed),
528
- makeAztecAddress(seed + 1),
529
- makeSelector(seed + 2),
530
- false,
531
- fr(seed + 0x3),
532
- );
525
+ return new PublicCallRequest(makeAztecAddress(seed), makeAztecAddress(seed + 1), false, fr(seed + 0x3));
533
526
  }
534
527
 
535
528
  function makeCountedPublicCallRequest(seed = 1) {
@@ -1171,16 +1164,10 @@ export function makeUnconstrainedFunctionWithMembershipProof(seed = 0): Unconstr
1171
1164
  };
1172
1165
  }
1173
1166
 
1174
- export async function makeContractClassPublic(
1175
- seed = 0,
1176
- publicDispatchFunction?: PublicFunction,
1177
- ): Promise<ContractClassPublic> {
1167
+ export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer): Promise<ContractClassPublic> {
1178
1168
  const artifactHash = fr(seed + 1);
1179
- const publicFunctions = publicDispatchFunction
1180
- ? [publicDispatchFunction]
1181
- : makeTuple(1, makeContractClassPublicFunction, seed + 2);
1182
1169
  const privateFunctionsRoot = fr(seed + 3);
1183
- const packedBytecode = publicDispatchFunction?.bytecode ?? makeBytes(100, seed + 4);
1170
+ const packedBytecode = publicBytecode ?? makeBytes(100, seed + 4);
1184
1171
  const publicBytecodeCommitment = await computePublicBytecodeCommitment(packedBytecode);
1185
1172
  const id = await computeContractClassId({ artifactHash, privateFunctionsRoot, publicBytecodeCommitment });
1186
1173
  return {
@@ -1188,20 +1175,12 @@ export async function makeContractClassPublic(
1188
1175
  artifactHash,
1189
1176
  packedBytecode,
1190
1177
  privateFunctionsRoot,
1191
- publicFunctions,
1192
1178
  privateFunctions: [],
1193
1179
  unconstrainedFunctions: [],
1194
1180
  version: 1,
1195
1181
  };
1196
1182
  }
1197
1183
 
1198
- function makeContractClassPublicFunction(seed = 0): PublicFunction {
1199
- return {
1200
- selector: FunctionSelector.fromField(fr(seed + 1)),
1201
- bytecode: makeBytes(100, seed + 2),
1202
- };
1203
- }
1204
-
1205
1184
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1206
1185
  function makeContractClassPrivateFunction(seed = 0): PrivateFunction {
1207
1186
  return {