@aztec/stdlib 3.0.0-nightly.20251104 → 3.0.0-nightly.20251106
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/avm/avm.d.ts +2202 -250
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +93 -14
- package/dest/avm/avm_accumulated_data.d.ts +7 -7
- package/dest/avm/avm_circuit_public_inputs.d.ts +27 -27
- package/dest/avm/avm_proving_request.d.ts +667 -118
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/contract/contract_deployment_data.d.ts +111 -0
- package/dest/contract/contract_deployment_data.d.ts.map +1 -0
- package/dest/contract/contract_deployment_data.js +87 -0
- package/dest/contract/index.d.ts +1 -0
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +1 -0
- package/dest/contract/interfaces/contract_class.d.ts +16 -16
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/hash/hash.d.ts +9 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +11 -1
- package/dest/interfaces/get_logs_response.d.ts +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +2 -2
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +667 -118
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/kernel/private_to_avm_accumulated_data.d.ts +7 -7
- package/dest/logs/extended_public_log.d.ts +1 -1
- package/dest/messaging/l2_to_l1_message.d.ts +20 -20
- package/dest/slashing/types.d.ts +1 -1
- package/dest/snapshots/types.d.ts +4 -4
- package/dest/tests/factories.d.ts +11 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +24 -8
- package/dest/world-state/world_state_revision.d.ts +33 -1
- package/dest/world-state/world_state_revision.d.ts.map +1 -1
- package/dest/world-state/world_state_revision.js +24 -1
- package/dest/zkpassport/index.d.ts +1 -3
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +5 -10
- package/package.json +8 -8
- package/src/avm/avm.ts +100 -3
- package/src/contract/contract_deployment_data.ts +108 -0
- package/src/contract/index.ts +1 -0
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/hash/hash.ts +13 -2
- package/src/interfaces/merkle_tree_operations.ts +2 -2
- package/src/tests/factories.ts +29 -3
- package/src/world-state/world_state_revision.ts +47 -5
- package/src/zkpassport/index.ts +0 -8
package/dest/zkpassport/index.js
CHANGED
|
@@ -11,17 +11,15 @@ export class ZkPassportProofParams {
|
|
|
11
11
|
proof;
|
|
12
12
|
publicInputs;
|
|
13
13
|
committedInputs;
|
|
14
|
-
committedInputCounts;
|
|
15
14
|
validityPeriodInSeconds;
|
|
16
15
|
domain;
|
|
17
16
|
scope;
|
|
18
|
-
constructor(devMode, vkeyHash, proof, publicInputs, committedInputs,
|
|
17
|
+
constructor(devMode, vkeyHash, proof, publicInputs, committedInputs, validityPeriodInSeconds, domain, scope){
|
|
19
18
|
this.devMode = devMode;
|
|
20
19
|
this.vkeyHash = vkeyHash;
|
|
21
20
|
this.proof = proof;
|
|
22
21
|
this.publicInputs = publicInputs;
|
|
23
22
|
this.committedInputs = committedInputs;
|
|
24
|
-
this.committedInputCounts = committedInputCounts;
|
|
25
23
|
this.validityPeriodInSeconds = validityPeriodInSeconds;
|
|
26
24
|
this.domain = domain;
|
|
27
25
|
this.scope = scope;
|
|
@@ -36,8 +34,6 @@ export class ZkPassportProofParams {
|
|
|
36
34
|
this.publicInputs,
|
|
37
35
|
this.committedInputs.length,
|
|
38
36
|
this.committedInputs,
|
|
39
|
-
this.committedInputCounts.length,
|
|
40
|
-
this.committedInputCounts,
|
|
41
37
|
this.validityPeriodInSeconds,
|
|
42
38
|
this.domain,
|
|
43
39
|
this.scope
|
|
@@ -56,14 +52,14 @@ export class ZkPassportProofParams {
|
|
|
56
52
|
const publicInputs = Array.from({
|
|
57
53
|
length: Number(publicInputsCount)
|
|
58
54
|
}, ()=>Fr.random());
|
|
59
|
-
return new ZkPassportProofParams(false, Buffer32.random(), randomBytes(1024), publicInputs, committedInputs,
|
|
55
|
+
return new ZkPassportProofParams(false, Buffer32.random(), randomBytes(1024), publicInputs, committedInputs, BigInt(7 * 24 * 60 * 60), 'sequencer.alpha-testnet.aztec.network', 'personhood');
|
|
60
56
|
}
|
|
61
57
|
static fromBuffer(buffer) {
|
|
62
58
|
const reader = BufferReader.asReader(buffer);
|
|
63
|
-
return new ZkPassportProofParams(reader.readBoolean(), reader.readObject(Buffer32), reader.readBuffer(), reader.readVector(Fr), reader.readBuffer(), reader.
|
|
59
|
+
return new ZkPassportProofParams(reader.readBoolean(), reader.readObject(Buffer32), reader.readBuffer(), reader.readVector(Fr), reader.readBuffer(), reader.readUInt256(), reader.readString(), reader.readString());
|
|
64
60
|
}
|
|
65
61
|
static fromViem(params) {
|
|
66
|
-
return new ZkPassportProofParams(params.serviceConfig.devMode, Buffer32.fromString(params.proofVerificationData.vkeyHash), Buffer.from(withoutHexPrefix(params.proofVerificationData.proof), 'hex'), params.proofVerificationData.publicInputs.map((input)=>Fr.fromString(input)), Buffer.from(withoutHexPrefix(params.commitments.committedInputs), 'hex'), params.
|
|
62
|
+
return new ZkPassportProofParams(params.serviceConfig.devMode, Buffer32.fromString(params.proofVerificationData.vkeyHash), Buffer.from(withoutHexPrefix(params.proofVerificationData.proof), 'hex'), params.proofVerificationData.publicInputs.map((input)=>Fr.fromString(input)), Buffer.from(withoutHexPrefix(params.commitments.committedInputs), 'hex'), params.serviceConfig.validityPeriodInSeconds, params.serviceConfig.domain, params.serviceConfig.scope);
|
|
67
63
|
}
|
|
68
64
|
toViem() {
|
|
69
65
|
return {
|
|
@@ -79,8 +75,7 @@ export class ZkPassportProofParams {
|
|
|
79
75
|
publicInputs: this.publicInputs.map((input)=>input.toString())
|
|
80
76
|
},
|
|
81
77
|
commitments: {
|
|
82
|
-
committedInputs: `0x${this.committedInputs.toString('hex')}
|
|
83
|
-
committedInputCounts: this.committedInputCounts
|
|
78
|
+
committedInputs: `0x${this.committedInputs.toString('hex')}`
|
|
84
79
|
}
|
|
85
80
|
};
|
|
86
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251106",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
75
|
-
"@aztec/bb.js": "3.0.0-nightly.
|
|
76
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
77
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
78
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
79
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
80
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
81
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
75
|
+
"@aztec/bb.js": "3.0.0-nightly.20251106",
|
|
76
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251106",
|
|
77
|
+
"@aztec/constants": "3.0.0-nightly.20251106",
|
|
78
|
+
"@aztec/ethereum": "3.0.0-nightly.20251106",
|
|
79
|
+
"@aztec/foundation": "3.0.0-nightly.20251106",
|
|
80
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251106",
|
|
81
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251106",
|
|
82
82
|
"@google-cloud/storage": "^7.15.0",
|
|
83
83
|
"axios": "^1.12.0",
|
|
84
84
|
"json-stringify-deterministic": "1.0.12",
|
package/src/avm/avm.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { schemas } from '@aztec/foundation/schemas';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
7
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
8
|
+
import { AllContractDeploymentData, ContractDeploymentData } from '../contract/index.js';
|
|
8
9
|
import { computeEffectiveGasFees } from '../fees/transaction_fee.js';
|
|
9
10
|
import { Gas } from '../gas/gas.js';
|
|
10
11
|
import { GasFees } from '../gas/gas_fees.js';
|
|
@@ -22,6 +23,7 @@ import {
|
|
|
22
23
|
TreeSnapshots,
|
|
23
24
|
type Tx,
|
|
24
25
|
} from '../tx/index.js';
|
|
26
|
+
import { WorldStateRevision } from '../world-state/world_state_revision.js';
|
|
25
27
|
import { AvmCircuitPublicInputs } from './avm_circuit_public_inputs.js';
|
|
26
28
|
import { serializeWithMessagePack } from './message_pack.js';
|
|
27
29
|
|
|
@@ -30,6 +32,7 @@ import { serializeWithMessagePack } from './message_pack.js';
|
|
|
30
32
|
////////////////////////////////////////////////////////////////////////////
|
|
31
33
|
export class AvmContractClassHint {
|
|
32
34
|
constructor(
|
|
35
|
+
public readonly hintKey: number,
|
|
33
36
|
public readonly classId: Fr,
|
|
34
37
|
public readonly artifactHash: Fr,
|
|
35
38
|
public readonly privateFunctionsRoot: Fr,
|
|
@@ -39,20 +42,22 @@ export class AvmContractClassHint {
|
|
|
39
42
|
static get schema() {
|
|
40
43
|
return z
|
|
41
44
|
.object({
|
|
45
|
+
hintKey: z.number().int().nonnegative(),
|
|
42
46
|
classId: schemas.Fr,
|
|
43
47
|
artifactHash: schemas.Fr,
|
|
44
48
|
privateFunctionsRoot: schemas.Fr,
|
|
45
49
|
packedBytecode: schemas.Buffer,
|
|
46
50
|
})
|
|
47
51
|
.transform(
|
|
48
|
-
({ classId, artifactHash, privateFunctionsRoot, packedBytecode }) =>
|
|
49
|
-
new AvmContractClassHint(classId, artifactHash, privateFunctionsRoot, packedBytecode),
|
|
52
|
+
({ hintKey, classId, artifactHash, privateFunctionsRoot, packedBytecode }) =>
|
|
53
|
+
new AvmContractClassHint(hintKey, classId, artifactHash, privateFunctionsRoot, packedBytecode),
|
|
50
54
|
);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
export class AvmBytecodeCommitmentHint {
|
|
55
59
|
constructor(
|
|
60
|
+
public readonly hintKey: number,
|
|
56
61
|
public readonly classId: Fr,
|
|
57
62
|
public readonly commitment: Fr,
|
|
58
63
|
) {}
|
|
@@ -60,15 +65,17 @@ export class AvmBytecodeCommitmentHint {
|
|
|
60
65
|
static get schema() {
|
|
61
66
|
return z
|
|
62
67
|
.object({
|
|
68
|
+
hintKey: z.number().int().nonnegative(),
|
|
63
69
|
classId: schemas.Fr,
|
|
64
70
|
commitment: schemas.Fr,
|
|
65
71
|
})
|
|
66
|
-
.transform(({ classId, commitment }) => new AvmBytecodeCommitmentHint(classId, commitment));
|
|
72
|
+
.transform(({ hintKey, classId, commitment }) => new AvmBytecodeCommitmentHint(hintKey, classId, commitment));
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
export class AvmContractInstanceHint {
|
|
71
77
|
constructor(
|
|
78
|
+
public readonly hintKey: number,
|
|
72
79
|
public readonly address: AztecAddress,
|
|
73
80
|
public readonly salt: Fr,
|
|
74
81
|
public readonly deployer: AztecAddress,
|
|
@@ -81,6 +88,7 @@ export class AvmContractInstanceHint {
|
|
|
81
88
|
static get schema() {
|
|
82
89
|
return z
|
|
83
90
|
.object({
|
|
91
|
+
hintKey: z.number().int().nonnegative(),
|
|
84
92
|
address: AztecAddress.schema,
|
|
85
93
|
salt: schemas.Fr,
|
|
86
94
|
deployer: AztecAddress.schema,
|
|
@@ -91,6 +99,7 @@ export class AvmContractInstanceHint {
|
|
|
91
99
|
})
|
|
92
100
|
.transform(
|
|
93
101
|
({
|
|
102
|
+
hintKey,
|
|
94
103
|
address,
|
|
95
104
|
salt,
|
|
96
105
|
deployer,
|
|
@@ -100,6 +109,7 @@ export class AvmContractInstanceHint {
|
|
|
100
109
|
publicKeys,
|
|
101
110
|
}) =>
|
|
102
111
|
new AvmContractInstanceHint(
|
|
112
|
+
hintKey,
|
|
103
113
|
address,
|
|
104
114
|
salt,
|
|
105
115
|
deployer,
|
|
@@ -112,6 +122,24 @@ export class AvmContractInstanceHint {
|
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
|
|
125
|
+
export class AvmDebugFunctionNameHint {
|
|
126
|
+
constructor(
|
|
127
|
+
public readonly address: AztecAddress,
|
|
128
|
+
public readonly selector: Fr,
|
|
129
|
+
public readonly name: string,
|
|
130
|
+
) {}
|
|
131
|
+
|
|
132
|
+
static get schema() {
|
|
133
|
+
return z
|
|
134
|
+
.object({
|
|
135
|
+
address: AztecAddress.schema,
|
|
136
|
+
selector: schemas.Fr,
|
|
137
|
+
name: z.string(),
|
|
138
|
+
})
|
|
139
|
+
.transform(({ address, selector, name }) => new AvmDebugFunctionNameHint(address, selector, name));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
////////////////////////////////////////////////////////////////////////////
|
|
116
144
|
// Hints (merkle db)
|
|
117
145
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -387,6 +415,10 @@ export class AvmRevertCheckpointHint {
|
|
|
387
415
|
}
|
|
388
416
|
}
|
|
389
417
|
|
|
418
|
+
export class AvmContractDBCreateCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
|
|
419
|
+
export class AvmContractDBCommitCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
|
|
420
|
+
export class AvmContractDBRevertCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
|
|
421
|
+
|
|
390
422
|
////////////////////////////////////////////////////////////////////////////
|
|
391
423
|
// Hints (other)
|
|
392
424
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -395,6 +427,8 @@ export class AvmTxHint {
|
|
|
395
427
|
public readonly hash: string,
|
|
396
428
|
public readonly gasSettings: GasSettings,
|
|
397
429
|
public readonly effectiveGasFees: GasFees,
|
|
430
|
+
public readonly nonRevertibleContractDeploymentData: ContractDeploymentData,
|
|
431
|
+
public readonly revertibleContractDeploymentData: ContractDeploymentData,
|
|
398
432
|
public readonly nonRevertibleAccumulatedData: {
|
|
399
433
|
noteHashes: Fr[];
|
|
400
434
|
nullifiers: Fr[];
|
|
@@ -420,6 +454,7 @@ export class AvmTxHint {
|
|
|
420
454
|
const teardownCallRequest = tx.getTeardownPublicCallRequestWithCalldata();
|
|
421
455
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
422
456
|
const effectiveGasFees = computeEffectiveGasFees(gasFees, gasSettings);
|
|
457
|
+
const allContractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
423
458
|
|
|
424
459
|
// For informational purposes. Assumed quick because it should be cached.
|
|
425
460
|
const txHash = tx.getTxHash();
|
|
@@ -428,6 +463,8 @@ export class AvmTxHint {
|
|
|
428
463
|
txHash.hash.toString(),
|
|
429
464
|
gasSettings,
|
|
430
465
|
effectiveGasFees,
|
|
466
|
+
allContractDeploymentData.getNonRevertibleContractDeploymentData(),
|
|
467
|
+
allContractDeploymentData.getRevertibleContractDeploymentData(),
|
|
431
468
|
{
|
|
432
469
|
noteHashes: tx.data.forPublic!.nonRevertibleAccumulatedData.noteHashes.filter(x => !x.isZero()),
|
|
433
470
|
nullifiers: tx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers.filter(x => !x.isZero()),
|
|
@@ -451,6 +488,8 @@ export class AvmTxHint {
|
|
|
451
488
|
'',
|
|
452
489
|
GasSettings.empty(),
|
|
453
490
|
GasFees.empty(),
|
|
491
|
+
ContractDeploymentData.empty(),
|
|
492
|
+
ContractDeploymentData.empty(),
|
|
454
493
|
{ noteHashes: [], nullifiers: [], l2ToL1Messages: [] },
|
|
455
494
|
{ noteHashes: [], nullifiers: [], l2ToL1Messages: [] },
|
|
456
495
|
[],
|
|
@@ -467,6 +506,8 @@ export class AvmTxHint {
|
|
|
467
506
|
hash: z.string(),
|
|
468
507
|
gasSettings: GasSettings.schema,
|
|
469
508
|
effectiveGasFees: GasFees.schema,
|
|
509
|
+
nonRevertibleContractDeploymentData: ContractDeploymentData.schema,
|
|
510
|
+
revertibleContractDeploymentData: ContractDeploymentData.schema,
|
|
470
511
|
nonRevertibleAccumulatedData: z.object({
|
|
471
512
|
noteHashes: schemas.Fr.array(),
|
|
472
513
|
nullifiers: schemas.Fr.array(),
|
|
@@ -488,6 +529,8 @@ export class AvmTxHint {
|
|
|
488
529
|
hash,
|
|
489
530
|
gasSettings,
|
|
490
531
|
effectiveGasFees,
|
|
532
|
+
nonRevertibleContractDeploymentData,
|
|
533
|
+
revertibleContractDeploymentData,
|
|
491
534
|
nonRevertibleAccumulatedData,
|
|
492
535
|
revertibleAccumulatedData,
|
|
493
536
|
setupEnqueuedCalls,
|
|
@@ -500,6 +543,8 @@ export class AvmTxHint {
|
|
|
500
543
|
hash,
|
|
501
544
|
gasSettings,
|
|
502
545
|
effectiveGasFees,
|
|
546
|
+
nonRevertibleContractDeploymentData,
|
|
547
|
+
revertibleContractDeploymentData,
|
|
503
548
|
nonRevertibleAccumulatedData,
|
|
504
549
|
revertibleAccumulatedData,
|
|
505
550
|
setupEnqueuedCalls,
|
|
@@ -522,6 +567,7 @@ export class AvmExecutionHints {
|
|
|
522
567
|
public readonly contractInstances: AvmContractInstanceHint[] = [],
|
|
523
568
|
public readonly contractClasses: AvmContractClassHint[] = [],
|
|
524
569
|
public readonly bytecodeCommitments: AvmBytecodeCommitmentHint[] = [],
|
|
570
|
+
public readonly debugFunctionNames: AvmDebugFunctionNameHint[] = [],
|
|
525
571
|
// Merkle DB hints.
|
|
526
572
|
public startingTreeRoots: TreeSnapshots = TreeSnapshots.empty(),
|
|
527
573
|
public readonly getSiblingPathHints: AvmGetSiblingPathHint[] = [],
|
|
@@ -535,6 +581,9 @@ export class AvmExecutionHints {
|
|
|
535
581
|
public readonly createCheckpointHints: AvmCreateCheckpointHint[] = [],
|
|
536
582
|
public readonly commitCheckpointHints: AvmCommitCheckpointHint[] = [],
|
|
537
583
|
public readonly revertCheckpointHints: AvmRevertCheckpointHint[] = [],
|
|
584
|
+
public readonly contractDBCreateCheckpointHints: AvmContractDBCreateCheckpointHint[] = [],
|
|
585
|
+
public readonly contractDBCommitCheckpointHints: AvmContractDBCommitCheckpointHint[] = [],
|
|
586
|
+
public readonly contractDBRevertCheckpointHints: AvmContractDBRevertCheckpointHint[] = [],
|
|
538
587
|
) {}
|
|
539
588
|
|
|
540
589
|
static empty() {
|
|
@@ -550,6 +599,7 @@ export class AvmExecutionHints {
|
|
|
550
599
|
contractInstances: AvmContractInstanceHint.schema.array(),
|
|
551
600
|
contractClasses: AvmContractClassHint.schema.array(),
|
|
552
601
|
bytecodeCommitments: AvmBytecodeCommitmentHint.schema.array(),
|
|
602
|
+
debugFunctionNames: AvmDebugFunctionNameHint.schema.array(),
|
|
553
603
|
startingTreeRoots: TreeSnapshots.schema,
|
|
554
604
|
getSiblingPathHints: AvmGetSiblingPathHint.schema.array(),
|
|
555
605
|
getPreviousValueIndexHints: AvmGetPreviousValueIndexHint.schema.array(),
|
|
@@ -562,6 +612,9 @@ export class AvmExecutionHints {
|
|
|
562
612
|
createCheckpointHints: AvmCreateCheckpointHint.schema.array(),
|
|
563
613
|
commitCheckpointHints: AvmCommitCheckpointHint.schema.array(),
|
|
564
614
|
revertCheckpointHints: AvmRevertCheckpointHint.schema.array(),
|
|
615
|
+
contractDBCreateCheckpointHints: AvmContractDBCreateCheckpointHint.schema.array(),
|
|
616
|
+
contractDBCommitCheckpointHints: AvmContractDBCommitCheckpointHint.schema.array(),
|
|
617
|
+
contractDBRevertCheckpointHints: AvmContractDBRevertCheckpointHint.schema.array(),
|
|
565
618
|
})
|
|
566
619
|
.transform(
|
|
567
620
|
({
|
|
@@ -571,6 +624,7 @@ export class AvmExecutionHints {
|
|
|
571
624
|
contractInstances,
|
|
572
625
|
contractClasses,
|
|
573
626
|
bytecodeCommitments,
|
|
627
|
+
debugFunctionNames,
|
|
574
628
|
startingTreeRoots,
|
|
575
629
|
getSiblingPathHints,
|
|
576
630
|
getPreviousValueIndexHints,
|
|
@@ -583,6 +637,9 @@ export class AvmExecutionHints {
|
|
|
583
637
|
createCheckpointHints,
|
|
584
638
|
commitCheckpointHints,
|
|
585
639
|
revertCheckpointHints,
|
|
640
|
+
contractDBCreateCheckpointHints,
|
|
641
|
+
contractDBCommitCheckpointHints,
|
|
642
|
+
contractDBRevertCheckpointHints,
|
|
586
643
|
}) =>
|
|
587
644
|
new AvmExecutionHints(
|
|
588
645
|
globalVariables,
|
|
@@ -591,6 +648,7 @@ export class AvmExecutionHints {
|
|
|
591
648
|
contractInstances,
|
|
592
649
|
contractClasses,
|
|
593
650
|
bytecodeCommitments,
|
|
651
|
+
debugFunctionNames,
|
|
594
652
|
startingTreeRoots,
|
|
595
653
|
getSiblingPathHints,
|
|
596
654
|
getPreviousValueIndexHints,
|
|
@@ -603,6 +661,9 @@ export class AvmExecutionHints {
|
|
|
603
661
|
createCheckpointHints,
|
|
604
662
|
commitCheckpointHints,
|
|
605
663
|
revertCheckpointHints,
|
|
664
|
+
contractDBCreateCheckpointHints,
|
|
665
|
+
contractDBCommitCheckpointHints,
|
|
666
|
+
contractDBRevertCheckpointHints,
|
|
606
667
|
),
|
|
607
668
|
);
|
|
608
669
|
}
|
|
@@ -639,3 +700,39 @@ export class AvmCircuitInputs {
|
|
|
639
700
|
return jsonParseWithSchema(buf.toString(), this.schema);
|
|
640
701
|
}
|
|
641
702
|
}
|
|
703
|
+
|
|
704
|
+
export class AvmFastSimulationInputs {
|
|
705
|
+
constructor(
|
|
706
|
+
public readonly wsRevision: WorldStateRevision,
|
|
707
|
+
public tx: AvmTxHint,
|
|
708
|
+
public globalVariables: GlobalVariables,
|
|
709
|
+
public protocolContracts: ProtocolContracts,
|
|
710
|
+
) {}
|
|
711
|
+
|
|
712
|
+
static empty() {
|
|
713
|
+
return new AvmFastSimulationInputs(
|
|
714
|
+
WorldStateRevision.empty(),
|
|
715
|
+
AvmTxHint.empty(),
|
|
716
|
+
GlobalVariables.empty(),
|
|
717
|
+
ProtocolContracts.empty(),
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
static get schema() {
|
|
722
|
+
return z
|
|
723
|
+
.object({
|
|
724
|
+
wsRevision: WorldStateRevision.schema,
|
|
725
|
+
tx: AvmTxHint.schema,
|
|
726
|
+
globalVariables: GlobalVariables.schema,
|
|
727
|
+
protocolContracts: ProtocolContracts.schema,
|
|
728
|
+
})
|
|
729
|
+
.transform(
|
|
730
|
+
({ wsRevision, tx, globalVariables, protocolContracts }) =>
|
|
731
|
+
new AvmFastSimulationInputs(wsRevision, tx, globalVariables, protocolContracts),
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
public serializeWithMessagePack(): Buffer {
|
|
736
|
+
return serializeWithMessagePack(this);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ContractClassLog, PrivateLog } from '@aztec/stdlib/logs';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class containing contract class logs and private logs which are both
|
|
8
|
+
* relevant for contract registrations and deployments.
|
|
9
|
+
*/
|
|
10
|
+
export class ContractDeploymentData {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly contractClassLogs: ContractClassLog[],
|
|
13
|
+
public readonly privateLogs: PrivateLog[],
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
public getContractClassLogs(): ContractClassLog[] {
|
|
17
|
+
return this.contractClassLogs;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public getPrivateLogs(): PrivateLog[] {
|
|
21
|
+
return this.privateLogs;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static from(args: { contractClassLogs: ContractClassLog[]; privateLogs: PrivateLog[] }) {
|
|
25
|
+
return new ContractDeploymentData(args.contractClassLogs, args.privateLogs);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static empty(): ContractDeploymentData {
|
|
29
|
+
return new ContractDeploymentData([], []);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static get schema() {
|
|
33
|
+
return z
|
|
34
|
+
.object({
|
|
35
|
+
contractClassLogs: z.array(ContractClassLog.schema),
|
|
36
|
+
privateLogs: z.array(PrivateLog.schema),
|
|
37
|
+
})
|
|
38
|
+
.transform(ContractDeploymentData.from);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Class containing both revertible and non-revertible registration/deployment data.
|
|
44
|
+
*/
|
|
45
|
+
export class AllContractDeploymentData {
|
|
46
|
+
constructor(
|
|
47
|
+
public readonly nonRevertibleContractDeploymentData: ContractDeploymentData,
|
|
48
|
+
public readonly revertibleContractDeploymentData: ContractDeploymentData,
|
|
49
|
+
) {}
|
|
50
|
+
|
|
51
|
+
public getNonRevertibleContractDeploymentData(): ContractDeploymentData {
|
|
52
|
+
return this.nonRevertibleContractDeploymentData;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public getRevertibleContractDeploymentData(): ContractDeploymentData {
|
|
56
|
+
return this.revertibleContractDeploymentData;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Extracts all contract registration/deployment data from a tx separated by revertibility.
|
|
61
|
+
* This includes contract class logs and private logs.
|
|
62
|
+
*
|
|
63
|
+
* This method handles both private-only transactions and transactions with public calls,
|
|
64
|
+
* properly splitting logs between revertible and non-revertible categories.
|
|
65
|
+
* @param tx - The transaction to extract data from
|
|
66
|
+
* @returns The extracted deployment data separated by revertibility
|
|
67
|
+
*/
|
|
68
|
+
static fromTx(tx: Tx): AllContractDeploymentData {
|
|
69
|
+
const hasPublicCalls = !!tx.data.forPublic;
|
|
70
|
+
|
|
71
|
+
// Extract contract class logs from the tx
|
|
72
|
+
const allClassLogs = tx.getContractClassLogs();
|
|
73
|
+
let nonRevertibleClassLogs: ContractClassLog[];
|
|
74
|
+
let revertibleClassLogs: ContractClassLog[];
|
|
75
|
+
|
|
76
|
+
if (hasPublicCalls) {
|
|
77
|
+
// Transactions with public calls can have both revertible and non-revertible contract class logs
|
|
78
|
+
// Split the logs up here based on revertibility
|
|
79
|
+
nonRevertibleClassLogs = tx.getSplitContractClassLogs(/*revertible=*/ false);
|
|
80
|
+
revertibleClassLogs = tx.getSplitContractClassLogs(/*revertible=*/ true);
|
|
81
|
+
} else {
|
|
82
|
+
// Private-only tx: all logs are non-revertible
|
|
83
|
+
nonRevertibleClassLogs = allClassLogs;
|
|
84
|
+
revertibleClassLogs = [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Extract contract instance logs from the transaction's private logs
|
|
88
|
+
let nonRevertibleInstanceLogs: PrivateLog[];
|
|
89
|
+
let revertibleInstanceLogs: PrivateLog[];
|
|
90
|
+
|
|
91
|
+
if (hasPublicCalls) {
|
|
92
|
+
// Transactions with public calls can have both revertible and non-revertible contract instance logs
|
|
93
|
+
// Split the logs up here based on revertibility
|
|
94
|
+
nonRevertibleInstanceLogs = tx.data.forPublic!.nonRevertibleAccumulatedData.privateLogs.filter(l => !l.isEmpty());
|
|
95
|
+
revertibleInstanceLogs = tx.data.forPublic!.revertibleAccumulatedData.privateLogs.filter(l => !l.isEmpty());
|
|
96
|
+
} else {
|
|
97
|
+
// Private-only tx: use logs from the `forRollup` member of the tx
|
|
98
|
+
// For private-only txs, all logs are non-revertible
|
|
99
|
+
nonRevertibleInstanceLogs = tx.data.forRollup!.end.privateLogs.filter(l => !l.isEmpty());
|
|
100
|
+
revertibleInstanceLogs = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return new AllContractDeploymentData(
|
|
104
|
+
new ContractDeploymentData(nonRevertibleClassLogs, nonRevertibleInstanceLogs),
|
|
105
|
+
new ContractDeploymentData(revertibleClassLogs, revertibleInstanceLogs),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/contract/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './contract_address.js';
|
|
|
3
3
|
export * from './contract_class.js';
|
|
4
4
|
export * from './contract_class_metadata.js';
|
|
5
5
|
export * from './contract_class_id.js';
|
|
6
|
+
export * from './contract_deployment_data.js';
|
|
6
7
|
export * from './contract_instance.js';
|
|
7
8
|
export * from './contract_metadata.js';
|
|
8
9
|
export * from './contract_instance_update.js';
|
|
@@ -101,7 +101,7 @@ export async function createPrivateFunctionMembershipProof(
|
|
|
101
101
|
* // Compute function leaf and assert it belongs to the private functions tree
|
|
102
102
|
* function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__FUNCTION_LEAF)
|
|
103
103
|
* computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
|
|
104
|
-
* assert computed_private_function_tree_root == contract_class.
|
|
104
|
+
* assert computed_private_function_tree_root == contract_class.private_functions_root
|
|
105
105
|
*
|
|
106
106
|
* // Compute artifact leaf and assert it belongs to the artifact
|
|
107
107
|
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
package/src/hash/hash.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { GeneratorIndex } from '@aztec/constants';
|
|
1
|
+
import { GeneratorIndex, NULL_MSG_SENDER_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { poseidon2Hash, poseidon2HashWithSeparator, sha256ToField } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { AztecAddress } from '../aztec-address/index.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Computes a hash of a given verification key.
|
|
@@ -57,6 +57,17 @@ export function siloNullifier(contract: AztecAddress, innerNullifier: Fr): Promi
|
|
|
57
57
|
return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.OUTER_NULLIFIER);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Computes the protocol nullifier, which is the hash of the initial tx request siloed with the null msg sender address.
|
|
62
|
+
* @param txRequestHash - The hash of the initial tx request.
|
|
63
|
+
* @returns The siloed value of the protocol nullifier.
|
|
64
|
+
*
|
|
65
|
+
* @dev Must match the implementation in noir-protocol-circuits/crates/types/src/hash.nr > compute_protocol_nullifier
|
|
66
|
+
*/
|
|
67
|
+
export function computeProtocolNullifier(txRequestHash: Fr): Promise<Fr> {
|
|
68
|
+
return siloNullifier(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS), txRequestHash);
|
|
69
|
+
}
|
|
70
|
+
|
|
60
71
|
/**
|
|
61
72
|
* Computes a siloed private log tag, given the contract address and the unsiloed tag.
|
|
62
73
|
* A siloed private log tag effectively namespaces a log to a specific contract.
|
|
@@ -7,7 +7,7 @@ import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
|
|
|
7
7
|
import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
|
|
8
8
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
9
9
|
import type { StateReference } from '../tx/state_reference.js';
|
|
10
|
-
import type { WorldStateRevision } from '../world-state/world_state_revision.js';
|
|
10
|
+
import type { WorldStateRevision, WorldStateRevisionWithHandle } from '../world-state/world_state_revision.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Type alias for the nullifier tree ID.
|
|
@@ -136,7 +136,7 @@ export interface MerkleTreeReadOperations {
|
|
|
136
136
|
/**
|
|
137
137
|
* Gets the current revision.
|
|
138
138
|
*/
|
|
139
|
-
getRevision(): WorldStateRevision;
|
|
139
|
+
getRevision(): WorldStateRevision | WorldStateRevisionWithHandle;
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* Gets sibling path for a leaf.
|
package/src/tests/factories.ts
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
AvmContractClassHint,
|
|
62
62
|
AvmContractInstanceHint,
|
|
63
63
|
AvmCreateCheckpointHint,
|
|
64
|
+
AvmDebugFunctionNameHint,
|
|
64
65
|
AvmExecutionHints,
|
|
65
66
|
AvmGetLeafPreimageHintNullifierTree,
|
|
66
67
|
AvmGetLeafPreimageHintPublicDataTree,
|
|
@@ -79,6 +80,7 @@ import { AztecAddress } from '../aztec-address/index.js';
|
|
|
79
80
|
import { L2BlockHeader } from '../block/index.js';
|
|
80
81
|
import {
|
|
81
82
|
type ContractClassPublic,
|
|
83
|
+
ContractDeploymentData,
|
|
82
84
|
type ContractInstanceWithAddress,
|
|
83
85
|
type ExecutablePrivateFunctionWithMembershipProof,
|
|
84
86
|
type PrivateFunction,
|
|
@@ -118,7 +120,7 @@ import {
|
|
|
118
120
|
PublicCallRequestArrayLengths,
|
|
119
121
|
} from '../kernel/public_call_request.js';
|
|
120
122
|
import { PublicKeys, computeAddress } from '../keys/index.js';
|
|
121
|
-
import { ContractClassLogFields } from '../logs/index.js';
|
|
123
|
+
import { ContractClassLog, ContractClassLogFields } from '../logs/index.js';
|
|
122
124
|
import { PrivateLog } from '../logs/private_log.js';
|
|
123
125
|
import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
|
|
124
126
|
import { CountedL2ToL1Message, L2ToL1Message, ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
@@ -1369,6 +1371,7 @@ export function makeAvmCheckpointActionRevertCheckpointHint(seed = 0): AvmRevert
|
|
|
1369
1371
|
*/
|
|
1370
1372
|
export function makeAvmContractInstanceHint(seed = 0): AvmContractInstanceHint {
|
|
1371
1373
|
return new AvmContractInstanceHint(
|
|
1374
|
+
seed,
|
|
1372
1375
|
new AztecAddress(new Fr(seed)),
|
|
1373
1376
|
new Fr(seed + 0x2),
|
|
1374
1377
|
new AztecAddress(new Fr(seed + 0x3)),
|
|
@@ -1384,19 +1387,28 @@ export function makeAvmContractInstanceHint(seed = 0): AvmContractInstanceHint {
|
|
|
1384
1387
|
);
|
|
1385
1388
|
}
|
|
1386
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* Makes arbitrary AvmDebugFunctionNameHint.
|
|
1392
|
+
* @param seed - The seed to use for generating the hint.
|
|
1393
|
+
* @returns AvmDebugFunctionNameHint.
|
|
1394
|
+
*/
|
|
1395
|
+
export function makeAvmDebugFunctionNameHint(seed = 0): AvmDebugFunctionNameHint {
|
|
1396
|
+
return new AvmDebugFunctionNameHint(new AztecAddress(new Fr(seed)), new Fr(seed + 0x2), `function-${seed}`);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1387
1399
|
/* Makes arbitrary AvmContractClassHint.
|
|
1388
1400
|
* @param seed - The seed to use for generating the state reference.
|
|
1389
1401
|
* @returns AvmContractClassHint.
|
|
1390
1402
|
*/
|
|
1391
1403
|
export function makeAvmContractClassHint(seed = 0): AvmContractClassHint {
|
|
1392
1404
|
const bytecode = makeBytes(32, seed + 0x5);
|
|
1393
|
-
return new AvmContractClassHint(new Fr(seed), new Fr(seed + 0x2), new Fr(seed + 0x3), bytecode);
|
|
1405
|
+
return new AvmContractClassHint(seed, new Fr(seed), new Fr(seed + 0x2), new Fr(seed + 0x3), bytecode);
|
|
1394
1406
|
}
|
|
1395
1407
|
|
|
1396
1408
|
export async function makeAvmBytecodeCommitmentHint(seed = 0): Promise<AvmBytecodeCommitmentHint> {
|
|
1397
1409
|
const classId = new Fr(seed + 2);
|
|
1398
1410
|
const bytecode = makeBytes(32, seed + 0x5);
|
|
1399
|
-
return new AvmBytecodeCommitmentHint(classId, await computePublicBytecodeCommitment(bytecode));
|
|
1411
|
+
return new AvmBytecodeCommitmentHint(seed, classId, await computePublicBytecodeCommitment(bytecode));
|
|
1400
1412
|
}
|
|
1401
1413
|
|
|
1402
1414
|
export async function makePublicCallRequestWithCalldata(seed = 0): Promise<PublicCallRequestWithCalldata> {
|
|
@@ -1411,11 +1423,23 @@ export async function makePublicCallRequestWithCalldata(seed = 0): Promise<Publi
|
|
|
1411
1423
|
return new PublicCallRequestWithCalldata(publicCallRequest, calldata);
|
|
1412
1424
|
}
|
|
1413
1425
|
|
|
1426
|
+
export function makeContractClassLog(seed = 0): ContractClassLog {
|
|
1427
|
+
return new ContractClassLog(makeAztecAddress(seed + 0x1000), makeContractClassLogFields(seed + 0x2000), seed % 20);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
export function makeContractDeploymentData(seed = 0): ContractDeploymentData {
|
|
1431
|
+
const contractClassLogs = makeArray(seed % 20, i => makeContractClassLog(i), seed + 0x1000);
|
|
1432
|
+
const privateLogs = makeArray(seed % 20, i => makePrivateLog(i), seed + 0x2000);
|
|
1433
|
+
return new ContractDeploymentData(contractClassLogs, privateLogs);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1414
1436
|
export async function makeAvmTxHint(seed = 0): Promise<AvmTxHint> {
|
|
1415
1437
|
return new AvmTxHint(
|
|
1416
1438
|
`txhash-${seed}`,
|
|
1417
1439
|
makeGasSettings(),
|
|
1418
1440
|
makeGasFees(seed + 0x1000),
|
|
1441
|
+
makeContractDeploymentData(seed + 0x2000),
|
|
1442
|
+
makeContractDeploymentData(seed + 0x3000),
|
|
1419
1443
|
{
|
|
1420
1444
|
noteHashes: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
|
|
1421
1445
|
nullifiers: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x2000),
|
|
@@ -1454,6 +1478,7 @@ export async function makeAvmExecutionHints(
|
|
|
1454
1478
|
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1455
1479
|
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1456
1480
|
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
1481
|
+
debugFunctionNames: makeArray(baseLength + 5, makeAvmDebugFunctionNameHint, seed + 0x4a00),
|
|
1457
1482
|
startingTreeRoots: makeTreeSnapshots(seed + 0x4900),
|
|
1458
1483
|
getSiblingPathHints: makeArray(baseLength + 5, makeAvmGetSiblingPathHint, seed + 0x4b00),
|
|
1459
1484
|
getPreviousValueIndexHints: makeArray(baseLength + 5, makeAvmGetPreviousValueIndexHint, seed + 0x4d00),
|
|
@@ -1488,6 +1513,7 @@ export async function makeAvmExecutionHints(
|
|
|
1488
1513
|
fields.contractInstances,
|
|
1489
1514
|
fields.contractClasses,
|
|
1490
1515
|
fields.bytecodeCommitments,
|
|
1516
|
+
fields.debugFunctionNames,
|
|
1491
1517
|
fields.startingTreeRoots,
|
|
1492
1518
|
fields.getSiblingPathHints,
|
|
1493
1519
|
fields.getPreviousValueIndexHints,
|