@aztec/stdlib 4.0.0-nightly.20260111 → 4.0.0-nightly.20260113

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 (143) hide show
  1. package/dest/block/attestation_info.d.ts +5 -5
  2. package/dest/block/attestation_info.d.ts.map +1 -1
  3. package/dest/block/attestation_info.js +4 -4
  4. package/dest/block/l2_block.d.ts +6 -3
  5. package/dest/block/l2_block.d.ts.map +1 -1
  6. package/dest/block/l2_block.js +2 -2
  7. package/dest/block/l2_block_new.d.ts +1 -2
  8. package/dest/block/l2_block_new.d.ts.map +1 -1
  9. package/dest/block/l2_block_new.js +4 -1
  10. package/dest/block/l2_block_source.d.ts +245 -41
  11. package/dest/block/l2_block_source.d.ts.map +1 -1
  12. package/dest/block/l2_block_source.js +23 -5
  13. package/dest/block/l2_block_stream/index.d.ts +2 -1
  14. package/dest/block/l2_block_stream/index.d.ts.map +1 -1
  15. package/dest/block/l2_block_stream/index.js +1 -0
  16. package/dest/block/l2_block_stream/interfaces.d.ts +16 -5
  17. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  18. package/dest/block/l2_block_stream/l2_block_stream.d.ts +4 -2
  19. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  20. package/dest/block/l2_block_stream/l2_block_stream.js +102 -30
  21. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +24 -16
  22. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  23. package/dest/block/l2_block_stream/l2_tips_memory_store.js +55 -61
  24. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +49 -0
  25. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -0
  26. package/dest/block/l2_block_stream/l2_tips_store_base.js +179 -0
  27. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  28. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  29. package/dest/block/test/l2_tips_store_test_suite.js +483 -38
  30. package/dest/block/validate_block_result.d.ts +24 -24
  31. package/dest/block/validate_block_result.d.ts.map +1 -1
  32. package/dest/block/validate_block_result.js +13 -13
  33. package/dest/checkpoint/checkpoint.d.ts +1 -1
  34. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  35. package/dest/checkpoint/checkpoint.js +1 -0
  36. package/dest/checkpoint/checkpoint_info.d.ts +32 -3
  37. package/dest/checkpoint/checkpoint_info.d.ts.map +1 -1
  38. package/dest/checkpoint/checkpoint_info.js +34 -1
  39. package/dest/checkpoint/index.d.ts +2 -1
  40. package/dest/checkpoint/index.d.ts.map +1 -1
  41. package/dest/checkpoint/index.js +1 -0
  42. package/dest/interfaces/api_limit.d.ts +2 -1
  43. package/dest/interfaces/api_limit.d.ts.map +1 -1
  44. package/dest/interfaces/api_limit.js +1 -0
  45. package/dest/interfaces/archiver.d.ts +6 -6
  46. package/dest/interfaces/archiver.d.ts.map +1 -1
  47. package/dest/interfaces/archiver.js +6 -4
  48. package/dest/interfaces/aztec-node-admin.d.ts +12 -6
  49. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  50. package/dest/interfaces/aztec-node-admin.js +2 -2
  51. package/dest/interfaces/aztec-node.d.ts +2 -2
  52. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  53. package/dest/interfaces/aztec-node.js +8 -3
  54. package/dest/interfaces/configs.d.ts +6 -1
  55. package/dest/interfaces/configs.d.ts.map +1 -1
  56. package/dest/interfaces/configs.js +2 -1
  57. package/dest/interfaces/p2p.d.ts +7 -9
  58. package/dest/interfaces/p2p.d.ts.map +1 -1
  59. package/dest/interfaces/p2p.js +3 -4
  60. package/dest/interfaces/proving-job.d.ts +166 -166
  61. package/dest/interfaces/validator.d.ts +41 -7
  62. package/dest/interfaces/validator.d.ts.map +1 -1
  63. package/dest/interfaces/validator.js +3 -1
  64. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -5
  65. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  66. package/dest/kernel/hints/build_note_hash_read_request_hints.js +5 -6
  67. package/dest/p2p/attestation_utils.d.ts +3 -3
  68. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  69. package/dest/p2p/attestation_utils.js +1 -1
  70. package/dest/p2p/block_proposal.d.ts +85 -21
  71. package/dest/p2p/block_proposal.d.ts.map +1 -1
  72. package/dest/p2p/block_proposal.js +120 -37
  73. package/dest/p2p/checkpoint_attestation.d.ts +77 -0
  74. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -0
  75. package/dest/p2p/{block_attestation.js → checkpoint_attestation.js} +22 -19
  76. package/dest/p2p/checkpoint_proposal.d.ts +154 -0
  77. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -0
  78. package/dest/p2p/checkpoint_proposal.js +217 -0
  79. package/dest/p2p/consensus_payload.d.ts +4 -2
  80. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  81. package/dest/p2p/consensus_payload.js +3 -2
  82. package/dest/p2p/index.d.ts +4 -2
  83. package/dest/p2p/index.d.ts.map +1 -1
  84. package/dest/p2p/index.js +3 -1
  85. package/dest/p2p/signature_utils.d.ts +5 -3
  86. package/dest/p2p/signature_utils.d.ts.map +1 -1
  87. package/dest/p2p/signature_utils.js +3 -1
  88. package/dest/p2p/signed_txs.d.ts +40 -0
  89. package/dest/p2p/signed_txs.d.ts.map +1 -0
  90. package/dest/p2p/signed_txs.js +70 -0
  91. package/dest/p2p/topic_type.d.ts +3 -2
  92. package/dest/p2p/topic_type.d.ts.map +1 -1
  93. package/dest/p2p/topic_type.js +8 -2
  94. package/dest/rollup/checkpoint_header.d.ts +5 -1
  95. package/dest/rollup/checkpoint_header.d.ts.map +1 -1
  96. package/dest/rollup/checkpoint_header.js +4 -0
  97. package/dest/tests/factories.d.ts +13 -1
  98. package/dest/tests/factories.d.ts.map +1 -1
  99. package/dest/tests/factories.js +50 -1
  100. package/dest/tests/mocks.d.ts +55 -9
  101. package/dest/tests/mocks.d.ts.map +1 -1
  102. package/dest/tests/mocks.js +84 -35
  103. package/dest/tx/private_execution_result.d.ts +1 -5
  104. package/dest/tx/private_execution_result.d.ts.map +1 -1
  105. package/dest/tx/private_execution_result.js +3 -20
  106. package/package.json +8 -8
  107. package/src/block/attestation_info.ts +9 -6
  108. package/src/block/l2_block.ts +3 -3
  109. package/src/block/l2_block_new.ts +5 -1
  110. package/src/block/l2_block_source.ts +66 -16
  111. package/src/block/l2_block_stream/index.ts +1 -0
  112. package/src/block/l2_block_stream/interfaces.ts +16 -4
  113. package/src/block/l2_block_stream/l2_block_stream.ts +121 -38
  114. package/src/block/l2_block_stream/l2_tips_memory_store.ts +62 -56
  115. package/src/block/l2_block_stream/l2_tips_store_base.ts +226 -0
  116. package/src/block/test/l2_tips_store_test_suite.ts +485 -36
  117. package/src/block/validate_block_result.ts +35 -31
  118. package/src/checkpoint/checkpoint.ts +1 -0
  119. package/src/checkpoint/checkpoint_info.ts +45 -2
  120. package/src/checkpoint/index.ts +1 -0
  121. package/src/interfaces/api_limit.ts +1 -0
  122. package/src/interfaces/archiver.ts +14 -6
  123. package/src/interfaces/aztec-node-admin.ts +5 -2
  124. package/src/interfaces/aztec-node.ts +30 -3
  125. package/src/interfaces/configs.ts +5 -0
  126. package/src/interfaces/p2p.ts +8 -12
  127. package/src/interfaces/validator.ts +57 -7
  128. package/src/kernel/hints/build_note_hash_read_request_hints.ts +5 -8
  129. package/src/p2p/attestation_utils.ts +3 -3
  130. package/src/p2p/block_proposal.ts +185 -41
  131. package/src/p2p/{block_attestation.ts → checkpoint_attestation.ts} +31 -25
  132. package/src/p2p/checkpoint_proposal.ts +337 -0
  133. package/src/p2p/consensus_payload.ts +5 -2
  134. package/src/p2p/index.ts +3 -1
  135. package/src/p2p/signature_utils.ts +3 -1
  136. package/src/p2p/signed_txs.ts +83 -0
  137. package/src/p2p/topic_type.ts +3 -2
  138. package/src/rollup/checkpoint_header.ts +13 -0
  139. package/src/tests/factories.ts +42 -1
  140. package/src/tests/mocks.ts +146 -50
  141. package/src/tx/private_execution_result.ts +0 -15
  142. package/dest/p2p/block_attestation.d.ts +0 -77
  143. package/dest/p2p/block_attestation.d.ts.map +0 -1
