@aztec/stdlib 1.0.0-nightly.20250607 → 1.0.0-nightly.20250610

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 (130) hide show
  1. package/dest/block/l2_block.js +1 -1
  2. package/dest/hash/hash.d.ts +8 -2
  3. package/dest/hash/hash.d.ts.map +1 -1
  4. package/dest/hash/hash.js +8 -16
  5. package/dest/interfaces/epoch-prover.d.ts +3 -1
  6. package/dest/interfaces/epoch-prover.d.ts.map +1 -1
  7. package/dest/interfaces/proving-job.d.ts +1 -1
  8. package/dest/interfaces/proving-job.d.ts.map +1 -1
  9. package/dest/interfaces/service.d.ts +1 -1
  10. package/dest/interfaces/service.d.ts.map +1 -1
  11. package/dest/kernel/index.d.ts +0 -1
  12. package/dest/kernel/index.d.ts.map +1 -1
  13. package/dest/kernel/index.js +0 -1
  14. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  15. package/dest/p2p/consensus_payload.js +9 -3
  16. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +3 -3
  17. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
  18. package/dest/rollup/base_or_merge_rollup_public_inputs.js +3 -3
  19. package/dest/rollup/base_rollup_hints.d.ts +15 -14
  20. package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
  21. package/dest/rollup/base_rollup_hints.js +13 -12
  22. package/dest/rollup/block_constant_data.d.ts +37 -0
  23. package/dest/rollup/block_constant_data.d.ts.map +1 -0
  24. package/dest/rollup/{constant_rollup_data.js → block_constant_data.js} +10 -13
  25. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +12 -27
  26. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +1 -1
  27. package/dest/rollup/block_root_or_block_merge_public_inputs.js +8 -15
  28. package/dest/rollup/block_root_rollup.d.ts +24 -9
  29. package/dest/rollup/block_root_rollup.d.ts.map +1 -1
  30. package/dest/rollup/block_root_rollup.js +15 -7
  31. package/dest/rollup/empty_block_root_rollup_inputs.d.ts +4 -4
  32. package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +1 -1
  33. package/dest/rollup/empty_block_root_rollup_inputs.js +2 -2
  34. package/dest/rollup/epoch_constant_data.d.ts +39 -0
  35. package/dest/rollup/epoch_constant_data.d.ts.map +1 -0
  36. package/dest/rollup/epoch_constant_data.js +40 -0
  37. package/dest/rollup/index.d.ts +2 -1
  38. package/dest/rollup/index.d.ts.map +1 -1
  39. package/dest/rollup/index.js +2 -1
  40. package/dest/rollup/root_rollup.d.ts +7 -11
  41. package/dest/rollup/root_rollup.d.ts.map +1 -1
  42. package/dest/rollup/root_rollup.js +7 -10
  43. package/dest/snapshots/types.d.ts +4 -4
  44. package/dest/tests/factories.d.ts +1 -10
  45. package/dest/tests/factories.d.ts.map +1 -1
  46. package/dest/tests/factories.js +23 -36
  47. package/dest/tests/mocks.d.ts.map +1 -1
  48. package/dest/tests/mocks.js +3 -3
  49. package/dest/trees/append_only_tree_snapshot.d.ts +6 -2
  50. package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
  51. package/dest/trees/append_only_tree_snapshot.js +17 -2
  52. package/dest/tx/block_header.js +3 -3
  53. package/dest/tx/content_commitment.d.ts +3 -0
  54. package/dest/tx/content_commitment.d.ts.map +1 -1
  55. package/dest/tx/content_commitment.js +12 -1
  56. package/dest/tx/global_variables.js +1 -1
  57. package/dest/tx/index.d.ts +1 -0
  58. package/dest/tx/index.d.ts.map +1 -1
  59. package/dest/tx/index.js +1 -0
  60. package/dest/tx/offchain_message.d.ts +15 -0
  61. package/dest/tx/offchain_message.d.ts.map +1 -0
  62. package/dest/tx/offchain_message.js +4 -0
  63. package/dest/tx/partial_state_reference.d.ts +8 -0
  64. package/dest/tx/partial_state_reference.d.ts.map +1 -1
  65. package/dest/tx/partial_state_reference.js +19 -2
  66. package/dest/tx/private_execution_result.d.ts +18 -0
  67. package/dest/tx/private_execution_result.d.ts.map +1 -1
  68. package/dest/tx/private_execution_result.js +32 -2
  69. package/dest/tx/processed_tx.d.ts +2 -3
  70. package/dest/tx/processed_tx.d.ts.map +1 -1
  71. package/dest/tx/processed_tx.js +18 -8
  72. package/dest/tx/proposed_block_header.d.ts +3 -0
  73. package/dest/tx/proposed_block_header.d.ts.map +1 -1
  74. package/dest/tx/proposed_block_header.js +19 -1
  75. package/dest/tx/proven_tx.d.ts +2 -0
  76. package/dest/tx/proven_tx.d.ts.map +1 -1
  77. package/dest/tx/proven_tx.js +4 -1
  78. package/dest/tx/public_simulation_output.d.ts +3 -3
  79. package/dest/tx/public_simulation_output.d.ts.map +1 -1
  80. package/dest/tx/public_simulation_output.js +7 -7
  81. package/dest/tx/state_reference.d.ts +4 -0
  82. package/dest/tx/state_reference.d.ts.map +1 -1
  83. package/dest/tx/state_reference.js +20 -3
  84. package/dest/tx/tree_snapshots.js +3 -3
  85. package/dest/tx/tx.d.ts +1 -1
  86. package/dest/tx/tx.js +1 -1
  87. package/dest/tx/tx_hash.d.ts +1 -0
  88. package/dest/tx/tx_hash.d.ts.map +1 -1
  89. package/dest/tx/tx_hash.js +1 -0
  90. package/package.json +7 -7
  91. package/src/block/l2_block.ts +1 -1
  92. package/src/hash/hash.ts +16 -19
  93. package/src/interfaces/epoch-prover.ts +8 -2
  94. package/src/interfaces/service.ts +1 -1
  95. package/src/kernel/index.ts +0 -1
  96. package/src/p2p/consensus_payload.ts +13 -3
  97. package/src/rollup/base_or_merge_rollup_public_inputs.ts +4 -4
  98. package/src/rollup/base_rollup_hints.ts +12 -11
  99. package/src/rollup/block_constant_data.ts +63 -0
  100. package/src/rollup/block_root_or_block_merge_public_inputs.ts +10 -21
  101. package/src/rollup/block_root_rollup.ts +17 -5
  102. package/src/rollup/empty_block_root_rollup_inputs.ts +3 -3
  103. package/src/rollup/epoch_constant_data.ts +44 -0
  104. package/src/rollup/index.ts +2 -1
  105. package/src/rollup/root_rollup.ts +10 -12
  106. package/src/tests/factories.ts +36 -58
  107. package/src/tests/mocks.ts +3 -2
  108. package/src/trees/append_only_tree_snapshot.ts +18 -2
  109. package/src/tx/block_header.ts +3 -3
  110. package/src/tx/content_commitment.ts +19 -1
  111. package/src/tx/global_variables.ts +1 -1
  112. package/src/tx/index.ts +1 -0
  113. package/src/tx/offchain_message.ts +16 -0
  114. package/src/tx/partial_state_reference.ts +29 -4
  115. package/src/tx/private_execution_result.ts +30 -0
  116. package/src/tx/processed_tx.ts +26 -13
  117. package/src/tx/proposed_block_header.ts +31 -1
  118. package/src/tx/proven_tx.ts +10 -1
  119. package/src/tx/public_simulation_output.ts +5 -5
  120. package/src/tx/state_reference.ts +22 -3
  121. package/src/tx/tree_snapshots.ts +9 -9
  122. package/src/tx/tx.ts +1 -1
  123. package/src/tx/tx_hash.ts +1 -0
  124. package/dest/kernel/combined_constant_data.d.ts +0 -71
  125. package/dest/kernel/combined_constant_data.d.ts.map +0 -1
  126. package/dest/kernel/combined_constant_data.js +0 -73
  127. package/dest/rollup/constant_rollup_data.d.ts +0 -45
  128. package/dest/rollup/constant_rollup_data.d.ts.map +0 -1
  129. package/src/kernel/combined_constant_data.ts +0 -128
  130. package/src/rollup/constant_rollup_data.ts +0 -54
