@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
|
@@ -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
|
-
|
|
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
|
-
|
|
43
|
+
calldataHash: schemas.Fr,
|
|
46
44
|
})
|
|
47
|
-
.transform(({ msgSender, contractAddress,
|
|
48
|
-
return new PublicCallRequest(msgSender, contractAddress,
|
|
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,
|
|
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
|
-
|
|
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 {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
|
|
4
|
-
// TypeScript representation of the Noir aztec::oracle::
|
|
5
|
-
// for PXE's custom getLogByTag oracle.
|
|
4
|
+
// TypeScript representation of the Noir aztec::oracle::message_discovery::LogWithTxData struct. This is used as a
|
|
5
|
+
// response for PXE's custom getLogByTag oracle.
|
|
6
6
|
export class LogWithTxData {
|
|
7
7
|
constructor(
|
|
8
8
|
public logContent: Fr[],
|
package/src/noir/index.ts
CHANGED
|
@@ -75,7 +75,7 @@ export interface NoirCompiledContract {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* The compilation result of
|
|
78
|
+
* The compilation result of a protocol (non-contract) circuit.
|
|
79
79
|
*/
|
|
80
80
|
export interface NoirCompiledCircuit {
|
|
81
81
|
/** The hash of the circuit. */
|
|
@@ -92,6 +92,11 @@ export interface NoirCompiledCircuit {
|
|
|
92
92
|
file_map: DebugFileMap;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
export interface NoirCompiledCircuitWithName extends NoirCompiledCircuit {
|
|
96
|
+
/** The name of the circuit. */
|
|
97
|
+
name: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
/**
|
|
96
101
|
* The debug metadata of an Aztec.nr contract.
|
|
97
102
|
*/
|
|
@@ -3,7 +3,6 @@ import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
4
|
|
|
5
5
|
const CLIENT_IVC_PROOF_LENGTH = 172052;
|
|
6
|
-
const CLIENT_IVC_VK_LENGTH = 2730;
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* TODO(https://github.com/AztecProtocol/aztec-packages/issues/7370) refactor this to
|
|
@@ -15,7 +14,6 @@ export class ClientIvcProof {
|
|
|
15
14
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/7370): Need to precompute private kernel tail VK so we can verify this immediately in the tx pool
|
|
16
15
|
// which parts of these are needed to quickly verify that we have a correct IVC proof
|
|
17
16
|
public clientIvcProofBuffer: Buffer,
|
|
18
|
-
public clientIvcVkBuffer: Buffer,
|
|
19
17
|
) {}
|
|
20
18
|
|
|
21
19
|
public isEmpty() {
|
|
@@ -23,18 +21,15 @@ export class ClientIvcProof {
|
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
static empty() {
|
|
26
|
-
return new ClientIvcProof(Buffer.from('')
|
|
24
|
+
return new ClientIvcProof(Buffer.from(''));
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
static fake(fill = Math.floor(Math.random() * 255)) {
|
|
30
|
-
return new ClientIvcProof(Buffer.alloc(1, fill)
|
|
28
|
+
return new ClientIvcProof(Buffer.alloc(1, fill));
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
static random() {
|
|
34
|
-
return new ClientIvcProof(
|
|
35
|
-
Buffer.from(randomBytes(CLIENT_IVC_PROOF_LENGTH)),
|
|
36
|
-
Buffer.from(randomBytes(CLIENT_IVC_VK_LENGTH)),
|
|
37
|
-
);
|
|
32
|
+
return new ClientIvcProof(Buffer.from(randomBytes(CLIENT_IVC_PROOF_LENGTH)));
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
static get schema() {
|
|
@@ -47,15 +42,10 @@ export class ClientIvcProof {
|
|
|
47
42
|
|
|
48
43
|
static fromBuffer(buffer: Buffer | BufferReader): ClientIvcProof {
|
|
49
44
|
const reader = BufferReader.asReader(buffer);
|
|
50
|
-
return new ClientIvcProof(reader.readBuffer()
|
|
45
|
+
return new ClientIvcProof(reader.readBuffer());
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
public toBuffer() {
|
|
54
|
-
return serializeToBuffer(
|
|
55
|
-
this.clientIvcProofBuffer.length,
|
|
56
|
-
this.clientIvcProofBuffer,
|
|
57
|
-
this.clientIvcVkBuffer.length,
|
|
58
|
-
this.clientIvcVkBuffer,
|
|
59
|
-
);
|
|
49
|
+
return serializeToBuffer(this.clientIvcProofBuffer.length, this.clientIvcProofBuffer);
|
|
60
50
|
}
|
|
61
51
|
}
|
|
@@ -5,15 +5,19 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
5
5
|
|
|
6
6
|
import { ClientIvcProof } from '../proofs/client_ivc_proof.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Inputs for the tube circuit, which turns a client IVC proof folding stack into an ultrahonk proof.
|
|
10
|
+
* 'usePublicTailVk' signifies if we should prove this with the public or private kernel tail client IVC VKs.
|
|
11
|
+
*/
|
|
8
12
|
export class TubeInputs {
|
|
9
|
-
constructor(public clientIVCData: ClientIvcProof) {}
|
|
13
|
+
constructor(public usePublicTailVk: boolean, public clientIVCData: ClientIvcProof) {}
|
|
10
14
|
|
|
11
15
|
static from(fields: FieldsOf<TubeInputs>): TubeInputs {
|
|
12
16
|
return new TubeInputs(...TubeInputs.getFields(fields));
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
static getFields(fields: FieldsOf<TubeInputs>) {
|
|
16
|
-
return [fields.clientIVCData] as const;
|
|
20
|
+
return [fields.usePublicTailVk, fields.clientIVCData] as const;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
/**
|
|
@@ -39,7 +43,7 @@ export class TubeInputs {
|
|
|
39
43
|
*/
|
|
40
44
|
static fromBuffer(buffer: Buffer | BufferReader): TubeInputs {
|
|
41
45
|
const reader = BufferReader.asReader(buffer);
|
|
42
|
-
return new TubeInputs(reader.readObject(ClientIvcProof));
|
|
46
|
+
return new TubeInputs(reader.readBoolean(), reader.readObject(ClientIvcProof));
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
isEmpty(): boolean {
|
|
@@ -55,7 +59,7 @@ export class TubeInputs {
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
static empty() {
|
|
58
|
-
return new TubeInputs(ClientIvcProof.empty());
|
|
62
|
+
return new TubeInputs(false, ClientIvcProof.empty());
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
/** Returns a hex representation for JSON serialization. */
|
package/src/stats/stats.ts
CHANGED
|
@@ -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' | '
|
|
228
|
+
feePaymentMethod: 'fee_juice' | 'fpc';
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
/**
|
package/src/tests/factories.ts
CHANGED
|
@@ -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 =
|
|
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 {
|
package/src/tests/mocks.ts
CHANGED
|
@@ -11,7 +11,6 @@ import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
|
11
11
|
import type { ContractInstanceWithAddress } from '../contract/index.js';
|
|
12
12
|
import { GasFees } from '../gas/gas_fees.js';
|
|
13
13
|
import { GasSettings } from '../gas/gas_settings.js';
|
|
14
|
-
import { computeVarArgsHash } from '../hash/hash.js';
|
|
15
14
|
import { Nullifier } from '../kernel/nullifier.js';
|
|
16
15
|
import { PrivateCircuitPublicInputs } from '../kernel/private_circuit_public_inputs.js';
|
|
17
16
|
import {
|
|
@@ -26,15 +25,7 @@ import { BlockProposal } from '../p2p/block_proposal.js';
|
|
|
26
25
|
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
27
26
|
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
|
|
28
27
|
import { ClientIvcProof } from '../proofs/client_ivc_proof.js';
|
|
29
|
-
import {
|
|
30
|
-
BlockHeader,
|
|
31
|
-
CallContext,
|
|
32
|
-
CountedPublicExecutionRequest,
|
|
33
|
-
PrivateCallExecutionResult,
|
|
34
|
-
PrivateExecutionResult,
|
|
35
|
-
PublicExecutionRequest,
|
|
36
|
-
Tx,
|
|
37
|
-
} from '../tx/index.js';
|
|
28
|
+
import { BlockHeader, HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx } from '../tx/index.js';
|
|
38
29
|
import { PublicSimulationOutput } from '../tx/public_simulation_output.js';
|
|
39
30
|
import { TxSimulationResult, accumulatePrivateReturnValues } from '../tx/simulated_tx.js';
|
|
40
31
|
import { TxEffect } from '../tx/tx_effect.js';
|
|
@@ -77,70 +68,20 @@ export const randomUniqueNote = async ({
|
|
|
77
68
|
);
|
|
78
69
|
};
|
|
79
70
|
|
|
80
|
-
export const mockPrivateCallExecutionResult = async (
|
|
81
|
-
seed = 1,
|
|
82
|
-
numberOfNonRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2,
|
|
83
|
-
numberOfRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2,
|
|
84
|
-
hasPublicTeardownCallRequest = false,
|
|
85
|
-
) => {
|
|
86
|
-
const totalPublicCallRequests =
|
|
87
|
-
numberOfNonRevertiblePublicCallRequests +
|
|
88
|
-
numberOfRevertiblePublicCallRequests +
|
|
89
|
-
(hasPublicTeardownCallRequest ? 1 : 0);
|
|
90
|
-
const isForPublic = totalPublicCallRequests > 0;
|
|
91
|
-
let enqueuedPublicFunctionCalls: PublicExecutionRequest[] = [];
|
|
92
|
-
let publicTeardownFunctionCall = PublicExecutionRequest.empty();
|
|
93
|
-
if (isForPublic) {
|
|
94
|
-
const publicCallRequests = times(totalPublicCallRequests, i => makePublicCallRequest(seed + 0x102 + i)).reverse(); // Reverse it so that they are sorted by counters in descending order.
|
|
95
|
-
const publicFunctionArgs = times(totalPublicCallRequests, i => [new Fr(seed + i * 100), new Fr(seed + i * 101)]);
|
|
96
|
-
for (let i = 0; i < publicCallRequests.length; i++) {
|
|
97
|
-
const r = publicCallRequests[i];
|
|
98
|
-
r.argsHash = await computeVarArgsHash(publicFunctionArgs[i]);
|
|
99
|
-
i++;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (hasPublicTeardownCallRequest) {
|
|
103
|
-
const request = publicCallRequests.shift()!;
|
|
104
|
-
const args = publicFunctionArgs.shift()!;
|
|
105
|
-
publicTeardownFunctionCall = new PublicExecutionRequest(CallContext.fromFields(request.toFields()), args);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
enqueuedPublicFunctionCalls = publicCallRequests.map(
|
|
109
|
-
(r, i) => new PublicExecutionRequest(CallContext.fromFields(r.toFields()), publicFunctionArgs[i]),
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
return new PrivateCallExecutionResult(
|
|
113
|
-
Buffer.from(''),
|
|
114
|
-
Buffer.from(''),
|
|
115
|
-
new Map(),
|
|
116
|
-
PrivateCircuitPublicInputs.empty(),
|
|
117
|
-
new Map(),
|
|
118
|
-
[],
|
|
119
|
-
new Map(),
|
|
120
|
-
[],
|
|
121
|
-
[],
|
|
122
|
-
enqueuedPublicFunctionCalls.map((call, index) => new CountedPublicExecutionRequest(call, index)),
|
|
123
|
-
publicTeardownFunctionCall,
|
|
124
|
-
[],
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const mockPrivateExecutionResult = async (seed = 1) => {
|
|
129
|
-
return new PrivateExecutionResult(await mockPrivateCallExecutionResult(seed), Fr.zero());
|
|
130
|
-
};
|
|
131
|
-
|
|
132
71
|
export const mockTx = async (
|
|
133
72
|
seed = 1,
|
|
134
73
|
{
|
|
135
74
|
numberOfNonRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2,
|
|
136
75
|
numberOfRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2,
|
|
137
76
|
hasPublicTeardownCallRequest = false,
|
|
77
|
+
publicCalldataSize = 2,
|
|
138
78
|
feePayer,
|
|
139
79
|
clientIvcProof = ClientIvcProof.empty(),
|
|
140
80
|
}: {
|
|
141
81
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
142
82
|
numberOfRevertiblePublicCallRequests?: number;
|
|
143
83
|
hasPublicTeardownCallRequest?: boolean;
|
|
84
|
+
publicCalldataSize?: number;
|
|
144
85
|
feePayer?: AztecAddress;
|
|
145
86
|
clientIvcProof?: ClientIvcProof;
|
|
146
87
|
} = {},
|
|
@@ -155,8 +96,7 @@ export const mockTx = async (
|
|
|
155
96
|
data.constants.txContext.gasSettings = GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) });
|
|
156
97
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
157
98
|
|
|
158
|
-
|
|
159
|
-
let publicTeardownFunctionCall = PublicExecutionRequest.empty();
|
|
99
|
+
const publicFunctionCalldata: HashedValues[] = [];
|
|
160
100
|
if (!isForPublic) {
|
|
161
101
|
data.forRollup!.end.nullifiers[0] = firstNullifier.value;
|
|
162
102
|
} else {
|
|
@@ -166,24 +106,18 @@ export const mockTx = async (
|
|
|
166
106
|
const revertibleBuilder = new PrivateToPublicAccumulatedDataBuilder();
|
|
167
107
|
const nonRevertibleBuilder = new PrivateToPublicAccumulatedDataBuilder();
|
|
168
108
|
|
|
169
|
-
const publicCallRequests = times(totalPublicCallRequests, i => makePublicCallRequest(seed + 0x102 + i))
|
|
170
|
-
const
|
|
109
|
+
const publicCallRequests = times(totalPublicCallRequests, i => makePublicCallRequest(seed + 0x102 + i));
|
|
110
|
+
const calldata = times(totalPublicCallRequests, i => times(publicCalldataSize, j => new Fr(seed + (i * 13 + j))));
|
|
171
111
|
for (let i = 0; i < publicCallRequests.length; i++) {
|
|
172
|
-
const
|
|
173
|
-
|
|
112
|
+
const hashedCalldata = await HashedValues.fromCalldata(calldata[i]);
|
|
113
|
+
publicFunctionCalldata.push(hashedCalldata);
|
|
114
|
+
publicCallRequests[i].calldataHash = hashedCalldata.hash;
|
|
174
115
|
}
|
|
175
116
|
|
|
176
117
|
if (hasPublicTeardownCallRequest) {
|
|
177
|
-
|
|
178
|
-
data.forPublic.publicTeardownCallRequest = request;
|
|
179
|
-
const args = publicFunctionArgs.shift()!;
|
|
180
|
-
publicTeardownFunctionCall = new PublicExecutionRequest(CallContext.fromFields(request.toFields()), args);
|
|
118
|
+
data.forPublic.publicTeardownCallRequest = publicCallRequests.pop()!;
|
|
181
119
|
}
|
|
182
120
|
|
|
183
|
-
enqueuedPublicFunctionCalls = publicCallRequests.map(
|
|
184
|
-
(r, i) => new PublicExecutionRequest(CallContext.fromFields(r.toFields()), publicFunctionArgs[i]),
|
|
185
|
-
);
|
|
186
|
-
|
|
187
121
|
data.forPublic.nonRevertibleAccumulatedData = nonRevertibleBuilder
|
|
188
122
|
.pushNullifier(firstNullifier.value)
|
|
189
123
|
.withPublicCallRequests(publicCallRequests.slice(numberOfRevertiblePublicCallRequests))
|
|
@@ -194,16 +128,30 @@ export const mockTx = async (
|
|
|
194
128
|
.build();
|
|
195
129
|
}
|
|
196
130
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return tx;
|
|
131
|
+
return new Tx(data, clientIvcProof, [], publicFunctionCalldata);
|
|
200
132
|
};
|
|
201
133
|
|
|
202
134
|
export const mockTxForRollup = (seed = 1) =>
|
|
203
135
|
mockTx(seed, { numberOfNonRevertiblePublicCallRequests: 0, numberOfRevertiblePublicCallRequests: 0 });
|
|
204
136
|
|
|
137
|
+
const emptyPrivateCallExecutionResult = () =>
|
|
138
|
+
new PrivateCallExecutionResult(
|
|
139
|
+
Buffer.from(''),
|
|
140
|
+
Buffer.from(''),
|
|
141
|
+
new Map(),
|
|
142
|
+
PrivateCircuitPublicInputs.empty(),
|
|
143
|
+
new Map(),
|
|
144
|
+
[],
|
|
145
|
+
new Map(),
|
|
146
|
+
[],
|
|
147
|
+
[],
|
|
148
|
+
[],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const emptyPrivateExecutionResult = () => new PrivateExecutionResult(emptyPrivateCallExecutionResult(), Fr.zero(), []);
|
|
152
|
+
|
|
205
153
|
export const mockSimulatedTx = async (seed = 1) => {
|
|
206
|
-
const privateExecutionResult =
|
|
154
|
+
const privateExecutionResult = emptyPrivateExecutionResult();
|
|
207
155
|
const tx = await mockTx(seed);
|
|
208
156
|
const output = new PublicSimulationOutput(
|
|
209
157
|
undefined,
|
|
@@ -56,4 +56,16 @@ export class NullifierMembershipWitness {
|
|
|
56
56
|
public toFields(): Fr[] {
|
|
57
57
|
return [new Fr(this.index), ...this.leafPreimage.toFields(), ...this.siblingPath.toFields()];
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns a representation of the nullifier membership witness as expected by intrinsic Noir deserialization.
|
|
62
|
+
*/
|
|
63
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
64
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
65
|
+
return [
|
|
66
|
+
new Fr(this.index).toString() as string,
|
|
67
|
+
...(this.leafPreimage.toFields().map(fr => fr.toString()) as string[]),
|
|
68
|
+
this.siblingPath.toFields().map(fr => fr.toString()) as string[],
|
|
69
|
+
];
|
|
70
|
+
}
|
|
59
71
|
}
|
|
@@ -58,6 +58,21 @@ export class PublicDataWitness {
|
|
|
58
58
|
];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Returns a representation of the public data witness as expected by intrinsic Noir deserialization.
|
|
63
|
+
*/
|
|
64
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
65
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
66
|
+
return [
|
|
67
|
+
new Fr(this.index).toString() as string,
|
|
68
|
+
new Fr(this.leafPreimage.slot).toString() as string,
|
|
69
|
+
new Fr(this.leafPreimage.value).toString() as string,
|
|
70
|
+
new Fr(this.leafPreimage.nextSlot).toString() as string,
|
|
71
|
+
new Fr(this.leafPreimage.nextIndex).toString() as string,
|
|
72
|
+
this.siblingPath.toFields().map(fr => fr.toString()) as string[],
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
61
76
|
toBuffer(): Buffer {
|
|
62
77
|
return serializeToBuffer([this.index, this.leafPreimage, this.siblingPath]);
|
|
63
78
|
}
|
package/src/tx/hashed_values.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
4
|
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
|
|
6
|
-
import { computeVarArgsHash } from '../hash/index.js';
|
|
7
|
+
import { computeCalldataHash, computeVarArgsHash } from '../hash/index.js';
|
|
7
8
|
import { type ZodFor, schemas } from '../schemas/schemas.js';
|
|
8
9
|
import { Vector } from '../types/index.js';
|
|
9
10
|
|
|
@@ -11,7 +12,7 @@ import { Vector } from '../types/index.js';
|
|
|
11
12
|
* A container for storing a list of values and their hash.
|
|
12
13
|
*/
|
|
13
14
|
export class HashedValues {
|
|
14
|
-
|
|
15
|
+
constructor(
|
|
15
16
|
/**
|
|
16
17
|
* Raw values.
|
|
17
18
|
*/
|
|
@@ -22,20 +23,29 @@ export class HashedValues {
|
|
|
22
23
|
public readonly hash: Fr,
|
|
23
24
|
) {}
|
|
24
25
|
|
|
26
|
+
getSize() {
|
|
27
|
+
return this.values.length + 1 /* hash */;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
static get schema(): ZodFor<HashedValues> {
|
|
26
|
-
return z
|
|
31
|
+
return z
|
|
32
|
+
.object({
|
|
33
|
+
values: z.array(schemas.Fr),
|
|
34
|
+
hash: schemas.Fr,
|
|
35
|
+
})
|
|
36
|
+
.transform(HashedValues.from);
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
return
|
|
39
|
+
static from(fields: FieldsOf<HashedValues>): HashedValues {
|
|
40
|
+
return new HashedValues(...HashedValues.getFields(fields));
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
static
|
|
34
|
-
return
|
|
43
|
+
static getFields(fields: FieldsOf<HashedValues>) {
|
|
44
|
+
return [fields.values, fields.hash] as const;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
static
|
|
38
|
-
return new HashedValues(
|
|
47
|
+
static random() {
|
|
48
|
+
return new HashedValues([Fr.random(), Fr.random()], Fr.random());
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
toBuffer() {
|
|
@@ -46,4 +56,14 @@ export class HashedValues {
|
|
|
46
56
|
const reader = BufferReader.asReader(buffer);
|
|
47
57
|
return new HashedValues(reader.readVector(Fr), Fr.fromBuffer(reader));
|
|
48
58
|
}
|
|
59
|
+
|
|
60
|
+
// Computes the hash of input arguments or return values for private functions, or for authwit creation.
|
|
61
|
+
static async fromArgs(args: Fr[]) {
|
|
62
|
+
return new HashedValues(args, await computeVarArgsHash(args));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Computes the hash of calldata for public functions.
|
|
66
|
+
static async fromCalldata(calldata: Fr[]) {
|
|
67
|
+
return new HashedValues(calldata, await computeCalldataHash(calldata));
|
|
68
|
+
}
|
|
49
69
|
}
|
package/src/tx/index.ts
CHANGED
|
@@ -11,11 +11,13 @@ export * from './tx_constant_data.js';
|
|
|
11
11
|
export * from './tx_context.js';
|
|
12
12
|
export * from './tx_request.js';
|
|
13
13
|
export * from './private_execution_result.js';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './public_call_request_with_calldata.js';
|
|
15
15
|
export * from './tx_hash.js';
|
|
16
16
|
export * from './tx_receipt.js';
|
|
17
17
|
export * from './tx.js';
|
|
18
18
|
export * from './processed_tx.js';
|
|
19
|
+
export * from './proven_tx.js';
|
|
20
|
+
export * from './profiled_tx.js';
|
|
19
21
|
export * from './simulated_tx.js';
|
|
20
22
|
export * from './tx_effect.js';
|
|
21
23
|
export * from './public_simulation_output.js';
|