@@ -5,57 +5,61 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
 
6
6
  import { z } from 'zod';
7
7
 
8
- import { BlockInfoSchema, type L2BlockInfo, deserializeBlockInfo, serializeBlockInfo } from './l2_block_info.js';
8
+ import {
9
+ type CheckpointInfo,
10
+ CheckpointInfoSchema,
11
+ deserializeCheckpointInfo,
12
+ serializeCheckpointInfo,
13
+ } from '../checkpoint/checkpoint_info.js';
9
14
  import { CommitteeAttestation } from './proposal/committee_attestation.js';
10
15
 
11
- /** Subtype for invalid block validation results */
12
- export type ValidateBlockNegativeResult =
16
+ /** Subtype for invalid checkpoint validation results */
17
+ export type ValidateCheckpointNegativeResult =
13
18
  | {
14
19
  valid: false;
15
- /** Identifiers from the invalid block */
16
- block: L2BlockInfo;
17
- /** Committee members at the epoch this block was proposed */
20
+ /** Identifiers from the invalid checkpoint */
21
+ checkpoint: CheckpointInfo;
22
+ /** Committee members at the epoch this checkpoint was proposed */
18
23
  committee: EthAddress[];
19
- /** Epoch in which this block was proposed */
24
+ /** Epoch in which this checkpoint was proposed */
20
25
  epoch: EpochNumber;
21
26
  /** Proposer selection seed for the epoch */
22
27
  seed: bigint;
23
- /** List of committee members who signed this block proposal */
28
+ /** List of committee members who signed this checkpoint proposal */
24
29
  attestors: EthAddress[];
25
- /** Committee attestations for this block as they were posted to L1 */
30
+ /** Committee attestations for this checkpoint as they were posted to L1 */
26
31
  attestations: CommitteeAttestation[];
27
- /** Reason for the block being invalid: not enough attestations were posted */
32
+ /** Reason for the checkpoint being invalid: not enough attestations were posted */
28
33
  reason: 'insufficient-attestations';
29
34
  }