package/src/hash/hash.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { GeneratorIndex } from '@aztec/constants';
2
- import { poseidon2Hash, poseidon2HashWithSeparator, sha256Trunc } from '@aztec/foundation/crypto';
2
+ import { poseidon2Hash, poseidon2HashWithSeparator, sha256ToField } from '@aztec/foundation/crypto';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
3
4
  import { Fr } from '@aztec/foundation/fields';
4
5
 
5
6
  import type { AztecAddress } from '../aztec-address/index.js';
6
- import type { ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
7
7
 
8
8
  /**
9
9
  * Computes a hash of a given verification key.
@@ -126,21 +126,18 @@ export async function computeL1ToL2MessageNullifier(contract: AztecAddress, mess
126
126
  * Calculates a siloed hash of a scoped l2 to l1 message.
127
127
  * @returns Fr containing 248 bits of information of sha256 hash.
128
128
  */
129
- export function siloL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message, version: Fr, chainId: Fr): Fr {
130
- if (l2ToL1Message.contractAddress.isZero()) {
131
- return Fr.ZERO;
132
- }
133
- // Left-pad recipient to 32 bytes to match what the circuit is doing
134
- // TODO: Only hash 20 bytes for l2l1 recipient everywhere.
135
- const paddedRecipient = Buffer.alloc(32);
136
- l2ToL1Message.message.recipient.toBuffer().copy(paddedRecipient, 12);
137
-
138
- const preimage = Buffer.concat([
139
- l2ToL1Message.contractAddress.toBuffer(),
140
- version.toBuffer(),
141
- paddedRecipient,
142
- chainId.toBuffer(),
143
- l2ToL1Message.message.content.toBuffer(),
144
- ]);
145
- return Fr.fromBuffer(sha256Trunc(preimage));
129
+ export function computeL2ToL1MessageHash({
130
+ l2Sender,
131
+ l1Recipient,
132
+ content,
133
+ rollupVersion,
134
+ chainId,
135
+ }: {
136
+ l2Sender: AztecAddress;
137
+ l1Recipient: EthAddress;
138
+ content: Fr;
139
+ rollupVersion: Fr;
140
+ chainId: Fr;
141
+ }) {
142
+ return sha256ToField([l2Sender, rollupVersion, l1Recipient, chainId, content]);
146
143
  }
@@ -1,3 +1,4 @@
1
+ import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
1
2
  import type { Fr } from '@aztec/foundation/fields';
2
3
 
3
4
  import type { L2Block } from '../block/l2_block.js';
@@ -15,7 +16,12 @@ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
15
16
  * @param firstBlockNumber - The block number of the first block in the epoch.
16
17
  * @param totalNumBlocks - The total number of blocks expected in the epoch (must be at least one).
17
18
  **/
18
- startNewEpoch(epochNumber: number, firstBlockNumber: number, totalNumBlocks: number): void;
19
+ startNewEpoch(
20
+ epochNumber: number,
21
+ firstBlockNumber: number,
22
+ totalNumBlocks: number,
23
+ finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
24
+ ): void;
19
25
 
20
26
  /**
21
27
  * Kickstarts tube circuits for the specified txs. These will be used during epoch proving.
@@ -27,7 +33,7 @@ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
27
33
  setBlockCompleted(blockNumber: number, expectedBlockHeader?: BlockHeader): Promise<L2Block>;
28
34
 
29
35
  /** Pads the epoch with empty block roots if needed and blocks until proven. Throws if proving has failed. */
30
- finaliseEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof }>;
36
+ finaliseEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof; batchedBlobInputs: BatchedBlob }>;
31
37
 
