@aztec/stdlib 4.0.0-nightly.20260116 → 4.0.0-nightly.20260117

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.
Files changed (66) hide show
  1. package/dest/block/l2_block_new.d.ts +3 -2
  2. package/dest/block/l2_block_new.d.ts.map +1 -1
  3. package/dest/block/l2_block_new.js +3 -0
  4. package/dest/block/l2_block_source.d.ts +18 -11
  5. package/dest/block/l2_block_source.d.ts.map +1 -1
  6. package/dest/block/l2_block_source.js +2 -1
  7. package/dest/block/l2_block_stream/interfaces.d.ts +2 -3
  8. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  9. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  10. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  11. package/dest/block/l2_block_stream/l2_block_stream.js +0 -9
  12. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  13. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  14. package/dest/block/test/l2_tips_store_test_suite.js +0 -5
  15. package/dest/checkpoint/checkpoint.d.ts +8 -5
  16. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  17. package/dest/checkpoint/checkpoint.js +3 -0
  18. package/dest/interfaces/archiver.d.ts +1 -1
  19. package/dest/interfaces/archiver.d.ts.map +1 -1
  20. package/dest/interfaces/archiver.js +1 -0
  21. package/dest/interfaces/aztec-node-admin.d.ts +31 -1
  22. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  23. package/dest/interfaces/block-builder.d.ts +2 -1
  24. package/dest/interfaces/block-builder.d.ts.map +1 -1
  25. package/dest/interfaces/proving-job.d.ts +166 -166
  26. package/dest/interfaces/validator.d.ts +68 -4
  27. package/dest/interfaces/validator.d.ts.map +1 -1
  28. package/dest/interfaces/validator.js +2 -1
  29. package/dest/p2p/block_proposal.d.ts +3 -2
  30. package/dest/p2p/block_proposal.d.ts.map +1 -1
  31. package/dest/p2p/block_proposal.js +14 -2
  32. package/dest/p2p/checkpoint_proposal.d.ts +3 -2
  33. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  34. package/dest/p2p/checkpoint_proposal.js +9 -2
  35. package/dest/tests/mocks.d.ts +3 -2
  36. package/dest/tests/mocks.d.ts.map +1 -1
  37. package/dest/tests/mocks.js +4 -4
  38. package/dest/tx/block_header.d.ts +3 -1
  39. package/dest/tx/block_header.d.ts.map +1 -1
  40. package/dest/tx/block_header.js +3 -0
  41. package/dest/tx/private_execution_result.d.ts +3 -3
  42. package/dest/tx/private_execution_result.d.ts.map +1 -1
  43. package/dest/tx/private_execution_result.js +1 -1
  44. package/dest/tx/profiling.d.ts +149 -26
  45. package/dest/tx/profiling.d.ts.map +1 -1
  46. package/dest/tx/profiling.js +44 -7
  47. package/dest/zkpassport/index.d.ts +3 -4
  48. package/dest/zkpassport/index.d.ts.map +1 -1
  49. package/dest/zkpassport/index.js +9 -9
  50. package/package.json +9 -8
  51. package/src/block/l2_block_new.ts +5 -1
  52. package/src/block/l2_block_source.ts +19 -11
  53. package/src/block/l2_block_stream/interfaces.ts +1 -2
  54. package/src/block/l2_block_stream/l2_block_stream.ts +1 -10
  55. package/src/block/test/l2_tips_store_test_suite.ts +0 -5
  56. package/src/checkpoint/checkpoint.ts +9 -3
  57. package/src/interfaces/archiver.ts +1 -0
  58. package/src/interfaces/block-builder.ts +1 -0
  59. package/src/interfaces/validator.ts +7 -3
  60. package/src/p2p/block_proposal.ts +14 -3
  61. package/src/p2p/checkpoint_proposal.ts +10 -4
  62. package/src/tests/mocks.ts +15 -11
  63. package/src/tx/block_header.ts +5 -0
  64. package/src/tx/private_execution_result.ts +1 -1
  65. package/src/tx/profiling.ts +46 -4
  66. package/src/zkpassport/index.ts +11 -12
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { SecretValue } from '@aztec/foundation/config';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
@@ -14,6 +15,7 @@ import type {
14
15
  } from '@aztec/stdlib/p2p';