30
35
  | {
31
36
  valid: false;
32
- /** Identifiers from the invalid block */
33
- block: L2BlockInfo;
34
- /** Committee members at the epoch this block was proposed */
37
+ /** Identifiers from the invalid checkpoint */
38
+ checkpoint: CheckpointInfo;
39
+ /** Committee members at the epoch this checkpoint was proposed */
35
40
  committee: EthAddress[];
36
- /** Epoch in which this block was proposed */
41
+ /** Epoch in which this checkpoint was proposed */
37
42
  epoch: EpochNumber;
38
43
  /** Proposer selection seed for the epoch */
39
44
  seed: bigint;
40
- /** List of committee members who signed this block proposal */
45
+ /** List of committee members who signed this checkpoint proposal */
41
46
  attestors: EthAddress[];
42
- /** Committee attestations for this block as they were posted to L1 */
47
+ /** Committee attestations for this checkpoint as they were posted to L1 */
43
48
  attestations: CommitteeAttestation[];
44
- /** Reason for the block being invalid: an invalid attestation was posted */
49
+ /** Reason for the checkpoint being invalid: an invalid attestation was posted */
45
50
  reason: 'invalid-attestation';
46
51
  /** Index in the attestations array of the invalid attestation posted */
47
52
  invalidIndex: number;
48
53
  };
49
54
 
50
- // TODO: Rename to ValidateAttestationsResult
51
- /** Result type for validating a block attestations */
52
- export type ValidateBlockResult = { valid: true } | ValidateBlockNegativeResult;
55
+ /** Result type for validating checkpoint attestations */
56
+ export type ValidateCheckpointResult = { valid: true } | ValidateCheckpointNegativeResult;
53
57
 
54
- export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
58
+ export const ValidateCheckpointResultSchema: ZodFor<ValidateCheckpointResult> = z.union([
55
59
  z.object({ valid: z.literal(true) }),
56
60
  z.object({
57
61
  valid: z.literal(false),
58
- block: BlockInfoSchema,
62
+ checkpoint: CheckpointInfoSchema,
59
63
  committee: z.array(schemas.EthAddress),
60
64
  epoch: EpochNumberSchema,
61
65
  seed: schemas.BigInt,
@@ -65,7 +69,7 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
65
69
  }),
66
70
  z.object({
67
71
  valid: z.literal(false),
68
- block: BlockInfoSchema,
72
+ checkpoint: CheckpointInfoSchema,
69
73
  committee: z.array(schemas.EthAddress),
70
74
  epoch: EpochNumberSchema,
71
75
  seed: schemas.BigInt,
@@ -76,17 +80,17 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
76
80
  }),
77
81
  ]);
78
82
 
