@aztec/stdlib 0.81.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.
- package/dest/abi/abi.d.ts +5 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +2 -1
- package/dest/auth_witness/auth_witness.d.ts +21 -0
- package/dest/auth_witness/auth_witness.d.ts.map +1 -1
- package/dest/auth_witness/auth_witness.js +29 -0
- package/dest/avm/avm.d.ts +24 -48
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.d.ts +18 -36
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_proving_request.d.ts +27 -54
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/index.d.ts +0 -1
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +0 -1
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.js +0 -2
- package/dest/block/l2_block_source.d.ts +6 -0
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/contract/contract_class.d.ts.map +1 -1
- package/dest/contract/contract_class.js +3 -21
- package/dest/contract/interfaces/contract_class.d.ts +1 -143
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +0 -5
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -8
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/database-version/version_manager.d.ts +5 -0
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +7 -0
- package/dest/hash/hash.d.ts +8 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +12 -1
- package/dest/interfaces/archiver.d.ts +1 -2
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +2 -4
- package/dest/interfaces/aztec-node-admin.d.ts +20 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -0
- package/dest/interfaces/aztec-node-admin.js +16 -0
- package/dest/interfaces/aztec-node.d.ts +8 -38
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +4 -12
- package/dest/interfaces/client.d.ts +1 -0
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +1 -0
- package/dest/interfaces/private_kernel_prover.d.ts +2 -3
- package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +1 -1
- package/dest/interfaces/prover-node.d.ts +1 -2
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +5 -4
- package/dest/interfaces/proving-job.d.ts +27 -54
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +21 -39
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +10 -9
- package/dest/kernel/index.d.ts +1 -1
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -1
- package/dest/kernel/private_kernel_prover_output.d.ts +49 -0
- package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -0
- package/dest/kernel/private_kernel_prover_output.js +8 -0
- package/dest/kernel/private_kernel_simulated_output.d.ts +3 -7
- package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
- package/dest/kernel/public_call_request.d.ts +14 -19
- package/dest/kernel/public_call_request.d.ts.map +1 -1
- package/dest/kernel/public_call_request.js +19 -20
- package/dest/logs/log_with_tx_data.js +2 -2
- package/dest/noir/index.d.ts +5 -1
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/proofs/client_ivc_proof.d.ts +1 -2
- package/dest/proofs/client_ivc_proof.d.ts.map +1 -1
- package/dest/proofs/client_ivc_proof.js +6 -9
- package/dest/rollup/tube_inputs.d.ts +7 -2
- package/dest/rollup/tube_inputs.d.ts.map +1 -1
- package/dest/rollup/tube_inputs.js +10 -4
- package/dest/stats/stats.d.ts +1 -1
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +2 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -13
- package/dest/tests/mocks.d.ts +3 -4
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -48
- package/dest/trees/nullifier_membership_witness.d.ts +4 -0
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +10 -0
- package/dest/trees/public_data_witness.d.ts +5 -5
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +13 -0
- package/dest/tx/call_context.d.ts +1 -1
- package/dest/tx/hashed_values.d.ts +16 -4
- package/dest/tx/hashed_values.d.ts.map +1 -1
- package/dest/tx/hashed_values.js +26 -9
- package/dest/tx/index.d.ts +3 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +3 -1
- package/dest/tx/private_execution_result.d.ts +10 -26
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +18 -70
- package/dest/tx/profiled_tx.d.ts +9 -0
- package/dest/tx/profiled_tx.d.ts.map +1 -0
- package/dest/tx/profiled_tx.js +27 -0
- package/dest/tx/proven_tx.d.ts +33 -0
- package/dest/tx/proven_tx.d.ts.map +1 -0
- package/dest/tx/proven_tx.js +33 -0
- package/dest/tx/public_call_request_with_calldata.d.ts +41 -0
- package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -0
- package/dest/tx/public_call_request_with_calldata.js +57 -0
- package/dest/tx/simulated_tx.d.ts +8 -44
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +19 -44
- package/dest/tx/tx.d.ts +16 -20
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +56 -42
- package/dest/tx/tx_execution_request.js +1 -1
- package/dest/tx/tx_receipt.d.ts +1 -30
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +3 -13
- package/package.json +6 -7
- package/src/abi/abi.ts +7 -2
- package/src/auth_witness/auth_witness.ts +29 -0
- package/src/block/index.ts +0 -1
- package/src/block/l2_block_downloader/l2_block_stream.ts +0 -2
- package/src/block/l2_block_source.ts +7 -0
- package/src/contract/contract_class.ts +7 -26
- package/src/contract/interfaces/contract_class.ts +2 -18
- package/src/contract/interfaces/contract_data_source.ts +3 -9
- package/src/database-version/version_manager.ts +10 -0
- package/src/hash/hash.ts +15 -1
- package/src/interfaces/archiver.ts +3 -12
- package/src/interfaces/aztec-node-admin.ts +39 -0
- package/src/interfaces/aztec-node.ts +9 -71
- package/src/interfaces/client.ts +1 -0
- package/src/interfaces/private_kernel_prover.ts +2 -3
- package/src/interfaces/prover-client.ts +1 -1
- package/src/interfaces/prover-node.ts +2 -4
- package/src/interfaces/pxe.ts +34 -56
- package/src/kernel/index.ts +1 -1
- package/src/kernel/private_kernel_prover_output.ts +44 -0
- package/src/kernel/private_kernel_simulated_output.ts +4 -13
- package/src/kernel/public_call_request.ts +22 -27
- package/src/logs/log_with_tx_data.ts +2 -2
- package/src/noir/index.ts +6 -1
- package/src/proofs/client_ivc_proof.ts +5 -15
- package/src/rollup/tube_inputs.ts +8 -4
- package/src/stats/stats.ts +1 -1
- package/src/tests/factories.ts +3 -24
- package/src/tests/mocks.ts +28 -80
- package/src/trees/nullifier_membership_witness.ts +12 -0
- package/src/trees/public_data_witness.ts +15 -0
- package/src/tx/hashed_values.ts +29 -9
- package/src/tx/index.ts +3 -1
- package/src/tx/private_execution_result.ts +16 -81
- package/src/tx/profiled_tx.ts +27 -0
- package/src/tx/proven_tx.ts +50 -0
- package/src/tx/public_call_request_with_calldata.ts +72 -0
- package/src/tx/simulated_tx.ts +12 -69
- package/src/tx/tx.ts +57 -70
- package/src/tx/tx_execution_request.ts +1 -1
- package/src/tx/tx_receipt.ts +0 -36
- package/dest/block/nullifier_with_block_source.d.ts +0 -6
- package/dest/block/nullifier_with_block_source.d.ts.map +0 -1
- package/dest/block/nullifier_with_block_source.js +0 -1
- package/dest/kernel/private_kernel_prover_profile_result.d.ts +0 -25
- package/dest/kernel/private_kernel_prover_profile_result.d.ts.map +0 -1
- package/dest/kernel/private_kernel_prover_profile_result.js +0 -7
- package/dest/tx/public_execution_request.d.ts +0 -45
- package/dest/tx/public_execution_request.d.ts.map +0 -1
- package/dest/tx/public_execution_request.js +0 -72
- package/src/block/nullifier_with_block_source.ts +0 -7
- package/src/kernel/private_kernel_prover_profile_result.ts +0 -7
- 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 {
|
|
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
|
-
|
|
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
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
|
|
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.
|
|
46
|
+
return this.numberOfPublicCalls() > 0;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return this.enqueuedPublicFunctionCalls.slice(numRevertible);
|
|
48
|
+
numberOfPublicCalls() {
|
|
49
|
+
return this.data.numberOfPublicCallRequests();
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return this.enqueuedPublicFunctionCalls.slice(0, numRevertible);
|
|
51
|
+
getNonRevertiblePublicCallRequestsWithCalldata() {
|
|
52
|
+
return this.data.getNonRevertiblePublicCallRequests().map((r)=>this.#combinePublicCallRequestWithCallData(r));
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
return this.
|
|
54
|
+
getRevertiblePublicCallRequestsWithCalldata() {
|
|
55
|
+
return this.data.getRevertiblePublicCallRequests().map((r)=>this.#combinePublicCallRequestWithCallData(r));
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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(
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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 ?
|
|
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) +
|
|
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
|
|
209
|
-
const
|
|
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
|
-
|
|
225
|
-
]
|
|
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
|
-
|
|
111
|
+
HashedValues.random()
|
|
112
112
|
], [
|
|
113
113
|
AuthWitness.random()
|
|
114
114
|
], [
|
package/dest/tx/tx_receipt.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
1
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
-
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
4
2
|
import { RevertCode } from '../avm/revert_code.js';
|
|
5
3
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
6
4
|
import { type ZodFor } from '../schemas/schemas.js';
|
|
@@ -35,8 +33,6 @@ export declare class TxReceipt {
|
|
|
35
33
|
blockHash?: L2BlockHash | undefined;
|
|
36
34
|
/** The block number in which the transaction was included. */
|
|
37
35
|
blockNumber?: number | undefined;
|
|
38
|
-
/** Information useful for testing/debugging, set when test flag is set to true in `waitOpts`. */
|
|
39
|
-
debugInfo?: DebugInfo | undefined;
|
|
40
36
|
constructor(
|
|
41
37
|
/** A unique identifier for a transaction. */
|
|
42
38
|
txHash: TxHash,
|
|
@@ -49,35 +45,10 @@ export declare class TxReceipt {
|
|
|
49
45
|
/** The hash of the block containing the transaction. */
|
|
50
46
|
blockHash?: L2BlockHash | undefined,
|
|
51
47
|
/** The block number in which the transaction was included. */
|
|
52
|
-
blockNumber?: number | undefined
|
|
53
|
-
/** Information useful for testing/debugging, set when test flag is set to true in `waitOpts`. */
|
|
54
|
-
debugInfo?: DebugInfo | undefined);
|
|
48
|
+
blockNumber?: number | undefined);
|
|
55
49
|
static empty(): TxReceipt;
|
|
56
50
|
static get schema(): ZodFor<TxReceipt>;
|
|
57
51
|
static from(fields: FieldsOf<TxReceipt>): TxReceipt;
|
|
58
52
|
static statusFromRevertCode(revertCode: RevertCode): TxStatus.SUCCESS | TxStatus.APP_LOGIC_REVERTED | TxStatus.TEARDOWN_REVERTED | TxStatus.BOTH_REVERTED;
|
|
59
53
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Information useful for debugging/testing purposes included in the receipt when the debug flag is set to true
|
|
62
|
-
* in `WaitOpts`.
|
|
63
|
-
*/
|
|
64
|
-
interface DebugInfo {
|
|
65
|
-
/**
|
|
66
|
-
* New note hashes created by the transaction.
|
|
67
|
-
*/
|
|
68
|
-
noteHashes: Fr[];
|
|
69
|
-
/**
|
|
70
|
-
* New nullifiers created by the transaction.
|
|
71
|
-
*/
|
|
72
|
-
nullifiers: Fr[];
|
|
73
|
-
/**
|
|
74
|
-
* New public data writes created by the transaction.
|
|
75
|
-
*/
|
|
76
|
-
publicDataWrites: PublicDataWrite[];
|
|
77
|
-
/**
|
|
78
|
-
* New L2 to L1 messages created by the transaction.
|
|
79
|
-
*/
|
|
80
|
-
l2ToL1Msgs: Fr[];
|
|
81
|
-
}
|
|
82
|
-
export {};
|
|
83
54
|
//# sourceMappingURL=tx_receipt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_receipt.d.ts","sourceRoot":"","sources":["../../src/tx/tx_receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tx_receipt.d.ts","sourceRoot":"","sources":["../../src/tx/tx_receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IAElB,6CAA6C;IACtC,MAAM,EAAE,MAAM;IACrB,gCAAgC;IACzB,MAAM,EAAE,QAAQ;IACvB,gDAAgD;IACzC,KAAK,EAAE,MAAM;IACpB,oDAAoD;IAC7C,cAAc,CAAC;IACtB,wDAAwD;IACjD,SAAS,CAAC;IACjB,8DAA8D;IACvD,WAAW,CAAC;;IAXnB,6CAA6C;IACtC,MAAM,EAAE,MAAM;IACrB,gCAAgC;IACzB,MAAM,EAAE,QAAQ;IACvB,gDAAgD;IACzC,KAAK,EAAE,MAAM;IACpB,oDAAoD;IAC7C,cAAc,CAAC,oBAAQ;IAC9B,wDAAwD;IACjD,SAAS,CAAC,yBAAa;IAC9B,8DAA8D;IACvD,WAAW,CAAC,oBAAQ;IAG7B,MAAM,CAAC,KAAK;IAIZ,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAWrC;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC;WAWzB,oBAAoB,CAAC,UAAU,EAAE,UAAU;CAa1D"}
|
package/dest/tx/tx_receipt.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
3
2
|
import { RevertCode } from '../avm/revert_code.js';
|
|
4
3
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
5
4
|
import { schemas } from '../schemas/schemas.js';
|
|
@@ -27,15 +26,13 @@ import { TxHash } from './tx_hash.js';
|
|
|
27
26
|
transactionFee;
|
|
28
27
|
blockHash;
|
|
29
28
|
blockNumber;
|
|
30
|
-
|
|
31
|
-
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's status. */ status, /** Description of transaction error, if any. */ error, /** The transaction fee paid for the transaction. */ transactionFee, /** The hash of the block containing the transaction. */ blockHash, /** The block number in which the transaction was included. */ blockNumber, /** Information useful for testing/debugging, set when test flag is set to true in `waitOpts`. */ debugInfo){
|
|
29
|
+
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's status. */ status, /** Description of transaction error, if any. */ error, /** The transaction fee paid for the transaction. */ transactionFee, /** The hash of the block containing the transaction. */ blockHash, /** The block number in which the transaction was included. */ blockNumber){
|
|
32
30
|
this.txHash = txHash;
|
|
33
31
|
this.status = status;
|
|
34
32
|
this.error = error;
|
|
35
33
|
this.transactionFee = transactionFee;
|
|
36
34
|
this.blockHash = blockHash;
|
|
37
35
|
this.blockNumber = blockNumber;
|
|
38
|
-
this.debugInfo = debugInfo;
|
|
39
36
|
}
|
|
40
37
|
static empty() {
|
|
41
38
|
return new TxReceipt(TxHash.zero(), "dropped", '');
|
|
@@ -47,12 +44,11 @@ import { TxHash } from './tx_hash.js';
|
|
|
47
44
|
error: z.string(),
|
|
48
45
|
blockHash: L2BlockHash.schema.optional(),
|
|
49
46
|
blockNumber: z.number().int().nonnegative().optional(),
|
|
50
|
-
transactionFee: schemas.BigInt.optional()
|
|
51
|
-
debugInfo: DebugInfoSchema.optional()
|
|
47
|
+
transactionFee: schemas.BigInt.optional()
|
|
52
48
|
}).transform(TxReceipt.from);
|
|
53
49
|
}
|
|
54
50
|
static from(fields) {
|
|
55
|
-
return new TxReceipt(fields.txHash, fields.status, fields.error, fields.transactionFee, fields.blockHash, fields.blockNumber
|
|
51
|
+
return new TxReceipt(fields.txHash, fields.status, fields.error, fields.transactionFee, fields.blockHash, fields.blockNumber);
|
|
56
52
|
}
|
|
57
53
|
static statusFromRevertCode(revertCode) {
|
|
58
54
|
if (revertCode.equals(RevertCode.OK)) {
|
|
@@ -68,9 +64,3 @@ import { TxHash } from './tx_hash.js';
|
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
|
-
const DebugInfoSchema = z.object({
|
|
72
|
-
noteHashes: z.array(schemas.Fr),
|
|
73
|
-
nullifiers: z.array(schemas.Fr),
|
|
74
|
-
publicDataWrites: z.array(PublicDataWrite.schema),
|
|
75
|
-
l2ToL1Msgs: z.array(schemas.Fr)
|
|
76
|
-
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1-alpha-testnet.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"./keys": "./dest/keys/index.js",
|
|
14
14
|
"./testing": "./dest/tests/index.js",
|
|
15
15
|
"./testing/fixtures": "./dest/tests/fixtures.js",
|
|
16
|
-
"./interfaces": "./dest/interfaces/index.js",
|
|
17
16
|
"./network": "./dest/network/index.js",
|
|
18
17
|
"./utils": "./dest/utils/index.js",
|
|
19
18
|
"./types": "./dest/types/index.js",
|
|
@@ -66,11 +65,11 @@
|
|
|
66
65
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
67
66
|
},
|
|
68
67
|
"dependencies": {
|
|
69
|
-
"@aztec/bb.js": "0.
|
|
70
|
-
"@aztec/blob-lib": "0.
|
|
71
|
-
"@aztec/constants": "0.
|
|
72
|
-
"@aztec/ethereum": "0.
|
|
73
|
-
"@aztec/foundation": "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",
|
|
74
73
|
"lodash.chunk": "^4.2.0",
|
|
75
74
|
"lodash.isequal": "^4.5.0",
|
|
76
75
|
"lodash.omit": "^4.5.0",
|
package/src/abi/abi.ts
CHANGED
|
@@ -231,6 +231,11 @@ export interface FunctionArtifact extends FunctionAbi {
|
|
|
231
231
|
debug?: FunctionDebugMetadata;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
export interface FunctionArtifactWithContractName extends FunctionArtifact {
|
|
235
|
+
/** The name of the contract. */
|
|
236
|
+
contractName: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
234
239
|
export const FunctionArtifactSchema = FunctionAbiSchema.and(
|
|
235
240
|
z.object({
|
|
236
241
|
bytecode: schemas.Buffer,
|
|
@@ -395,7 +400,7 @@ export function getFunctionArtifactByName(artifact: ContractArtifact, functionNa
|
|
|
395
400
|
export async function getFunctionArtifact(
|
|
396
401
|
artifact: ContractArtifact,
|
|
397
402
|
functionNameOrSelector: string | FunctionSelector,
|
|
398
|
-
): Promise<
|
|
403
|
+
): Promise<FunctionArtifactWithContractName> {
|
|
399
404
|
let functionArtifact;
|
|
400
405
|
if (typeof functionNameOrSelector === 'string') {
|
|
401
406
|
functionArtifact = artifact.functions.find(f => f.name === functionNameOrSelector);
|
|
@@ -416,7 +421,7 @@ export async function getFunctionArtifact(
|
|
|
416
421
|
|
|
417
422
|
const debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact);
|
|
418
423
|
|
|
419
|
-
return { ...functionArtifact, debug: debugMetadata };
|
|
424
|
+
return { ...functionArtifact, debug: debugMetadata, contractName: artifact.name };
|
|
420
425
|
}
|
|
421
426
|
|
|
422
427
|
/** Gets all function abis */
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
1
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
5
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
4
6
|
|
|
7
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
8
|
import { hexSchemaFor } from '../schemas/schemas.js';
|
|
6
9
|
import { Vector } from '../types/shared.js';
|
|
7
10
|
|
|
@@ -50,3 +53,29 @@ export class AuthWitness {
|
|
|
50
53
|
return new AuthWitness(Fr.random(), [Fr.random(), Fr.random(), Fr.random()]);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Compute the inner hash for an authentication witness.
|
|
59
|
+
* This is the "intent" of the message, before siloed with the consumer.
|
|
60
|
+
* @param args - The arguments to hash
|
|
61
|
+
* @returns The inner hash for the witness
|
|
62
|
+
*/
|
|
63
|
+
export const computeInnerAuthWitHash = (args: Fr[]) => {
|
|
64
|
+
return poseidon2HashWithSeparator(args, GeneratorIndex.AUTHWIT_INNER);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Compute the outer hash for an authentication witness.
|
|
69
|
+
* This is the value siloed with its "consumer" and what the `on_behalf_of`
|
|
70
|
+
* should be signing.
|
|
71
|
+
* The consumer is who will be consuming the message, for token approvals it
|
|
72
|
+
* is the token contract itself (because the token makes the call to check the approval).
|
|
73
|
+
* @param consumer - The address that can "consume" the authwit
|
|
74
|
+
* @param chainId - The chain id that can "consume" the authwit
|
|
75
|
+
* @param version - The version that can "consume" the authwit
|
|
76
|
+
* @param innerHash - The inner hash for the witness
|
|
77
|
+
* @returns The outer hash for the witness
|
|
78
|
+
*/
|
|
79
|
+
export const computeOuterAuthWitHash = (consumer: AztecAddress, chainId: Fr, version: Fr, innerHash: Fr) => {
|
|
80
|
+
return poseidon2HashWithSeparator([consumer.toField(), chainId, version, innerHash], GeneratorIndex.AUTHWIT_OUTER);
|
|
81
|
+
};
|
package/src/block/index.ts
CHANGED
|
@@ -93,8 +93,6 @@ export class L2BlockStream {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// Update the proven and finalized tips.
|
|
96
|
-
// TODO(palla/reorg): Should we emit this before passing the new blocks? This would allow world-state to skip
|
|
97
|
-
// building the data structures for the pending chain if it's unneeded.
|
|
98
96
|
if (localTips.proven !== undefined && sourceTips.proven.number !== localTips.proven.number) {
|
|
99
97
|
await this.emitEvent({ type: 'chain-proven', blockNumber: sourceTips.proven.number });
|
|
100
98
|
}
|
|
@@ -97,6 +97,13 @@ export interface L2BlockSource {
|
|
|
97
97
|
*/
|
|
98
98
|
getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Returns all block headers for a given epoch.
|
|
102
|
+
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
103
|
+
* @param epochNumber - The epoch number to return headers for.
|
|
104
|
+
*/
|
|
105
|
+
getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]>;
|
|
106
|
+
|
|
100
107
|
/**
|
|
101
108
|
* Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
|
|
102
109
|
* @param epochNumber - The epoch number to check.
|
|
@@ -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
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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';
|
|
@@ -20,12 +20,6 @@ export interface ContractDataSource {
|
|
|
20
20
|
|
|
21
21
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Adds a contract class to the database.
|
|
25
|
-
* TODO(#10007): Remove this method
|
|
26
|
-
*/
|
|
27
|
-
addContractClass(contractClass: ContractClassPublic): Promise<void>;
|
|
28
|
-
|
|
29
23
|
/**
|
|
30
24
|
* Returns a publicly deployed contract instance given its address.
|
|
31
25
|
* @param address - Address of the deployed contract.
|
|
@@ -38,8 +32,8 @@ export interface ContractDataSource {
|
|
|
38
32
|
*/
|
|
39
33
|
getContractClassIds(): Promise<Fr[]>;
|
|
40
34
|
|
|
41
|
-
/** Returns a function's name */
|
|
42
|
-
|
|
35
|
+
/** Returns a function's name. It's only available if provided by calling `registerContractFunctionSignatures`. */
|
|
36
|
+
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
43
37
|
/** Registers a function names. Useful for debugging. */
|
|
44
38
|
registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void>;
|
|
45
39
|
}
|
|
@@ -3,6 +3,7 @@ import { jsonParseWithSchemaSync, jsonStringify } from '@aztec/foundation/json-r
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
import fs from 'fs/promises';
|
|
6
|
+
import { inspect } from 'node:util';
|
|
6
7
|
import { join } from 'path';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
|
|
@@ -59,6 +60,15 @@ export class DatabaseVersion {
|
|
|
59
60
|
.transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
/** Allows for better introspection. */
|
|
64
|
+
public [inspect.custom](): string {
|
|
65
|
+
return this.toString();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public toString(): string {
|
|
69
|
+
return this.schemaVersion.toString();
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
/**
|
|
63
73
|
* Returns an empty instance
|
|
64
74
|
*/
|
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
|
|
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.
|