@aztec/stdlib 3.0.0-nightly.20251222 → 3.0.0-nightly.20251224
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/checkpoint/checkpoint.d.ts +15 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +26 -0
- package/dest/checkpoint/checkpoint_info.d.ts +9 -0
- package/dest/checkpoint/checkpoint_info.d.ts.map +1 -0
- package/dest/checkpoint/checkpoint_info.js +1 -0
- package/dest/contract/contract_class_id.js +1 -1
- package/dest/hash/hash.d.ts +1 -9
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +0 -12
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -1
- package/dest/interfaces/aztec-node-admin.d.ts +19 -7
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +10 -10
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +3 -3
- package/dest/interfaces/block-builder.d.ts +3 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +9 -1
- package/dest/interfaces/configs.d.ts +35 -13
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +7 -3
- package/dest/interfaces/l2_logs_source.d.ts +12 -8
- package/dest/interfaces/l2_logs_source.d.ts.map +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 +166 -166
- package/dest/interfaces/world_state.d.ts +10 -3
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +47 -47
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +59 -59
- package/dest/logs/index.d.ts +3 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +2 -0
- package/dest/logs/siloed_tag.d.ts +23 -0
- package/dest/logs/siloed_tag.d.ts.map +1 -0
- package/dest/logs/siloed_tag.js +30 -0
- package/dest/logs/tag.d.ts +21 -0
- package/dest/logs/tag.d.ts.map +1 -0
- package/dest/logs/tag.js +30 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +8 -2
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +13 -5
- package/dest/messaging/l1_to_l2_message.d.ts +1 -1
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.d.ts +2 -1
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.js +1 -0
- package/dest/rollup/checkpoint_header.d.ts +5 -1
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +4 -1
- package/dest/schemas/schemas.d.ts +3 -1
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +1 -0
- package/dest/stats/stats.d.ts +10 -6
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tx/global_variable_builder.d.ts +4 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.d.ts +6 -1
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/checkpoint/checkpoint.ts +32 -0
- package/src/checkpoint/checkpoint_info.ts +9 -0
- package/src/contract/contract_class_id.ts +1 -1
- package/src/hash/hash.ts +0 -11
- package/src/interfaces/archiver.ts +8 -2
- package/src/interfaces/aztec-node.ts +17 -14
- package/src/interfaces/block-builder.ts +11 -1
- package/src/interfaces/configs.ts +36 -8
- package/src/interfaces/l2_logs_source.ts +12 -7
- package/src/interfaces/merkle_tree_operations.ts +4 -1
- package/src/interfaces/world_state.ts +7 -2
- package/src/kernel/private_circuit_public_inputs.ts +85 -85
- package/src/logs/index.ts +2 -0
- package/src/logs/siloed_tag.ts +44 -0
- package/src/logs/tag.ts +42 -0
- package/src/logs/tx_scoped_l2_log.ts +15 -5
- package/src/messaging/l1_to_l2_message.ts +1 -0
- package/src/rollup/checkpoint_constant_data.ts +1 -0
- package/src/rollup/checkpoint_header.ts +4 -0
- package/src/schemas/schemas.ts +3 -0
- package/src/stats/stats.ts +10 -5
- package/src/tx/global_variable_builder.ts +8 -1
- package/src/tx/global_variables.ts +6 -0
package/src/logs/tag.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
|
+
|
|
5
|
+
import { schemas } from '../schemas/schemas.js';
|
|
6
|
+
import type { PreTag } from './pre_tag.js';
|
|
7
|
+
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
9
|
+
|
|
10
|
+
export interface Tag {
|
|
11
|
+
/** Brand. */
|
|
12
|
+
_branding: 'Tag';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
|
|
17
|
+
* with a contract address by kernels before being included in the final log.
|
|
18
|
+
*/
|
|
19
|
+
export class Tag {
|
|
20
|
+
constructor(public readonly value: Fr) {}
|
|
21
|
+
|
|
22
|
+
static async compute(preTag: PreTag): Promise<Tag> {
|
|
23
|
+
const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
|
|
24
|
+
return new Tag(tag);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
toString(): string {
|
|
28
|
+
return this.value.toString();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toJSON(): string {
|
|
32
|
+
return this.value.toString();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
equals(other: Tag): boolean {
|
|
36
|
+
return this.value.equals(other.value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static get schema(): ZodFor<Tag> {
|
|
40
|
+
return schemas.Fr.transform((fr: Fr) => new Tag(fr));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
2
|
+
import { BufferReader, bigintToUInt64BE, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
7
|
+
import { schemas } from '../schemas/schemas.js';
|
|
7
8
|
import { TxHash } from '../tx/tx_hash.js';
|
|
9
|
+
import type { UInt64 } from '../types/shared.js';
|
|
8
10
|
import { PrivateLog } from './private_log.js';
|
|
9
11
|
import { PublicLog } from './public_log.js';
|
|
10
12
|
|
|
@@ -33,6 +35,10 @@ export class TxScopedL2Log {
|
|
|
33
35
|
* The block this log is included in
|
|
34
36
|
*/
|
|
35
37
|
public blockHash: L2BlockHash,
|
|
38
|
+
/*
|
|
39
|
+
* The timestamp of the block this log is included in
|
|
40
|
+
*/
|
|
41
|
+
public blockTimestamp: UInt64,
|
|
36
42
|
/*
|
|
37
43
|
* The log data as either a PrivateLog or PublicLog
|
|
38
44
|
*/
|
|
@@ -51,11 +57,12 @@ export class TxScopedL2Log {
|
|
|
51
57
|
logIndexInTx: z.number(),
|
|
52
58
|
blockNumber: BlockNumberSchema,
|
|
53
59
|
blockHash: L2BlockHash.schema,
|
|
60
|
+
blockTimestamp: schemas.UInt64,
|
|
54
61
|
log: z.union([PrivateLog.schema, PublicLog.schema]),
|
|
55
62
|
})
|
|
56
63
|
.transform(
|
|
57
|
-
({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log }) =>
|
|
58
|
-
new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log),
|
|
64
|
+
({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log }) =>
|
|
65
|
+
new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log),
|
|
59
66
|
);
|
|
60
67
|
}
|
|
61
68
|
|
|
@@ -66,6 +73,7 @@ export class TxScopedL2Log {
|
|
|
66
73
|
numToUInt32BE(this.logIndexInTx),
|
|
67
74
|
numToUInt32BE(this.blockNumber),
|
|
68
75
|
this.blockHash.toBuffer(),
|
|
76
|
+
bigintToUInt64BE(this.blockTimestamp),
|
|
69
77
|
boolToBuffer(this.isFromPublic),
|
|
70
78
|
this.log.toBuffer(),
|
|
71
79
|
]);
|
|
@@ -78,15 +86,16 @@ export class TxScopedL2Log {
|
|
|
78
86
|
const logIndexInTx = reader.readNumber();
|
|
79
87
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
80
88
|
const blockHash = reader.readObject(L2BlockHash);
|
|
89
|
+
const blockTimestamp = reader.readUInt64();
|
|
81
90
|
const isFromPublic = reader.readBoolean();
|
|
82
91
|
const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
|
|
83
92
|
|
|
84
|
-
return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log);
|
|
93
|
+
return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log);
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
static async random(isFromPublic = Math.random() < 0.5) {
|
|
88
97
|
const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
|
|
89
|
-
return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), log);
|
|
98
|
+
return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), 1n, log);
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
equals(other: TxScopedL2Log) {
|
|
@@ -96,6 +105,7 @@ export class TxScopedL2Log {
|
|
|
96
105
|
this.logIndexInTx === other.logIndexInTx &&
|
|
97
106
|
this.blockNumber === other.blockNumber &&
|
|
98
107
|
this.blockHash.equals(other.blockHash) &&
|
|
108
|
+
this.blockTimestamp === other.blockTimestamp &&
|
|
99
109
|
((this.log instanceof PublicLog && other.log instanceof PublicLog) ||
|
|
100
110
|
(this.log instanceof PrivateLog && other.log instanceof PrivateLog)) &&
|
|
101
111
|
this.log.equals(other.log as any)
|
|
@@ -84,6 +84,7 @@ export async function getNonNullifiedL1ToL2MessageWitness(
|
|
|
84
84
|
if (!response) {
|
|
85
85
|
throw new Error(`No L1 to L2 message found for message hash ${messageHash.toString()}`);
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
const [messageIndex, siblingPath] = response;
|
|
88
89
|
|
|
89
90
|
const messageNullifier = await computeL1ToL2MessageNullifier(contractAddress, messageHash, secret);
|
|
@@ -17,6 +17,10 @@ import { schemas } from '../schemas/index.js';
|
|
|
17
17
|
import { ContentCommitment } from '../tx/content_commitment.js';
|
|
18
18
|
import type { UInt64 } from '../types/shared.js';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Header of a checkpoint. A checkpoint is a collection of blocks submitted to L1 all within the same slot.
|
|
22
|
+
* TODO(palla/mbps): Should this include chainId and version as well? Is this used just in circuits?
|
|
23
|
+
*/
|
|
20
24
|
export class CheckpointHeader {
|
|
21
25
|
constructor(
|
|
22
26
|
/** Root of the archive tree before this block is added. */
|
package/src/schemas/schemas.ts
CHANGED
|
@@ -40,6 +40,9 @@ export const schemas = {
|
|
|
40
40
|
/** Coerces input to UInt32. */
|
|
41
41
|
UInt32: foundationSchemas.UInt32,
|
|
42
42
|
|
|
43
|
+
/** Coerces input to UInt64. */
|
|
44
|
+
UInt64: foundationSchemas.UInt64,
|
|
45
|
+
|
|
43
46
|
/** Accepts a hex string as a Buffer32 type. */
|
|
44
47
|
Buffer32: foundationSchemas.Buffer32 as ZodFor<Buffer32>,
|
|
45
48
|
|
package/src/stats/stats.ts
CHANGED
|
@@ -20,6 +20,13 @@ export type L2BlockStats = {
|
|
|
20
20
|
publicLogCount?: number;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
export type CheckpointStats = {
|
|
24
|
+
/** Number of transactions in the checkpoint */
|
|
25
|
+
txCount: number;
|
|
26
|
+
/** Number of blocks in the checkpoint */
|
|
27
|
+
blockCount: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
23
30
|
/** Stats logged for each L1 publish tx.*/
|
|
24
31
|
export type L1PublishStats = {
|
|
25
32
|
/** Address of the sender. */
|
|
@@ -45,11 +52,11 @@ export type L1PublishStats = {
|
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
/** Stats logged for each L1 rollup publish tx.*/
|
|
48
|
-
export type
|
|
55
|
+
export type L1PublishCheckpointStats = {
|
|
49
56
|
/** Name of the event for metrics purposes */
|
|
50
57
|
eventName: 'rollup-published-to-l1';
|
|
51
58
|
} & L1PublishStats &
|
|
52
|
-
|
|
59
|
+
CheckpointStats;
|
|
53
60
|
|
|
54
61
|
/** Stats logged for each L1 rollup publish tx.*/
|
|
55
62
|
export type L1PublishProofStats = {
|
|
@@ -189,8 +196,6 @@ export type CircuitVerificationStats = {
|
|
|
189
196
|
|
|
190
197
|
/** Stats for an L2 block built by a sequencer. */
|
|
191
198
|
export type L2BlockBuiltStats = {
|
|
192
|
-
/** The creator of the block */
|
|
193
|
-
creator: string;
|
|
194
199
|
/** Name of the event. */
|
|
195
200
|
eventName: 'l2-block-built';
|
|
196
201
|
/** Total duration in ms. */
|
|
@@ -272,7 +277,7 @@ export type Stats =
|
|
|
272
277
|
| CircuitSimulationStats
|
|
273
278
|
| CircuitWitnessGenerationStats
|
|
274
279
|
| PublicDBAccessStats
|
|
275
|
-
|
|
|
280
|
+
| L1PublishCheckpointStats
|
|
276
281
|
| L1PublishProofStats
|
|
277
282
|
| L2BlockBuiltStats
|
|
278
283
|
| L2BlockHandledStats
|
|
@@ -4,7 +4,7 @@ import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
|
4
4
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
5
|
import type { GasFees } from '../gas/gas_fees.js';
|
|
6
6
|
import type { UInt32 } from '../types/index.js';
|
|
7
|
-
import type { GlobalVariables } from './global_variables.js';
|
|
7
|
+
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Interface for building global variables for Aztec blocks.
|
|
@@ -26,4 +26,11 @@ export interface GlobalVariableBuilder {
|
|
|
26
26
|
feeRecipient: AztecAddress,
|
|
27
27
|
slotNumber?: SlotNumber,
|
|
28
28
|
): Promise<GlobalVariables>;
|
|
29
|
+
|
|
30
|
+
/** Builds global variables that are constant throughout a checkpoint. */
|
|
31
|
+
buildCheckpointGlobalVariables(
|
|
32
|
+
coinbase: EthAddress,
|
|
33
|
+
feeRecipient: AztecAddress,
|
|
34
|
+
slotNumber: SlotNumber,
|
|
35
|
+
): Promise<CheckpointGlobalVariables>;
|
|
29
36
|
}
|
|
@@ -21,6 +21,12 @@ import { GasFees } from '../gas/gas_fees.js';
|
|
|
21
21
|
import { schemas } from '../schemas/index.js';
|
|
22
22
|
import type { UInt64 } from '../types/index.js';
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Global variables that are constant across the entire slot.
|
|
26
|
+
* TODO(palla/mbps): Should timestamp be included here as well?
|
|
27
|
+
*/
|
|
28
|
+
export type CheckpointGlobalVariables = Omit<FieldsOf<GlobalVariables>, 'blockNumber' | 'timestamp'>;
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* Global variables of the L2 block.
|
|
26
32
|
*/
|