79
- export function serializeValidateBlockResult(result: ValidateBlockResult): Buffer {
83
+ export function serializeValidateCheckpointResult(result: ValidateCheckpointResult): Buffer {
80
84
  if (result.valid) {
81
85
  return serializeToBuffer(true);
82
86
  }
83
87
 
84
- const l2Block = serializeBlockInfo(result.block);
88
+ const checkpointBuffer = serializeCheckpointInfo(result.checkpoint);
85
89
  return serializeToBuffer(
86
90
  result.valid,
87
91
  result.reason,
88
- l2Block.length,
89
- l2Block,
92
+ checkpointBuffer.length,
93
+ checkpointBuffer,
90
94
  result.committee.length,
91
95
  result.committee,
92
96
  result.epoch,
@@ -99,14 +103,14 @@ export function serializeValidateBlockResult(result: ValidateBlockResult): Buffe
99
103
  );
100
104
  }
101
105
 
102
- export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferReader): ValidateBlockResult {
106
+ export function deserializeValidateCheckpointResult(bufferOrReader: Buffer | BufferReader): ValidateCheckpointResult {
103
107
  const reader = BufferReader.asReader(bufferOrReader);
104
108
  const valid = reader.readBoolean();
105
109
  if (valid) {
106
110
  return { valid };
107
111
  }
108
112
  const reason = reader.readString() as 'insufficient-attestations' | 'invalid-attestation';
109
- const block = deserializeBlockInfo(reader.readBuffer());
113
+ const checkpoint = deserializeCheckpointInfo(reader.readBuffer());
110
114
  const committee = reader.readVector(EthAddress);
111
115
  const epoch = EpochNumber(reader.readNumber());
112
116
  const seed = reader.readBigInt();
@@ -114,9 +118,9 @@ export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferRe
114
118
  const attestations = reader.readVector(CommitteeAttestation);
115
119
  const invalidIndex = reader.readNumber();
116
120
  if (reason === 'insufficient-attestations') {
117
- return { valid, reason, block, committee, epoch, seed, attestors, attestations: attestations };
121
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, attestations };
118
122
  } else if (reason === 'invalid-attestation') {
119
- return { valid, reason, block, committee, epoch, seed, attestors, invalidIndex, attestations: attestations };
123
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, invalidIndex, attestations };
120
124
  } else {
121
125
  const _: never = reason;
122
126
  throw new Error(`Unknown reason: ${reason}`);
@@ -73,6 +73,7 @@ export class Checkpoint {
73
73
  public toCheckpointInfo(): CheckpointInfo {
74
74
  return {
75
75
  archive: this.archive.root,
76
+ lastArchive: this.header.lastArchiveRoot,
76
77
  slotNumber: this.header.slotNumber,
77
78
  checkpointNumber: this.number,
78
79
  timestamp: this.header.timestamp,
@@ -1,9 +1,52 @@
1
- import type { CheckpointNumber } from '@aztec/foundation/branded-types';
2
- import type { Fr, SlotNumber } from '@aztec/foundation/schemas';
1
+ import {
2
+ CheckpointNumber,
3
+ CheckpointNumberSchema,
4
+ SlotNumber,
5
+ SlotNumberSchema,
6
+ } from '@aztec/foundation/branded-types';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
+ import { schemas } from '@aztec/foundation/schemas';
9
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
10
+
11
+ import { z } from 'zod';
3
12
 
4
13
  export type CheckpointInfo = {
5
14
  archive: Fr;
15
+ lastArchive: Fr;
6
16
  slotNumber: SlotNumber;
7
17
  checkpointNumber: CheckpointNumber;
8
18
  timestamp: bigint;
9
19
  };
20
+
21
+ export function randomCheckpointInfo(checkpointNumber?: CheckpointNumber | number): CheckpointInfo {
22
+ return {
23
+ archive: Fr.random(),
24
+ lastArchive: Fr.random(),
25
+ slotNumber: SlotNumber(Math.floor(Math.random() * 100000) + 1),
26
+ checkpointNumber: CheckpointNumber(checkpointNumber ?? Math.floor(Math.random() * 100000) + 1),
27
+ timestamp: BigInt(Math.floor(Date.now() / 1000)),
28
+ };
29
+ }
30
+
31
+ export const CheckpointInfoSchema = z.object({
32
+ archive: schemas.Fr,
33
+ lastArchive: schemas.Fr,
34
+ slotNumber: SlotNumberSchema,
35
+ checkpointNumber: CheckpointNumberSchema,
36
+ timestamp: schemas.BigInt,
37
+ });
38
+
39
+ export function serializeCheckpointInfo(info: CheckpointInfo): Buffer {
40
+ return serializeToBuffer(info.archive, info.lastArchive, info.slotNumber, info.checkpointNumber, info.timestamp);
41
+ }
42
+
43
+ export function deserializeCheckpointInfo(buffer: Buffer | BufferReader): CheckpointInfo {
44
+ const reader = BufferReader.asReader(buffer);
45
+ return {
46
+ archive: reader.readObject(Fr),
47
+ lastArchive: reader.readObject(Fr),
48
+ slotNumber: SlotNumber(reader.readNumber()),
49
+ checkpointNumber: CheckpointNumber(reader.readNumber()),
50
+ timestamp: reader.readBigInt(),
51
+ };
52
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './checkpoint.js';
2
+ export * from './checkpoint_info.js';
2
3
  export * from './published_checkpoint.js';
@@ -1,3 +1,4 @@
1
1
  export const MAX_RPC_LEN = 100;
2
2
  export const MAX_RPC_TXS_LEN = 50;
3
3
  export const MAX_RPC_BLOCKS_LEN = 50;
4
+ export const MAX_RPC_CHECKPOINTS_LEN = 50;
@@ -8,7 +8,7 @@ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_
8
8
  import { L2Block } from '../block/l2_block.js';
9
9
  import { L2BlockNew } from '../block/l2_block_new.js';
10
10
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
11
- import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
11
+ import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
12
12
  import { Checkpoint } from '../checkpoint/checkpoint.js';
13
13
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
14
14
  import {
@@ -52,14 +52,14 @@ export type ArchiverSpecificConfig = {
52
52
  /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb. */
53
53
  archiverStoreMapSizeKb?: number;
54
54
 
55
- /** Whether to skip validating block attestations (use only for testing). */
56
- skipValidateBlockAttestations?: boolean;
57
-
58
55
  /** Maximum allowed drift in seconds between the Ethereum client and current time. */
59
56
  maxAllowedEthClientDriftSeconds?: number;
60
57
 
61
58
  /** Whether to allow starting the archiver without debug/trace method support on Ethereum hosts */
62
59
  ethereumAllowNoDebugHosts?: boolean;
60
+
61
+ /** Skip validating checkpoint attestations (for testing purposes only) */
62
+ skipValidateCheckpointAttestations?: boolean;
63
63
  };
64
64
 
65
65
  export const ArchiverSpecificConfigSchema = z.object({
@@ -68,9 +68,9 @@ export const ArchiverSpecificConfigSchema = z.object({
68
68
  viemPollingIntervalMS: schemas.Integer.optional(),
69
69
  maxLogs: schemas.Integer.optional(),
70
70
  archiverStoreMapSizeKb: schemas.Integer.optional(),
71
- skipValidateBlockAttestations: z.boolean().optional(),
72
71
  maxAllowedEthClientDriftSeconds: schemas.Integer.optional(),
73
72
  ethereumAllowNoDebugHosts: z.boolean().optional(),
73
+ skipValidateCheckpointAttestations: z.boolean().optional(),
74
74
  });
75
75
 
76
76
  export type ArchiverApi = Omit<
@@ -89,6 +89,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
89
89
  .args(z.union([BlockNumberSchema, z.literal('latest')]))
90
90
  .returns(BlockHeader.schema.optional()),
91
91
  getCheckpointedBlock: z.function().args(BlockNumberSchema).returns(CheckpointedL2Block.schema.optional()),
92
+ getCheckpointedBlocks: z
93
+ .function()
94
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
95
+ .returns(z.array(CheckpointedL2Block.schema)),
92
96
  getBlocks: z
93
97
  .function()
94
98
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
@@ -101,6 +105,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
101
105
  .function()
102
106
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
103
107
  .returns(z.array(PublishedL2Block.schema)),
108
+ getL2BlocksNew: z
109
+ .function()
110
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
111
+ .returns(z.array(L2BlockNew.schema)),
104
112
  getPublishedBlockByHash: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
105
113
  getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
106
114
  getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
@@ -144,5 +152,5 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
144
152
  getL1Timestamp: z.function().args().returns(schemas.BigInt.optional()),
145
153
  syncImmediate: z.function().args().returns(z.void()),
146
154
  isPendingChainInvalid: z.function().args().returns(z.boolean()),
147
- getPendingChainValidationStatus: z.function().args().returns(ValidateBlockResultSchema),
155
+ getPendingChainValidationStatus: z.function().args().returns(ValidateCheckpointResultSchema),
148
156
  };
@@ -56,7 +56,10 @@ export type AztecNodeAdminConfig = ValidatorClientFullConfig &
56
56
  SequencerConfig &
57
57
  ProverConfig &
58
58
  SlasherConfig &
59
- Pick<ArchiverSpecificConfig, 'archiverPollingIntervalMS' | 'skipValidateBlockAttestations' | 'archiverBatchSize'> & {
59
+ Pick<
60
+ ArchiverSpecificConfig,
61
+ 'archiverPollingIntervalMS' | 'archiverBatchSize' | 'skipValidateCheckpointAttestations'
62
+ > & {
60
63
  maxPendingTxCount: number;
61
64
  };
62
65
 
@@ -66,8 +69,8 @@ export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConf
66
69
  .merge(
67
70
  ArchiverSpecificConfigSchema.pick({
68
71
  archiverPollingIntervalMS: true,
69
- skipValidateBlockAttestations: true,
70
72
  archiverBatchSize: true,
73
+ skipValidateCheckpointAttestations: true,
71
74
  }),
72
75
  )
73
76
  .merge(z.object({ maxPendingTxCount: z.number() }));
@@ -10,6 +10,7 @@ import {
10
10
  BlockNumber,
11
11
  BlockNumberPositiveSchema,
12
12
  BlockNumberSchema,
13
+ CheckpointNumberPositiveSchema,
13
14
  EpochNumber,
14
15
  EpochNumberSchema,
15
16
  type SlotNumber,
@@ -23,10 +24,12 @@ import { z } from 'zod';
23
24
 
24
25
  import type { AztecAddress } from '../aztec-address/index.js';
25
26
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
26
- import { PublishedL2Block } from '../block/checkpointed_l2_block.js';
27
+ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_block.js';
27
28
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
28
29
  import { L2Block } from '../block/l2_block.js';
30
+ import { L2BlockNew } from '../block/l2_block_new.js';
29
31
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
32
+ import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
30
33
  import {
31
34
  type ContractClassPublic,
32
35
  ContractClassPublicSchema,
@@ -59,7 +62,7 @@ import { SingleValidatorStatsSchema, ValidatorsStatsSchema } from '../validators
59
62
  import type { SingleValidatorStats, ValidatorsStats } from '../validators/types.js';
60
63
  import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
61
64
  import { type AllowedElement, AllowedElementSchema } from './allowed_element.js';
62
- import { MAX_RPC_BLOCKS_LEN, MAX_RPC_LEN, MAX_RPC_TXS_LEN } from './api_limit.js';
65
+ import { MAX_RPC_BLOCKS_LEN, MAX_RPC_CHECKPOINTS_LEN, MAX_RPC_LEN, MAX_RPC_TXS_LEN } from './api_limit.js';
63
66
  import {
64
67
  type GetContractClassLogsResponse,
65
68
  GetContractClassLogsResponseSchema,
@@ -73,7 +76,16 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
73
76
  * We will probably implement the additional interfaces by means other than Aztec Node as it's currently a privacy leak
74
77
  */
75
78
  export interface AztecNode
76
- extends Pick<L2BlockSource, 'getBlocks' | 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'> {
79
+ extends Pick<
80
+ L2BlockSource,
81
+ | 'getBlocks'
82
+ | 'getL2BlocksNew'
83
+ | 'getPublishedBlocks'
84
+ | 'getPublishedCheckpoints'
85
+ | 'getBlockHeader'
86
+ | 'getL2Tips'
87
+ | 'getCheckpointedBlocks'
88
+ > {
77
89
  /**
78
90
  * Returns the tips of the L2 chain.
79
91
  */
@@ -582,6 +594,21 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
582
594
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
583
595
  .returns(z.array(PublishedL2Block.schema)),
584
596
 
597
+ getPublishedCheckpoints: z
598
+ .function()
599
+ .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
600
+ .returns(z.array(PublishedCheckpoint.schema)),
601
+
602
+ getL2BlocksNew: z
603
+ .function()
604
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
605
+ .returns(z.array(L2BlockNew.schema)),
606
+
607
+ getCheckpointedBlocks: z
608
+ .function()
609
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN), optional(z.boolean()))
610
+ .returns(z.array(CheckpointedL2Block.schema)),
611
+
585
612
  getCurrentMinFees: z.function().returns(GasFees.schema),
586
613
 
587
614
  getMaxPriorityFees: z.function().returns(GasFees.schema),
@@ -67,6 +67,10 @@ export interface SequencerConfig {
67
67
  blockDurationMs?: number;
68
68
  /** Have sequencer build and publish an empty checkpoint if there are no txs */
69
69
  buildCheckpointIfEmpty?: boolean;
70
+
71
+ // TODO(palla/mbps): Change default to false once block sync is stable
72
+ /** Skip pushing proposed blocks to archiver (default: true) */
73
+ skipPushProposedBlocksToArchiver?: boolean;
70
74
  }
71
75
 
72
76
  export const SequencerConfigSchema = zodFor<SequencerConfig>()(
@@ -100,6 +104,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
100
104
  shuffleAttestationOrdering: z.boolean().optional(),
101
105
  blockDurationMs: z.number().positive().optional(),
102
106
  buildCheckpointIfEmpty: z.boolean().optional(),
107
+ skipPushProposedBlocksToArchiver: z.boolean().optional(),
103
108
  }),
104
109
  );
105
110
 
@@ -2,7 +2,7 @@ import type { SlotNumber } from '@aztec/foundation/branded-types';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
5
- import { BlockAttestation } from '../p2p/block_attestation.js';
5
+ import { CheckpointAttestation } from '../p2p/checkpoint_attestation.js';
6
6
  import type { P2PClientType } from '../p2p/client_type.js';
7
7
  import { type ApiSchemaFor, optional, schemas } from '../schemas/index.js';
8
8
  import { Tx } from '../tx/tx.js';
@@ -52,21 +52,18 @@ export interface P2PApiWithoutAttestations {
52
52
 
53
53
  export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
54
54
  /**
55
- * Queries the Attestation pool for attestations for the given slot
55
+ * Queries the Attestation pool for checkpoint attestations for the given slot
56
56
  *
57
57
  * @param slot - the slot to query
58
58
  * @param proposalId - the proposal id to query, or undefined to query all proposals for the slot
59
- * @returns BlockAttestations
59
+ * @returns CheckpointAttestations
60
60
  */
61
- getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]>;
62
-
63
- /** Deletes a given attestation manually from the p2p client attestation pool. */
64
- deleteAttestation(attestation: BlockAttestation): Promise<void>;
61
+ getCheckpointAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<CheckpointAttestation[]>;
65
62
  }
66
63
 
67
64
  export interface P2PClient extends P2PApiWithAttestations {
68
- /** Manually adds an attestation to the p2p client attestation pool. */
69
- addAttestations(attestations: BlockAttestation[]): Promise<void>;
65
+ /** Manually adds checkpoint attestations to the p2p client attestation pool. */
66
+ addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
70
67
  }
71
68
 
72
69
  export type P2PApi<T extends P2PClientType = P2PClientType.Full> = T extends P2PClientType.Full
@@ -78,10 +75,10 @@ export type P2PApiFull<T extends P2PClientType = P2PClientType.Full> = T extends
78
75
  : P2PApiWithoutAttestations;
79
76
 
80
77
  export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
81
- getAttestationsForSlot: z
78
+ getCheckpointAttestationsForSlot: z
82
79
  .function()
83
80
  .args(schemas.SlotNumber, optional(z.string()))
84
- .returns(z.array(BlockAttestation.schema)),
81
+ .returns(z.array(CheckpointAttestation.schema)),
85
82
  getPendingTxs: z
86
83
  .function()
87
84
  .args(optional(z.number().gte(1).lte(MAX_RPC_TXS_LEN).default(MAX_RPC_TXS_LEN)), optional(TxHash.schema))
@@ -90,5 +87,4 @@ export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
90
87
  getPendingTxCount: z.function().returns(schemas.Integer),
91
88
  getEncodedEnr: z.function().returns(z.string().optional()),
92
89
  getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema)),
93
- deleteAttestation: z.function().args(BlockAttestation.schema).returns(z.void()),
94
90
  };
@@ -4,14 +4,21 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import type { Signature } from '@aztec/foundation/eth-signature';
5
5
  import { schemas, zodFor } from '@aztec/foundation/schemas';
6
6
  import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
7
- import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
8
- import type { Tx } from '@aztec/stdlib/tx';
7
+ import type {
8
+ BlockProposal,
9
+ BlockProposalOptions,
10
+ CheckpointAttestation,
11
+ CheckpointLastBlockData,
12
+ CheckpointProposal,
13
+ CheckpointProposalOptions,
14
+ } from '@aztec/stdlib/p2p';
15
+ import type { CheckpointHeader } from '@aztec/stdlib/rollup';
16
+ import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
9
17
 
10
18
  import type { PeerId } from '@libp2p/interface';
11
19
  import { z } from 'zod';
12
20
 
13
21
  import type { CommitteeAttestationsAndSigners } from '../block/index.js';
14
- import type { CheckpointHeader } from '../rollup/checkpoint_header.js';
15
22
  import { AllowedElementSchema } from './allowed_element.js';
16
23
 
17
24
  /**
@@ -44,6 +51,14 @@ export interface ValidatorClientConfig {
44
51
 
45
52
  /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
46
53
  fishermanMode?: boolean;
54
+
55
+ // TODO(palla/mbps): Change default to false once checkpoint validation is stable
56
+ /** Skip checkpoint proposal validation and always attest (default: true) */
57
+ skipCheckpointProposalValidation?: boolean;
58
+
59
+ // TODO(palla/mbps): Change default to false once block sync is stable
60
+ /** Skip pushing re-executed blocks to archiver (default: true) */
61
+ skipPushProposedBlocksToArchiver?: boolean;
47
62
  }
48
63
 
49
64
  export type ValidatorClientFullConfig = ValidatorClientConfig &
@@ -66,6 +81,8 @@ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'v
66
81
  validatorReexecuteDeadlineMs: z.number().min(0),
67
82
  alwaysReexecuteBlockProposals: z.boolean().optional(),
68
83
  fishermanMode: z.boolean().optional(),
84
+ skipCheckpointProposalValidation: z.boolean().optional(),
85
+ skipPushProposedBlocksToArchiver: z.boolean().optional(),
69
86
  }),
70
87
  );