32
38
  /** Cancels all proving jobs. */
33
39
  cancel(): void;
@@ -16,7 +16,7 @@ export interface Service {
16
16
  }
17
17
 
18
18
  /** Tries to call stop on a given object and awaits it. Logs any errors and does not rethrow. */
19
- export async function tryStop(service?: Partial<Pick<Service, 'stop'>>, logger?: Logger): Promise<void> {
19
+ export async function tryStop(service?: any, logger?: Logger): Promise<void> {
20
20
  try {
21
21
  return typeof service === 'object' && service && 'stop' in service && typeof service.stop === 'function'
22
22
  ? await service.stop()
@@ -1,5 +1,4 @@
1
1
  export * from './private_to_rollup_accumulated_data.js';
2
- export * from './combined_constant_data.js';
3
2
  export * from './private_to_rollup_kernel_circuit_public_inputs.js';
4
3
  export * from './private_accumulated_data.js';
5
4
  export * from './private_call_data.js';
@@ -4,7 +4,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
4
  import { hexToBuffer } from '@aztec/foundation/string';
5
5
  import type { FieldsOf } from '@aztec/foundation/types';
6
6
 
7
- import { encodeAbiParameters, parseAbiParameters, toHex } from 'viem';
7
+ import { encodeAbiParameters, parseAbiParameters } from 'viem';
8
8
  import { z } from 'zod';
9
9
 
10
10
  import type { L2Block } from '../block/l2_block.js';
@@ -41,9 +41,19 @@ export class ConsensusPayload implements Signable {
41
41
  }
42
42
 
43
43
  getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
44
- const abi = parseAbiParameters('uint8, (bytes32, bytes, (uint256), bytes32, bytes32[])');
44
+ const abi = parseAbiParameters(
45
+ 'uint8, ' + //domainSeperator
46
+ '(' +
47
+ 'bytes32, ' + // archive
48
+ '((bytes32,uint32),((bytes32,uint32),(bytes32,uint32),(bytes32,uint32))), ' + // stateReference
49
+ '(int256), ' + // oracleInput
50
+ 'bytes32, ' + // headerHash
51
+ 'bytes32[]' + // txHashes
52
+ ')',
53
+ );
45
54
  const archiveRoot = this.archive.toString();
46
- const stateReference = toHex(this.stateReference.toBuffer());
55
+ const stateReference = this.stateReference.toAbi();
56
+
47
57
  const headerHash = this.header.hash().toString();
48
58
  const txArray = this.txHashes.map(tx => tx.toString());
49
59
  const encodedData = encodeAbiParameters(abi, [
@@ -6,7 +6,7 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
6
6
 
7
7
  import { PartialStateReference } from '../tx/partial_state_reference.js';
8
8
  import { RollupTypes } from '../types/shared.js';
9
- import { ConstantRollupData } from './constant_rollup_data.js';
9
+ import { BlockConstantData } from './block_constant_data.js';
10
10
 
11
11
  /**
12
12
  * Output of the base and merge rollup circuits.
@@ -24,7 +24,7 @@ export class BaseOrMergeRollupPublicInputs {
24
24
  /**
25
25
  * Data which is forwarded through the rollup circuits unchanged.
26
26
  */
27
- public constants: ConstantRollupData,
27
+ public constants: BlockConstantData,
28
28
  /**
29
29
  * Partial state reference at the start of the rollup circuit.
30
30
  */
@@ -61,7 +61,7 @@ export class BaseOrMergeRollupPublicInputs {
61
61
  return new BaseOrMergeRollupPublicInputs(
62
62
  RollupTypes.Base,
63
63
  0,
64
- ConstantRollupData.empty(),
64
+ BlockConstantData.empty(),
65
65
  PartialStateReference.empty(),
66
66
  PartialStateReference.empty(),
67
67
  SpongeBlob.empty(),
@@ -83,7 +83,7 @@ export class BaseOrMergeRollupPublicInputs {
83
83
  return new BaseOrMergeRollupPublicInputs(
84
84
  reader.readNumber(),
85
85
  reader.readNumber(),
86
- reader.readObject(ConstantRollupData),
86
+ reader.readObject(BlockConstantData),
87
87
  reader.readObject(PartialStateReference),
88
88
  reader.readObject(PartialStateReference),
89
89
  reader.readObject(SpongeBlob),
@@ -8,8 +8,9 @@ import type { FieldsOf } from '@aztec/foundation/types';
8
8
 
9
9
  import { PublicDataHint } from '../avm/public_data_hint.js';
10
10
  import { ContractClassLogFields } from '../logs/index.js';
11
+ import { AppendOnlyTreeSnapshot } from '../trees/index.js';
11
12
  import { PartialStateReference } from '../tx/partial_state_reference.js';
12
- import { ConstantRollupData } from './constant_rollup_data.js';
13
+ import { BlockConstantData } from './block_constant_data.js';
13
14
  import { PrivateBaseStateDiffHints } from './state_diff_hints.js';
14
15
 
15
16
  export type BaseRollupHints = PrivateBaseRollupHints | PublicBaseRollupHints;
@@ -43,7 +44,7 @@ export class PrivateBaseRollupHints {
43
44
  /**
44
45
  * Data which is not modified by the base rollup circuit.
45
46
  */
46
- public constants: ConstantRollupData,
47
+ public constants: BlockConstantData,
47
48
  ) {}
48
49
 
49
50
  static from(fields: FieldsOf<PrivateBaseRollupHints>): PrivateBaseRollupHints {
@@ -87,7 +88,7 @@ export class PrivateBaseRollupHints {
87
88
  reader.readObject(PublicDataHint),
88
89
  MembershipWitness.fromBuffer(reader, ARCHIVE_HEIGHT),
89
90
  makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
90
- reader.readObject(ConstantRollupData),
91
+ reader.readObject(BlockConstantData),
91
92
  );
92
93
  }
93
94
 
@@ -103,7 +104,7 @@ export class PrivateBaseRollupHints {
103
104
  PublicDataHint.empty(),
104
105
  MembershipWitness.empty(ARCHIVE_HEIGHT),
105
106
  makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLogFields.empty),
106
- ConstantRollupData.empty(),
107
+ BlockConstantData.empty(),
107
108
  );
108
109
  }
109
110
  }
@@ -114,6 +115,10 @@ export class PublicBaseRollupHints {
114
115
  * Sponge state to absorb blob inputs at the start of the rollup.
115
116
  */
116
117
  public startSpongeBlob: SpongeBlob,
118
+ /**
119
+ * Archive tree snapshot at the very beginning of the block containing this base rollup.
120
+ */
121
+ public lastArchive: AppendOnlyTreeSnapshot,
117
122
  /**
118
123
  * Membership witnesses of blocks referred by each of the 2 kernels.
119
124
  */
@@ -122,10 +127,6 @@ export class PublicBaseRollupHints {
122
127
  * Preimages to the kernel's contractClassLogsHashes.
123
128
  */
124
129
  public contractClassLogsFields: Tuple<ContractClassLogFields, typeof MAX_CONTRACT_CLASS_LOGS_PER_TX>,
125
- /**
126
- * Data which is not modified by the base rollup circuit.
127
- */
128
- public constants: ConstantRollupData,
129
130
  ) {}
130
131
 
131
132
  static from(fields: FieldsOf<PublicBaseRollupHints>): PublicBaseRollupHints {
@@ -135,9 +136,9 @@ export class PublicBaseRollupHints {
135
136
  static getFields(fields: FieldsOf<PublicBaseRollupHints>) {
136
137
  return [
137
138
  fields.startSpongeBlob,
139
+ fields.lastArchive,
138
140
  fields.archiveRootMembershipWitness,
139
141
  fields.contractClassLogsFields,
140
- fields.constants,
141
142
  ] as const;
142
143
  }
143
144
 
@@ -161,9 +162,9 @@ export class PublicBaseRollupHints {
161
162
  const reader = BufferReader.asReader(buffer);
162
163
  return new PublicBaseRollupHints(
163
164
  reader.readObject(SpongeBlob),
165
+ reader.readObject(AppendOnlyTreeSnapshot),
164
166
  MembershipWitness.fromBuffer(reader, ARCHIVE_HEIGHT),
165
167
  makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
166
- reader.readObject(ConstantRollupData),
167
168
  );
168
169
  }
169
170
 
@@ -174,9 +175,9 @@ export class PublicBaseRollupHints {
174
175
  static empty() {
175
176
  return new PublicBaseRollupHints(
176
177
  SpongeBlob.empty(),
178
+ AppendOnlyTreeSnapshot.empty(),
177
179
  MembershipWitness.empty(ARCHIVE_HEIGHT),
178
180
  makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLogFields.empty),
179
- ConstantRollupData.empty(),
180
181
  );
181
182
  }
182
183
  }
@@ -0,0 +1,63 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
+ import type { FieldsOf } from '@aztec/foundation/types';
4
+
5
+ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
6
+ import { GlobalVariables } from '../tx/global_variables.js';
7
+
8
+ /**
9
+ * Constants that are the same for the entire block.
10
+ */
11
+ export class BlockConstantData {
12
+ constructor(
13
+ /** Archive tree snapshot at the very beginning of the entire rollup. */
14
+ public lastArchive: AppendOnlyTreeSnapshot,
15
+ /** L1 to L2 message tree snapshot at the very beginning of the entire rollup. */
16
+ public lastL1ToL2: AppendOnlyTreeSnapshot,
17
+ /** Root of the verification key tree. */
18
+ public vkTreeRoot: Fr,
19
+ /** Root of the protocol contract tree. */
20
+ public protocolContractTreeRoot: Fr,
21
+ /** Global variables for the block. */
22
+ public globalVariables: GlobalVariables,
23
+ ) {}
24
+
25
+ static from(fields: FieldsOf<BlockConstantData>): BlockConstantData {
26
+ return new BlockConstantData(...BlockConstantData.getFields(fields));
27
+ }
28
+
29
+ static fromBuffer(buffer: Buffer | BufferReader): BlockConstantData {
30
+ const reader = BufferReader.asReader(buffer);
31
+ return new BlockConstantData(
32
+ reader.readObject(AppendOnlyTreeSnapshot),
33
+ reader.readObject(AppendOnlyTreeSnapshot),
34
+ Fr.fromBuffer(reader),
35
+ Fr.fromBuffer(reader),
36
+ reader.readObject(GlobalVariables),
37
+ );
38
+ }
39
+
40
+ static getFields(fields: FieldsOf<BlockConstantData>) {
41
+ return [
42
+ fields.lastArchive,
43
+ fields.lastL1ToL2,
44
+ fields.vkTreeRoot,
45
+ fields.protocolContractTreeRoot,
46
+ fields.globalVariables,
47
+ ] as const;
48
+ }
49
+
50
+ static empty() {
51
+ return new BlockConstantData(
52
+ AppendOnlyTreeSnapshot.empty(),
53
+ AppendOnlyTreeSnapshot.empty(),
54
+ Fr.ZERO,
55
+ Fr.ZERO,
56
+ GlobalVariables.empty(),
57
+ );
58
+ }
59
+
60
+ toBuffer() {
61
+ return serializeToBuffer(...BlockConstantData.getFields(this));
62
+ }
63
+ }
@@ -9,12 +9,17 @@ import type { FieldsOf } from '@aztec/foundation/types';
9
9
 
10
10
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
11
11
  import { GlobalVariables } from '../tx/global_variables.js';
12
+ import { EpochConstantData } from './epoch_constant_data.js';
12
13
 
13
14
  /**
14
15
  * Output of the block root and block merge rollup circuits.
15
16
  */
16
17
  export class BlockRootOrBlockMergePublicInputs {
17
18
  constructor(
19
+ /**
20
+ * Constants for the entire epoch.
21
+ */
22
+ public constants: EpochConstantData,
18
23
  /**
19
24
  * Archive tree immediately before this block range.
20
25
  */
@@ -45,21 +50,9 @@ export class BlockRootOrBlockMergePublicInputs {
45
50
  */
46
51
  public fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>,
47
52
  /**
48
- * Root of the verification key tree.
49
- */
50
- public vkTreeRoot: Fr,
51
- /**
52
- * Root of the protocol contract tree.
53
- */
54
- public protocolContractTreeRoot: Fr,
55
- /**
56
- * TODO(#7346): Temporarily added prover_id while we verify block-root proofs on L1
53
+ * Public inputs required to verify a batch of blobs.
57
54
  */
58
- public proverId: Fr,
59
- /**
60
- * Public inputs required to verify a blob (challenge point z, evaluation y = p(z), and the commitment to p() for each blob)
61
- */
62
- public blobPublicInputs: Tuple<BlockBlobPublicInputs, typeof AZTEC_MAX_EPOCH_DURATION>,
55
+ public blobPublicInputs: BlockBlobPublicInputs,
63
56
  ) {}
64
57
 
65
58
  /**
@@ -70,6 +63,7 @@ export class BlockRootOrBlockMergePublicInputs {
70
63
  static fromBuffer(buffer: Buffer | BufferReader): BlockRootOrBlockMergePublicInputs {
71
64
  const reader = BufferReader.asReader(buffer);
72
65
  return new BlockRootOrBlockMergePublicInputs(
66
+ reader.readObject(EpochConstantData),
73
67
  reader.readObject(AppendOnlyTreeSnapshot),
74
68
  reader.readObject(AppendOnlyTreeSnapshot),
75
69
  reader.readObject(GlobalVariables),
@@ -77,10 +71,7 @@ export class BlockRootOrBlockMergePublicInputs {
77
71
  Fr.fromBuffer(reader),
78
72
  reader.readArray(AZTEC_MAX_EPOCH_DURATION, Fr),
79
73
  reader.readArray(AZTEC_MAX_EPOCH_DURATION, FeeRecipient),
80
- Fr.fromBuffer(reader),
81
- Fr.fromBuffer(reader),
82
- Fr.fromBuffer(reader),
83
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, BlockBlobPublicInputs),
74
+ reader.readObject(BlockBlobPublicInputs),
84
75
  );
85
76
  }
86
77
 
@@ -90,6 +81,7 @@ export class BlockRootOrBlockMergePublicInputs {
90
81
  */
91
82
  toBuffer() {
92
83
  return serializeToBuffer(
84
+ this.constants,
93
85
  this.previousArchive,
94
86
  this.newArchive,
95
87
  this.startGlobalVariables,
@@ -97,9 +89,6 @@ export class BlockRootOrBlockMergePublicInputs {
97
89
  this.outHash,
98
90
  this.proposedBlockHeaderHashes,
99
91
  this.fees,
100
- this.vkTreeRoot,
101
- this.protocolContractTreeRoot,
102
- this.proverId,
103
92
  this.blobPublicInputs,
104
93
  );
105
94
  }
@@ -1,3 +1,4 @@
1
+ import { BlobAccumulatorPublicInputs, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
1
2
  import {
2
3
  ARCHIVE_HEIGHT,
3
4
  BLOBS_PER_BLOCK,
@@ -5,7 +6,7 @@ import {
5
6
  L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
6
7
  NESTED_RECURSIVE_PROOF_LENGTH,
7
8
  } from '@aztec/constants';
8
- import { Fr } from '@aztec/foundation/fields';
9
+ import { BLS12Point, Fr } from '@aztec/foundation/fields';
9
10
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
10
11
  import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
11
12
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
@@ -38,7 +39,15 @@ export class BlockRootRollupData {
38
39
  */
39
40
  public previousBlockHeader: BlockHeader,
40
41
  /**
41
- * TODO(#7346): Temporarily added prover_id while we verify block-root proofs on L1
42
+ * The current blob accumulation state across the epoch.
43
+ */
44
+ public startBlobAccumulator: BlobAccumulatorPublicInputs,
45
+ /**
46
+ * Finalized challenges z and gamma for performing blob batching. Shared value across the epoch.
47
+ */
48
+ public finalBlobChallenges: FinalBlobBatchingChallenges,
49
+ /**
50
+ * Identifier of the prover.
42
51
  */
43
52
  public proverId: Fr,
44
53
  ) {}
@@ -80,6 +89,8 @@ export class BlockRootRollupData {
80
89
  fields.previousArchiveSiblingPath,
81
90
  fields.newArchiveSiblingPath,
82
91
  fields.previousBlockHeader,
92
+ fields.startBlobAccumulator,
93
+ fields.finalBlobChallenges,
83
94
  fields.proverId,
84
95
  ] as const;
85
96
  }
@@ -97,6 +108,8 @@ export class BlockRootRollupData {
97
108
  reader.readArray(ARCHIVE_HEIGHT, Fr),
98
109
  reader.readArray(ARCHIVE_HEIGHT, Fr),
99
110
  BlockHeader.fromBuffer(reader),
111
+ reader.readObject(BlobAccumulatorPublicInputs),
112
+ reader.readObject(FinalBlobBatchingChallenges),
100
113
  Fr.fromBuffer(reader),
101
114
  );
102
115
  }
@@ -131,9 +144,8 @@ export class BlockRootRollupBlobData {
131
144
  public blobFields: Fr[],
132
145
  /**
133
146
  * KZG commitments representing the blob (precomputed in ts, injected to use inside circuit).
134
- * TODO(Miranda): Rename to kzg_commitment to match BlobPublicInputs?
135
147
  */
136
- public blobCommitments: Tuple<Tuple<Fr, 2>, typeof BLOBS_PER_BLOCK>,
148
+ public blobCommitments: Tuple<BLS12Point, typeof BLOBS_PER_BLOCK>,
137
149
  /**
138
150
  * The hash of eth blob hashes for this block
139
151
  * See yarn-project/foundation/src/blob/index.ts or body.ts for calculation
@@ -186,7 +198,7 @@ export class BlockRootRollupBlobData {
186
198
  // Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
187
199
  // reader.readArray(FIELDS_PER_BLOB, Fr),
188
200
  Array.from({ length: FIELDS_PER_BLOB * BLOBS_PER_BLOCK }, () => Fr.fromBuffer(reader)),
189
- reader.readArray(BLOBS_PER_BLOCK, { fromBuffer: () => reader.readArray(2, Fr) }),
201
+ reader.readArray(BLOBS_PER_BLOCK, BLS12Point),
190
202
  Fr.fromBuffer(reader),
191
203
  );
192
204
  }
@@ -3,8 +3,8 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
3
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
4
4
  import type { FieldsOf } from '@aztec/foundation/types';
5
5
 
6
+ import { BlockConstantData } from './block_constant_data.js';
6
7
  import { BlockRootRollupData } from './block_root_rollup.js';
7
- import { ConstantRollupData } from './constant_rollup_data.js';
8
8
 
9
9
  /**
10
10
  * Represents inputs of the empty block root rollup circuit.
@@ -12,7 +12,7 @@ import { ConstantRollupData } from './constant_rollup_data.js';
12
12
  export class EmptyBlockRootRollupInputs {
13
13
  constructor(
14
14
  public readonly data: BlockRootRollupData,
15
- public readonly constants: ConstantRollupData,
15
+ public readonly constants: BlockConstantData,
16
16
  public readonly isPadding: boolean,
17
17
  ) {}
18
18
 
@@ -59,7 +59,7 @@ export class EmptyBlockRootRollupInputs {
59
59
  const reader = BufferReader.asReader(buffer);
60
60
  return new EmptyBlockRootRollupInputs(
61
61
  reader.readObject(BlockRootRollupData),
62
- reader.readObject(ConstantRollupData),
62
+ reader.readObject(BlockConstantData),
63
63
  reader.readBoolean(),
64
64
  );
65
65
  }
@@ -0,0 +1,44 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
+ import type { FieldsOf } from '@aztec/foundation/types';
4
+
5
+ /**
6
+ * Constants that are the same for the entire epoch.
7
+ */
8
+ export class EpochConstantData {
9
+ constructor(
10
+ /**
11
+ * Root of the verification key tree.
12
+ */
13
+ public vkTreeRoot: Fr,
14
+ /**
15
+ * Root of the protocol contract tree.
16
+ */
17
+ public protocolContractTreeRoot: Fr,
18
+ /**
19
+ * Identifier of the prover of the epoch.
20
+ */
21
+ public proverId: Fr,
22
+ ) {}
23
+
24
+ static from(fields: FieldsOf<EpochConstantData>): EpochConstantData {
25
+ return new EpochConstantData(...EpochConstantData.getFields(fields));
26
+ }
27
+
28
+ static fromBuffer(buffer: Buffer | BufferReader): EpochConstantData {
29
+ const reader = BufferReader.asReader(buffer);
30
+ return new EpochConstantData(Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader));
31
+ }
32
+
33
+ static getFields(fields: FieldsOf<EpochConstantData>) {
34
+ return [fields.vkTreeRoot, fields.protocolContractTreeRoot, fields.proverId] as const;
35
+ }
36
+
37
+ static empty() {
38
+ return new EpochConstantData(Fr.ZERO, Fr.ZERO, Fr.ZERO);
39
+ }
40
+
41
+ toBuffer() {
42
+ return serializeToBuffer(...EpochConstantData.getFields(this));
43
+ }
44
+ }
@@ -1,10 +1,11 @@
1
1
  export * from './avm_proof_data.js';
2
2
  export * from './base_or_merge_rollup_public_inputs.js';
3
3
  export * from './base_rollup_hints.js';
4
+ export * from './block_constant_data.js';
4
5
  export * from './block_merge_rollup.js';
5
6
  export * from './block_root_or_block_merge_public_inputs.js';
6
- export * from './constant_rollup_data.js';
7
7
  export * from './empty_block_root_rollup_inputs.js';
8
+ export * from './epoch_constant_data.js';
8
9
  export * from './block_root_rollup.js';
9
10
  export * from './merge_rollup.js';
10
11
  export * from './previous_rollup_block_data.js';
@@ -1,4 +1,4 @@
1
- import { BlockBlobPublicInputs } from '@aztec/blob-lib';
1
+ import { FinalBlobAccumulatorPublicInputs } from '@aztec/blob-lib';
2
2
  import { AZTEC_MAX_EPOCH_DURATION } from '@aztec/constants';
3
3
  import { makeTuple } from '@aztec/foundation/array';
4
4
  import { Fr } from '@aztec/foundation/fields';
@@ -21,8 +21,6 @@ export class RootRollupInputs {
21
21
  * from 2 block merge circuits.
22
22
  */
23
23
  public previousRollupData: [PreviousRollupBlockData, PreviousRollupBlockData],
24
- /** Identifier of the prover for this root rollup. */
25
- public proverId: Fr,
26
24
  ) {}
27
25
 
28
26
  /**
@@ -56,7 +54,7 @@ export class RootRollupInputs {
56
54
  * @returns An array of fields.
57
55
  */
58
56
  static getFields(fields: FieldsOf<RootRollupInputs>) {
59
- return [fields.previousRollupData, fields.proverId] as const;
57
+ return [fields.previousRollupData] as const;
60
58
  }
61
59
 
62
60
  /**
@@ -66,10 +64,10 @@ export class RootRollupInputs {
66
64
  */
67
65
  static fromBuffer(buffer: Buffer | BufferReader): RootRollupInputs {
68
66
  const reader = BufferReader.asReader(buffer);
69
- return new RootRollupInputs(
70
- [reader.readObject(PreviousRollupBlockData), reader.readObject(PreviousRollupBlockData)],
71
- Fr.fromBuffer(reader),
72
- );
67
+ return new RootRollupInputs([
68
+ reader.readObject(PreviousRollupBlockData),
69
+ reader.readObject(PreviousRollupBlockData),
70
+ ]);
73
71
  }
74
72
 
75
73
  /**
@@ -110,7 +108,7 @@ export class RootRollupPublicInputs {
110
108
  public vkTreeRoot: Fr,
111
109
  public protocolContractTreeRoot: Fr,
112
110
  public proverId: Fr,
113
- public blobPublicInputs: Tuple<BlockBlobPublicInputs, typeof AZTEC_MAX_EPOCH_DURATION>,
111
+ public blobPublicInputs: FinalBlobAccumulatorPublicInputs,
114
112
  ) {}
115
113
 
116
114
  static getFields(fields: FieldsOf<RootRollupPublicInputs>) {
@@ -157,7 +155,7 @@ export class RootRollupPublicInputs {
157
155
  Fr.fromBuffer(reader),
158
156
  Fr.fromBuffer(reader),
159
157
  Fr.fromBuffer(reader),
160
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, BlockBlobPublicInputs),
158
+ reader.readObject(FinalBlobAccumulatorPublicInputs),
161
159
  );
162
160
  }
163
161
 
@@ -179,7 +177,7 @@ export class RootRollupPublicInputs {
179
177
  return bufferSchemaFor(RootRollupPublicInputs);
180
178
  }
181
179
 
182
- /** Creates a random instance. */
180
+ /** Creates a random instance. Used for testing only - will not prove/verify. */
183
181
  static random() {
184
182
  return new RootRollupPublicInputs(
185
183
  Fr.random(),
@@ -191,7 +189,7 @@ export class RootRollupPublicInputs {
191
189
  Fr.random(),
192
190
  Fr.random(),
193
191
  Fr.random(),
194
- makeTuple(AZTEC_MAX_EPOCH_DURATION, BlockBlobPublicInputs.empty),
192
+ FinalBlobAccumulatorPublicInputs.random(),
195
193
  );
196
194
  }
197
195
  }