15
16
  import type { CheckpointHeader } from '@aztec/stdlib/rollup';
16
17
  import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
18
+ import { type ValidatorHASignerConfig, ValidatorHASignerConfigSchema } from '@aztec/validator-ha-signer/config';
17
19
 
18
20
  import type { PeerId } from '@libp2p/interface';
19
21
  import { z } from 'zod';
@@ -24,7 +26,7 @@ import { AllowedElementSchema } from './allowed_element.js';
24
26
  /**
25
27
  * Validator client configuration
26
28
  */
27
- export interface ValidatorClientConfig {
29
+ export type ValidatorClientConfig = ValidatorHASignerConfig & {
28
30
  /** The private keys of the validators participating in attestation duties */
29
31
  validatorPrivateKeys?: SecretValue<`0x${string}`[]>;
30
32
 
@@ -56,7 +58,7 @@ export interface ValidatorClientConfig {
56
58
  // TODO(palla/mbps): Change default to false once block sync is stable
57
59
  /** Skip pushing re-executed blocks to archiver (default: true) */
58
60
  skipPushProposedBlocksToArchiver?: boolean;
59
- }
61
+ };
60
62
 
61
63
  export type ValidatorClientFullConfig = ValidatorClientConfig &
62
64
  Pick<SequencerConfig, 'txPublicSetupAllowList' | 'broadcastInvalidBlockProposal'> &
@@ -69,7 +71,7 @@ export type ValidatorClientFullConfig = ValidatorClientConfig &
69
71
  };
70
72
 
