@aztec/stdlib 0.83.0 → 0.83.1-nightly.20250404
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 +1203 -694
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +58 -6
- package/dest/avm/avm_circuit_public_inputs.d.ts +80 -80
- package/dest/avm/avm_proving_request.d.ts +672 -447
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/config/config.d.ts +2 -1
- package/dest/config/config.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.d.ts +2 -2
- package/dest/interfaces/allowed_element.d.ts +53 -0
- package/dest/interfaces/allowed_element.d.ts.map +1 -0
- package/dest/interfaces/allowed_element.js +18 -0
- package/dest/interfaces/configs.d.ts +17 -34
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -17
- package/dest/interfaces/proving-job.d.ts +672 -447
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/public_state_source.d.ts +8 -0
- package/dest/interfaces/public_state_source.d.ts.map +1 -0
- package/dest/interfaces/public_state_source.js +1 -0
- package/dest/interfaces/server.d.ts +1 -0
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +1 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +1 -1
- package/dest/note/extended_note.d.ts +3 -3
- package/dest/proofs/proof.d.ts +0 -1
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/proof.js +6 -11
- package/dest/tests/factories.d.ts +2 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +12 -3
- package/dest/trees/database_public_state_source.d.ts +11 -0
- package/dest/trees/database_public_state_source.d.ts.map +1 -0
- package/dest/trees/database_public_state_source.js +18 -0
- package/dest/trees/index.d.ts +1 -0
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +1 -0
- package/dest/tx/call_context.d.ts +1 -1
- package/dest/tx/tree_snapshots.d.ts +6 -6
- package/package.json +6 -6
- package/src/avm/avm.ts +89 -5
- package/src/config/config.ts +2 -1
- package/src/interfaces/allowed_element.ts +21 -0
- package/src/interfaces/configs.ts +3 -18
- package/src/interfaces/public_state_source.ts +9 -0
- package/src/interfaces/server.ts +1 -0
- package/src/proofs/proof.ts +6 -16
- package/src/tests/factories.ts +19 -2
- package/src/trees/database_public_state_source.ts +30 -0
- package/src/trees/index.ts +1 -0
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
|
|
6
|
-
import type { FunctionSelector } from '../abi/function_selector.js';
|
|
7
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
8
6
|
import { type ZodFor, schemas } from '../schemas/index.js';
|
|
9
|
-
|
|
10
|
-
type AllowedInstance = { address: AztecAddress };
|
|
11
|
-
type AllowedInstanceFunction = { address: AztecAddress; selector: FunctionSelector };
|
|
12
|
-
type AllowedClass = { classId: Fr };
|
|
13
|
-
type AllowedClassFunction = { classId: Fr; selector: FunctionSelector };
|
|
14
|
-
|
|
15
|
-
export type AllowedElement = AllowedInstance | AllowedInstanceFunction | AllowedClass | AllowedClassFunction;
|
|
7
|
+
import { type AllowedElement, AllowedElementSchema } from './allowed_element.js';
|
|
16
8
|
|
|
17
9
|
/**
|
|
18
10
|
* The sequencer configuration.
|
|
@@ -37,7 +29,7 @@ export interface SequencerConfig {
|
|
|
37
29
|
/** The path to the ACVM binary */
|
|
38
30
|
acvmBinaryPath?: string;
|
|
39
31
|
/** The list of functions calls allowed to run in setup */
|
|
40
|
-
|
|
32
|
+
txPublicSetupAllowList?: AllowedElement[];
|
|
41
33
|
/** Max block size */
|
|
42
34
|
maxBlockSizeInBytes?: number;
|
|
43
35
|
/** Payload address to vote for */
|
|
@@ -48,13 +40,6 @@ export interface SequencerConfig {
|
|
|
48
40
|
maxL1TxInclusionTimeIntoSlot?: number;
|
|
49
41
|
}
|
|
50
42
|
|
|
51
|
-
const AllowedElementSchema = z.union([
|
|
52
|
-
z.object({ address: schemas.AztecAddress, selector: schemas.FunctionSelector }),
|
|
53
|
-
z.object({ address: schemas.AztecAddress }),
|
|
54
|
-
z.object({ classId: schemas.Fr, selector: schemas.FunctionSelector }),
|
|
55
|
-
z.object({ classId: schemas.Fr }),
|
|
56
|
-
]) satisfies ZodFor<AllowedElement>;
|
|
57
|
-
|
|
58
43
|
export const SequencerConfigSchema = z.object({
|
|
59
44
|
transactionPollingIntervalMS: z.number().optional(),
|
|
60
45
|
maxTxsPerBlock: z.number().optional(),
|
|
@@ -65,7 +50,7 @@ export const SequencerConfigSchema = z.object({
|
|
|
65
50
|
feeRecipient: schemas.AztecAddress.optional(),
|
|
66
51
|
acvmWorkingDirectory: z.string().optional(),
|
|
67
52
|
acvmBinaryPath: z.string().optional(),
|
|
68
|
-
|
|
53
|
+
txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
|
|
69
54
|
maxBlockSizeInBytes: z.number().optional(),
|
|
70
55
|
governanceProposerPayload: schemas.EthAddress.optional(),
|
|
71
56
|
maxL1TxInclusionTimeIntoSlot: z.number().optional(),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
|
|
3
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
4
|
+
|
|
5
|
+
/** Provides a view into public contract state */
|
|
6
|
+
export interface PublicStateSource {
|
|
7
|
+
/** Returns the value for a given slot at a given contract. */
|
|
8
|
+
storageRead: (contractAddress: AztecAddress, slot: Fr) => Promise<Fr>;
|
|
9
|
+
}
|
package/src/interfaces/server.ts
CHANGED
package/src/proofs/proof.ts
CHANGED
|
@@ -17,11 +17,6 @@ export class Proof {
|
|
|
17
17
|
// Make sure this type is not confused with other buffer wrappers
|
|
18
18
|
readonly __proofBrand: any;
|
|
19
19
|
|
|
20
|
-
// Honk proofs start with a 4 byte length prefix
|
|
21
|
-
// the proof metadata starts immediately after
|
|
22
|
-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1312): Get rid of if possible.
|
|
23
|
-
private readonly metadataOffset = 4;
|
|
24
|
-
|
|
25
20
|
constructor(
|
|
26
21
|
/**
|
|
27
22
|
* Holds the serialized proof data in a binary buffer format.
|
|
@@ -69,14 +64,14 @@ export class Proof {
|
|
|
69
64
|
return this.buffer;
|
|
70
65
|
}
|
|
71
66
|
// We are indexing to this particular size because we are assuming the proof buffer looks like:
|
|
72
|
-
// [
|
|
73
|
-
const proofStart =
|
|
67
|
+
// [binary public inputs, binary proof]
|
|
68
|
+
const proofStart = Fr.SIZE_IN_BYTES * this.numPublicInputs;
|
|
74
69
|
assert(this.buffer.length >= proofStart, 'Proof buffer is not appropriately sized to call withoutPublicInputs()');
|
|
75
70
|
return this.buffer.subarray(proofStart);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
// This function assumes that the proof will contain an aggregation object and look something like:
|
|
79
|
-
// [
|
|
74
|
+
// [binary public inputs, aggregation object, rest of proof]
|
|
80
75
|
// We are extracting the binary public inputs and reading them as Frs, and also extracting the aggregation object.
|
|
81
76
|
public extractPublicInputs(): Fr[] {
|
|
82
77
|
if (this.isEmpty()) {
|
|
@@ -85,9 +80,7 @@ export class Proof {
|
|
|
85
80
|
}
|
|
86
81
|
assert(this.numPublicInputs >= AGGREGATION_OBJECT_LENGTH, 'Proof does not contain an aggregation object');
|
|
87
82
|
const numInnerPublicInputs = this.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
88
|
-
const reader = BufferReader.asReader(
|
|
89
|
-
this.buffer.subarray(this.metadataOffset, this.metadataOffset + Fr.SIZE_IN_BYTES * numInnerPublicInputs),
|
|
90
|
-
);
|
|
83
|
+
const reader = BufferReader.asReader(this.buffer.subarray(0, Fr.SIZE_IN_BYTES * numInnerPublicInputs));
|
|
91
84
|
let publicInputs = reader.readArray(numInnerPublicInputs, Fr);
|
|
92
85
|
// concatenate Fr[] with aggregation object
|
|
93
86
|
publicInputs = publicInputs.concat(this.extractAggregationObject());
|
|
@@ -101,12 +94,9 @@ export class Proof {
|
|
|
101
94
|
}
|
|
102
95
|
assert(this.numPublicInputs >= AGGREGATION_OBJECT_LENGTH, 'Proof does not contain an aggregation object');
|
|
103
96
|
const numInnerPublicInputs = this.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
104
|
-
// The aggregation object is currently stored after the initial inner public inputs
|
|
97
|
+
// The aggregation object is currently stored after the initial inner public inputs.
|
|
105
98
|
const reader = BufferReader.asReader(
|
|
106
|
-
this.buffer.subarray(
|
|
107
|
-
this.metadataOffset + Fr.SIZE_IN_BYTES * numInnerPublicInputs + this.metadataOffset,
|
|
108
|
-
this.metadataOffset + Fr.SIZE_IN_BYTES * this.numPublicInputs + this.metadataOffset,
|
|
109
|
-
),
|
|
99
|
+
this.buffer.subarray(Fr.SIZE_IN_BYTES * numInnerPublicInputs, Fr.SIZE_IN_BYTES * this.numPublicInputs),
|
|
110
100
|
);
|
|
111
101
|
return reader.readArray(AGGREGATION_OBJECT_LENGTH, Fr);
|
|
112
102
|
}
|
package/src/tests/factories.ts
CHANGED
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
AvmGetSiblingPathHint,
|
|
70
70
|
AvmSequentialInsertHintNullifierTree,
|
|
71
71
|
AvmSequentialInsertHintPublicDataTree,
|
|
72
|
+
AvmTxHint,
|
|
72
73
|
RevertCode,
|
|
73
74
|
} from '../avm/index.js';
|
|
74
75
|
import { PublicDataHint } from '../avm/public_data_hint.js';
|
|
@@ -1427,6 +1428,22 @@ export function makeAvmEnqueuedCallHint(seed = 0): AvmEnqueuedCallHint {
|
|
|
1427
1428
|
);
|
|
1428
1429
|
}
|
|
1429
1430
|
|
|
1431
|
+
export function makeAvmTxHint(seed = 0): AvmTxHint {
|
|
1432
|
+
return new AvmTxHint(
|
|
1433
|
+
{
|
|
1434
|
+
noteHashes: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
|
|
1435
|
+
nullifiers: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x2000),
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
noteHashes: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x3000),
|
|
1439
|
+
nullifiers: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x4000),
|
|
1440
|
+
},
|
|
1441
|
+
makeArray((seed % 20) + 4, i => makeAvmEnqueuedCallHint(i), seed + 0x5000), // setupEnqueuedCalls
|
|
1442
|
+
makeArray((seed % 20) + 4, i => makeAvmEnqueuedCallHint(i), seed + 0x6000), // appLogicEnqueuedCalls
|
|
1443
|
+
makeAvmEnqueuedCallHint(seed + 0x7000), // teardownEnqueuedCall
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1430
1447
|
/**
|
|
1431
1448
|
* Creates arbitrary AvmExecutionHints.
|
|
1432
1449
|
* @param seed - The seed to use for generating the hints.
|
|
@@ -1441,7 +1458,7 @@ export async function makeAvmExecutionHints(
|
|
|
1441
1458
|
const baseLength = lengthOffset + (seed % lengthSeedMod);
|
|
1442
1459
|
|
|
1443
1460
|
const fields = {
|
|
1444
|
-
|
|
1461
|
+
tx: makeAvmTxHint(seed + 0x4100),
|
|
1445
1462
|
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1446
1463
|
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1447
1464
|
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
@@ -1468,7 +1485,7 @@ export async function makeAvmExecutionHints(
|
|
|
1468
1485
|
};
|
|
1469
1486
|
|
|
1470
1487
|
return new AvmExecutionHints(
|
|
1471
|
-
fields.
|
|
1488
|
+
fields.tx,
|
|
1472
1489
|
fields.contractInstances,
|
|
1473
1490
|
fields.contractClasses,
|
|
1474
1491
|
fields.bytecodeCommitments,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
|
|
3
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
4
|
+
import { computePublicDataTreeLeafSlot } from '../hash/hash.js';
|
|
5
|
+
import type { MerkleTreeReadOperations } from '../interfaces/merkle_tree_operations.js';
|
|
6
|
+
import type { PublicStateSource } from '../interfaces/public_state_source.js';
|
|
7
|
+
import { MerkleTreeId } from './merkle_tree_id.js';
|
|
8
|
+
import type { PublicDataTreeLeafPreimage } from './public_data_leaf.js';
|
|
9
|
+
|
|
10
|
+
export type { PublicStateSource };
|
|
11
|
+
|
|
12
|
+
export class DatabasePublicStateSource implements PublicStateSource {
|
|
13
|
+
constructor(private db: MerkleTreeReadOperations) {}
|
|
14
|
+
|
|
15
|
+
async storageRead(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
|
|
16
|
+
const leafSlot = (await computePublicDataTreeLeafSlot(contractAddress, slot)).toBigInt();
|
|
17
|
+
|
|
18
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
|
|
19
|
+
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
20
|
+
return Fr.ZERO;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const preimage = (await this.db.getLeafPreimage(
|
|
24
|
+
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
25
|
+
lowLeafResult.index,
|
|
26
|
+
)) as PublicDataTreeLeafPreimage;
|
|
27
|
+
|
|
28
|
+
return preimage.leaf.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/trees/index.ts
CHANGED