71
88
 
@@ -78,23 +95,56 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
78
95
  }),
79
96
  );
80
97
 
98
+ export type CreateCheckpointProposalLastBlockData = Omit<CheckpointLastBlockData, 'txHashes'> & { txs: Tx[] };
99
+
81
100
  export interface Validator {
82
101
  start(): Promise<void>;
83
102
  updateConfig(config: Partial<ValidatorClientFullConfig>): void;
84
103
 
85
104
  // Block validation responsibilities
86
105
  createBlockProposal(
87
- blockNumber: number,
88
- header: CheckpointHeader,
106
+ blockHeader: BlockHeader,
107
+ indexWithinCheckpoint: number,
108
+ inHash: Fr,
89
109
  archive: Fr,
90
110
  txs: Tx[],
91
111
  proposerAddress: EthAddress | undefined,
92
112
  options: BlockProposalOptions,
93
113
  ): Promise<BlockProposal | undefined>;
94
- attestToProposal(proposal: BlockProposal, sender: PeerId): Promise<BlockAttestation[] | undefined>;
114
+
115
+ /** Creates a checkpoint proposal for the last block in a checkpoint */
116
+ createCheckpointProposal(
117
+ checkpointHeader: CheckpointHeader,
118
+ archive: Fr,
119
+ lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
120
+ proposerAddress: EthAddress | undefined,
121
+ options: CheckpointProposalOptions,
122
+ ): Promise<CheckpointProposal>;
123
+
124
+ /**
125
+ * Validate a block proposal from a peer.
126
+ * Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
127
+ * @returns true if the proposal is valid, false otherwise
128
+ */
129
+ validateBlockProposal(proposal: BlockProposal, sender: PeerId): Promise<boolean>;
130
+
131
+ /**
132
+ * Validate and attest to a checkpoint proposal from a peer.
133
+ * @returns Checkpoint attestations if valid, undefined otherwise
134
+ */
135
+ attestToCheckpointProposal(
136
+ proposal: CheckpointProposal,
137
+ sender: PeerId,
138
+ ): Promise<CheckpointAttestation[] | undefined>;
95
139
 
96
140
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
97
- collectAttestations(proposal: BlockProposal, required: number, deadline: Date): Promise<BlockAttestation[]>;
141
+
142
+ /** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
143
+ collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]>;
144
+
145
+ /** Collect attestations from the p2p network for a checkpoint proposal */
146
+ collectAttestations(proposal: CheckpointProposal, required: number, deadline: Date): Promise<CheckpointAttestation[]>;
147
+
98
148
  signAttestationsAndSigners(
99
149
  attestationsAndSigners: CommitteeAttestationsAndSigners,
100
150
  proposer: EthAddress,
@@ -3,6 +3,7 @@ import {
3
3
  MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
4
4
  type NOTE_HASH_TREE_HEIGHT,
5
5
  } from '@aztec/constants';
6
+ import type { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import type { MembershipWitness } from '@aztec/foundation/trees';
7
8
 
8
9
  import type { ClaimedLengthArray } from '../claimed_length_array.js';
@@ -61,12 +62,11 @@ export function getNoteHashReadRequestResetActions(
61
62
 
62
63
  export async function buildNoteHashReadRequestHintsFromResetActions<PENDING extends number, SETTLED extends number>(
63
64
  oracle: {
64
- getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
65
+ getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
65
66
  },
66
67
  noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
67
68
  noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
68
69
  resetActions: ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
69
- noteHashLeafIndexMap: Map<bigint, bigint>,
70
70
  maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
71
71
  maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
72
72
  ) {
@@ -79,11 +79,10 @@ export async function buildNoteHashReadRequestHintsFromResetActions<PENDING exte
79
79
  for (let i = 0; i < resetActions.actions.length; i++) {
80
80
  if (resetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
81
81
  const readRequest = noteHashReadRequests.array[i];
82
- const leafIndex = noteHashLeafIndexMap.get(readRequest.value.toBigInt());
83
- if (leafIndex === undefined) {
82
+ const membershipWitness = await oracle.getNoteHashMembershipWitness(readRequest.value);
83
+ if (!membershipWitness) {
84
84
  throw new Error('Read request is reading an unknown note hash.');
85
85
  }
86
- const membershipWitness = await oracle.getNoteHashMembershipWitness(leafIndex);
87
86
  builder.addSettledReadRequest(i, membershipWitness, readRequest.value);
88
87
  }
89
88
  }
@@ -101,11 +100,10 @@ export async function buildNoteHashReadRequestHintsFromResetActions<PENDING exte
101
100
 
102
101
  export async function buildNoteHashReadRequestHints<PENDING extends number, SETTLED extends number>(
103
102
  oracle: {
104
- getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
103
+ getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
105
104
  },
106
105
  noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
107
106
  noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
108
- noteHashLeafIndexMap: Map<bigint, bigint>,
109
107
  futureNoteHashes: ScopedNoteHash[],
110
108
  maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
111
109
  maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
@@ -116,7 +114,6 @@ export async function buildNoteHashReadRequestHints<PENDING extends number, SETT
116
114
  noteHashReadRequests,
117
115
  noteHashes,
118
116
  resetActions,
119
- noteHashLeafIndexMap,
120
117
  maxPending,
121
118
  maxSettled,
122
119
  );
@@ -1,7 +1,7 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
 
3
3
  import { CommitteeAttestation } from '../block/index.js';
4
- import type { BlockAttestation } from './block_attestation.js';
4
+ import type { CheckpointAttestation } from './checkpoint_attestation.js';
5
5
 
6
6
  /**
7
7
  * Returns attestation signatures in the order of a series of provided ethereum addresses
@@ -9,10 +9,10 @@ import type { BlockAttestation } from './block_attestation.js';
9
9
  * @todo: perform this logic within the memory attestation store instead?
10
10
  */
11
11
  export function orderAttestations(
12
- attestations: BlockAttestation[],
12
+ attestations: CheckpointAttestation[],
13
13
  orderAddresses: EthAddress[],
14
14
  ): CommitteeAttestation[] {
15
- // Create a map of sender addresses to BlockAttestations
15
+ // Create a map of sender addresses to attestations
16
16
  const attestationMap = new Map<string, CommitteeAttestation>();
17
17
 
18
18
  for (const attestation of attestations) {