71
73
  export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>()(
72
- z.object({
74
+ ValidatorHASignerConfigSchema.extend({
73
75
  validatorAddresses: z.array(schemas.EthAddress).optional(),
74
76
  disableValidator: z.boolean(),
75
77
  disabledValidators: z.array(schemas.EthAddress),
@@ -144,5 +146,7 @@ export interface Validator {
144
146
  signAttestationsAndSigners(
145
147
  attestationsAndSigners: CommitteeAttestationsAndSigners,
146
148
  proposer: EthAddress,
149
+ slot: SlotNumber,
150
+ blockNumber: BlockNumber | CheckpointNumber,
147
151
  ): Promise<Signature>;
148
152
  }
@@ -6,6 +6,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
+ import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
9
10
 
10
11
  import type { L2Block } from '../block/l2_block.js';
11
12
  import type { L2BlockInfo } from '../block/l2_block_info.js';
@@ -125,7 +126,7 @@ export class BlockProposal extends Gossipable {
125
126
  archiveRoot: Fr,
126
127
  txHashes: TxHash[],
127
128
  txs: Tx[] | undefined,
128
- payloadSigner: (payload: Buffer32) => Promise<Signature>,
129
+ payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
129
130
  ): Promise<BlockProposal> {
130
131
  // Create a temporary proposal to get the payload to sign
131
132
  const tempProposal = new BlockProposal(
@@ -137,13 +138,23 @@ export class BlockProposal extends Gossipable {
137
138
  Signature.empty(),
138
139
  );
139
140
 
141
+ // Create the block signing context
142
+ const blockContext: SigningContext = {
143
+ slot: blockHeader.globalVariables.slotNumber,
144
+ blockNumber: blockHeader.globalVariables.blockNumber,
145
+ blockIndexWithinCheckpoint: indexWithinCheckpoint,
146
+ dutyType: DutyType.BLOCK_PROPOSAL,
147
+ };
148
+
140
149
  const hashed = getHashedSignaturePayload(tempProposal, SignatureDomainSeparator.blockProposal);
141
- const sig = await payloadSigner(hashed);
150
+ const sig = await payloadSigner(hashed, blockContext);
142
151
 
143
152
  // If txs are provided, sign them as well
144
153
  let signedTxs: SignedTxs | undefined;
145
154
  if (txs) {
146
- signedTxs = await SignedTxs.createFromSigner(txs, payloadSigner);
155
+ const txsSigningContext: SigningContext = { dutyType: DutyType.TXS };
156
+ const txsSigner = (payload: Buffer32) => payloadSigner(payload, txsSigningContext);
157
+ signedTxs = await SignedTxs.createFromSigner(txs, txsSigner);
147
158
  }
148
159
 
149
160
  return new BlockProposal(blockHeader, indexWithinCheckpoint, inHash, archiveRoot, txHashes, sig, signedTxs);
@@ -6,6 +6,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
+ import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
9
10
 
10
11
  import type { L2BlockInfo } from '../block/l2_block_info.js';
11
12
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
@@ -152,13 +153,18 @@ export class CheckpointProposal extends Gossipable {
152
153
  checkpointHeader: CheckpointHeader,
153
154
  archiveRoot: Fr,
154
155
  lastBlockInfo: CheckpointLastBlockData | undefined,
155
- payloadSigner: (payload: Buffer32) => Promise<Signature>,
156
+ payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
156
157
  ): Promise<CheckpointProposal> {
157
- // Sign the checkpoint payload
158
+ // Sign the checkpoint payload with CHECKPOINT_PROPOSAL duty type
158
159
  const tempProposal = new CheckpointProposal(checkpointHeader, archiveRoot, Signature.empty(), undefined);
159
-
160
160
  const checkpointHash = getHashedSignaturePayload(tempProposal, SignatureDomainSeparator.checkpointProposal);
161
- const checkpointSignature = await payloadSigner(checkpointHash);
161
+
162
+ const checkpointContext: SigningContext = {
163
+ slot: checkpointHeader.slotNumber,
164
+ blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
165
+ dutyType: DutyType.CHECKPOINT_PROPOSAL,
166
+ };
167
+ const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
162
168
 
163
169
  if (!lastBlockInfo) {
164
170
  return new CheckpointProposal(checkpointHeader, archiveRoot, checkpointSignature);
@@ -400,6 +400,7 @@ export async function mockCheckpointAndMessages(
400
400
  {
401
401
  startBlockNumber = BlockNumber(1),
402
402
  numBlocks = 1,
403
+ blocks,
403
404
  numTxsPerBlock = 1,
404
405
  numL1ToL2Messages = 1,
405
406
  makeBlockOptions = () => ({}),
@@ -412,6 +413,7 @@ export async function mockCheckpointAndMessages(
412
413
  numL1ToL2Messages?: number;
413
414
  makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2BlockNew.random>[1]>;
414
415
  previousArchive?: AppendOnlyTreeSnapshot;
416
+ blocks?: L2BlockNew[];
415
417
  } & Partial<Parameters<typeof Checkpoint.random>[1]> &
416
418
  Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
417
419
  ) {
@@ -420,18 +422,20 @@ export async function mockCheckpointAndMessages(
420
422
  // Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
421
423
  // The current block's header.lastArchive must equal the previous block's archive.
422
424
  let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
423
- for (let i = 0; i < numBlocks; i++) {
425
+ for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
424
426
  const blockNumber = BlockNumber(startBlockNumber + i);
425
427
  const { block, messages } = {
426
- block: await L2BlockNew.random(blockNumber, {
427
- checkpointNumber,
428
- indexWithinCheckpoint: i,
429
- txsPerBlock: numTxsPerBlock,
430
- slotNumber,
431
- ...options,
432
- ...makeBlockOptions(blockNumber),
433
- ...(lastArchive ? { lastArchive } : {}),
434
- }),
428
+ block:
429
+ blocks?.[i] ??
430
+ (await L2BlockNew.random(blockNumber, {
431
+ checkpointNumber,
432
+ indexWithinCheckpoint: i,
433
+ txsPerBlock: numTxsPerBlock,
434
+ slotNumber,
435
+ ...options,
436
+ ...makeBlockOptions(blockNumber),
437
+ ...(lastArchive ? { lastArchive } : {}),
438
+ })),
435
439
  messages: mockL1ToL2Messages(numL1ToL2Messages),
436
440
  };
437
441
  // Update lastArchive for the next block
@@ -565,7 +569,7 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
565
569
  archiveRoot,
566
570
  txHashes,
567
571
  txs,
568
- payload => Promise.resolve(signer.signMessage(payload)),
572
+ (_payload, _context) => Promise.resolve(signer.signMessage(_payload)),
569
573
  );
570
574
  };
571
575
 
@@ -168,6 +168,11 @@ export class BlockHeader {
168
168
  return this._cachedHash;
169
169
  }
170
170
 
171
+ /** Manually set the hash for this block header if already computed */
172
+ setHash(hashed: Fr) {
173
+ this._cachedHash = Promise.resolve(hashed);
174
+ }
175
+
171
176
  static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
172
177
  return BlockHeader.from({
173
178
  lastArchive: AppendOnlyTreeSnapshot.random(),
@@ -79,7 +79,7 @@ export class CountedContractClassLog implements IsEmpty {
79
79
  export class PrivateExecutionResult {
80
80
  constructor(
81
81
  public entrypoint: PrivateCallExecutionResult,
82
- /** The first non revertible nullifier, or zero if there was none. */
82
+ /** The first non-revertible nullifier emitted by any private call, or the protocol nullifier if there was none. */
83
83
  public firstNullifier: Fr,
84
84
  /** An array of calldata for the enqueued public function calls and the teardown function call. */
85
85
  public publicFunctionCalldata: HashedValues[],
@@ -6,9 +6,35 @@ import { z } from 'zod';
6
6
  import type { AztecNode } from '../interfaces/aztec-node.js';
7
7
  import { type PrivateExecutionStep, PrivateExecutionStepSchema } from '../kernel/private_kernel_prover_output.js';
8
8
 
9
- export type NodeStats = Partial<Record<keyof AztecNode, { times: number[] }>>;
9
+ export type RoundTripStats = {
10
+ /** Number of round trips (times we blocked waiting for node responses) */
11
+ roundTrips: number;
12
+ /** Total wall-clock time spent waiting on node (excludes parallel overlap) */
13
+ totalBlockingTime: number;
14
+ /** Individual round trip durations */
15
+ roundTripDurations: number[];
16
+ /** Methods called in each round trip (parallel calls grouped together) */
17
+ roundTripMethods: string[][];
18
+ };
19
+
20
+ const RoundTripStatsSchema = z.object({
21
+ roundTrips: z.number(),
22
+ totalBlockingTime: z.number(),
23
+ roundTripDurations: z.array(z.number()),
24
+ roundTripMethods: z.array(z.array(z.string())),
25
+ });
26
+
27
+ export type NodeStats = {
28
+ /** Per-method call stats */
29
+ perMethod: Partial<Record<keyof AztecNode, { times: number[] }>>;
30
+ /** Round trip stats tracking actual blocking waits */
31
+ roundTrips: RoundTripStats;
32
+ };
10
33
 
11
- const NodeStatsSchema = z.record(z.string(), z.object({ times: z.array(z.number()) }));
34
+ const NodeStatsSchema = z.object({
35
+ perMethod: z.record(z.string(), z.object({ times: z.array(z.number()) })),
36
+ roundTrips: RoundTripStatsSchema,
37
+ });
12
38
 
13
39
  type FunctionTiming = {
14
40
  functionName: string;
@@ -105,7 +131,15 @@ export class TxProfileResult {
105
131
  },
106
132
  ],
107
133
  {
108
- nodeRPCCalls: { getBlockHeader: { times: [1] } },
134
+ nodeRPCCalls: {
135
+ perMethod: { getBlockHeader: { times: [1] } },
136
+ roundTrips: {
137
+ roundTrips: 1,
138
+ totalBlockingTime: 1,
139
+ roundTripDurations: [1],
140
+ roundTripMethods: [['getBlockHeader']],
141
+ },
142
+ },
109
143
  timings: {
110
144
  sync: 1,
111
145
  proving: 1,
@@ -140,7 +174,15 @@ export class UtilitySimulationResult {
140
174
 
141
175
  static random(): UtilitySimulationResult {
142
176
  return new UtilitySimulationResult([Fr.random()], {
143
- nodeRPCCalls: { getBlockHeader: { times: [1] } },
177
+ nodeRPCCalls: {
178
+ perMethod: { getBlockHeader: { times: [1] } },
179
+ roundTrips: {
180
+ roundTrips: 1,
181
+ totalBlockingTime: 1,
182
+ roundTripDurations: [1],
183
+ roundTripMethods: [['getBlockHeader']],
184
+ },
185
+ },
144
186
  timings: {
145
187
  sync: 1,
146
188
  publicSimulation: 1,
@@ -5,14 +5,13 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
  import { withoutHexPrefix } from '@aztec/foundation/string';
6
6
 
7
7
  export type ViemZkPassportProofParams = {
8
+ version: `0x${string}`;
8
9
  proofVerificationData: {
9
10
  vkeyHash: `0x${string}`;
10
11
  proof: `0x${string}`;
11
12
  publicInputs: `0x${string}`[];
12
13
  };
13
- commitments: {
14
- committedInputs: `0x${string}`;
15
- };
14
+ committedInputs: `0x${string}`;
16
15
  serviceConfig: {
17
16
  validityPeriodInSeconds: bigint;
18
17
  domain: string;
@@ -91,7 +90,7 @@ export class ZkPassportProofParams {
91
90
  Buffer32.fromString(params.proofVerificationData.vkeyHash),
92
91
  Buffer.from(withoutHexPrefix(params.proofVerificationData.proof), 'hex'),
93
92
  params.proofVerificationData.publicInputs.map(input => Fr.fromString(input)),
94
- Buffer.from(withoutHexPrefix(params.commitments.committedInputs), 'hex'),
93
+ Buffer.from(withoutHexPrefix(params.committedInputs), 'hex'),
95
94
  params.serviceConfig.validityPeriodInSeconds,
96
95
  params.serviceConfig.domain,
97
96
  params.serviceConfig.scope,
@@ -99,20 +98,20 @@ export class ZkPassportProofParams {
99
98
  }
100
99
 
101
100
  toViem(): ViemZkPassportProofParams {
101
+ // Version is set to bytes32(0) as per zkpassport library convention
102
102
  return {
103
- serviceConfig: {
104
- devMode: this.devMode,
105
- validityPeriodInSeconds: this.validityPeriodInSeconds,
106
- domain: this.domain,
107
- scope: this.scope,
108
- },
103
+ version: '0x0000000000000000000000000000000000000000000000000000000000000000',
109
104
  proofVerificationData: {
110
105
  vkeyHash: this.vkeyHash.toString(),
111
106
  proof: `0x${this.proof.toString('hex')}`,
112
107
  publicInputs: this.publicInputs.map(input => input.toString()),
113
108
  },
114
- commitments: {
115
- committedInputs: `0x${this.committedInputs.toString('hex')}`,
109
+ committedInputs: `0x${this.committedInputs.toString('hex')}`,
110
+ serviceConfig: {
111
+ devMode: this.devMode,
112
+ validityPeriodInSeconds: this.validityPeriodInSeconds,
113
+ domain: this.domain,
114
+ scope: this.scope,
116
115
  },
117
116
  };
118
117
  }