@aztec/stdlib 1.0.0 → 1.1.2

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 (112) hide show
  1. package/dest/block/l2_block_stream/l2_block_stream.js +1 -1
  2. package/dest/block/proposal/committee_attestation.d.ts +3 -3
  3. package/dest/block/proposal/committee_attestation.d.ts.map +1 -1
  4. package/dest/block/proposal/committee_attestation.js +41 -2
  5. package/dest/contract/contract_instance_update.d.ts +2 -1
  6. package/dest/contract/contract_instance_update.d.ts.map +1 -1
  7. package/dest/contract/contract_instance_update.js +6 -6
  8. package/dest/contract/interfaces/contract_data_source.d.ts +5 -2
  9. package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
  10. package/dest/contract/interfaces/contract_instance_update.d.ts +9 -8
  11. package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
  12. package/dest/contract/interfaces/contract_instance_update.js +1 -1
  13. package/dest/hash/hash.d.ts +1 -1
  14. package/dest/hash/hash.d.ts.map +1 -1
  15. package/dest/hash/hash.js +7 -3
  16. package/dest/interfaces/archiver.js +1 -1
  17. package/dest/interfaces/aztec-node.d.ts +1 -1
  18. package/dest/interfaces/client.d.ts +1 -0
  19. package/dest/interfaces/client.d.ts.map +1 -1
  20. package/dest/interfaces/client.js +1 -0
  21. package/dest/interfaces/proving-job.d.ts +22 -1
  22. package/dest/interfaces/proving-job.d.ts.map +1 -1
  23. package/dest/interfaces/proving-job.js +13 -0
  24. package/dest/interfaces/server.d.ts +1 -0
  25. package/dest/interfaces/server.d.ts.map +1 -1
  26. package/dest/interfaces/server.js +1 -0
  27. package/dest/interfaces/server_circuit_prover.d.ts +2 -0
  28. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  29. package/dest/kernel/hints/rollup_validation_requests.d.ts +6 -10
  30. package/dest/kernel/hints/rollup_validation_requests.d.ts.map +1 -1
  31. package/dest/kernel/hints/rollup_validation_requests.js +9 -11
  32. package/dest/kernel/private_circuit_public_inputs.d.ts +6 -6
  33. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  34. package/dest/kernel/private_circuit_public_inputs.js +10 -10
  35. package/dest/proofs/proving_request_type.d.ts +8 -7
  36. package/dest/proofs/proving_request_type.d.ts.map +1 -1
  37. package/dest/proofs/proving_request_type.js +8 -7
  38. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +0 -9
  39. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
  40. package/dest/rollup/base_or_merge_rollup_public_inputs.js +3 -8
  41. package/dest/rollup/empty_block_root_rollup_inputs.d.ts +2 -3
  42. package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +1 -1
  43. package/dest/rollup/empty_block_root_rollup_inputs.js +3 -6
  44. package/dest/rollup/index.d.ts +1 -0
  45. package/dest/rollup/index.d.ts.map +1 -1
  46. package/dest/rollup/index.js +1 -0
  47. package/dest/rollup/padding_block_root_rollup_inputs.d.ts +20 -0
  48. package/dest/rollup/padding_block_root_rollup_inputs.d.ts.map +1 -0
  49. package/dest/rollup/padding_block_root_rollup_inputs.js +39 -0
  50. package/dest/shared_mutable/scheduled_delay_change.d.ts +5 -5
  51. package/dest/shared_mutable/scheduled_delay_change.d.ts.map +1 -1
  52. package/dest/shared_mutable/scheduled_delay_change.js +5 -5
  53. package/dest/shared_mutable/scheduled_value_change.d.ts +4 -3
  54. package/dest/shared_mutable/scheduled_value_change.d.ts.map +1 -1
  55. package/dest/shared_mutable/scheduled_value_change.js +7 -7
  56. package/dest/shared_mutable/shared_mutable_values.js +7 -7
  57. package/dest/stats/stats.d.ts +1 -1
  58. package/dest/stats/stats.d.ts.map +1 -1
  59. package/dest/tests/factories.d.ts.map +1 -1
  60. package/dest/tests/factories.js +6 -6
  61. package/dest/tx/include_by_timestamp.d.ts +54 -0
  62. package/dest/tx/include_by_timestamp.d.ts.map +1 -0
  63. package/dest/tx/include_by_timestamp.js +72 -0
  64. package/dest/tx/index.d.ts +1 -1
  65. package/dest/tx/index.d.ts.map +1 -1
  66. package/dest/tx/index.js +1 -1
  67. package/dest/tx/offchain_effect.d.ts.map +1 -1
  68. package/dest/tx/offchain_effect.js +1 -0
  69. package/dest/tx/validator/error_texts.d.ts +2 -2
  70. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  71. package/dest/tx/validator/error_texts.js +2 -2
  72. package/dest/types/shared.d.ts +0 -8
  73. package/dest/types/shared.d.ts.map +1 -1
  74. package/dest/types/shared.js +0 -8
  75. package/dest/vks/verification_key.d.ts +1 -0
  76. package/dest/vks/verification_key.d.ts.map +1 -1
  77. package/dest/vks/verification_key.js +5 -0
  78. package/package.json +7 -7
  79. package/src/block/l2_block_stream/l2_block_stream.ts +1 -1
  80. package/src/block/proposal/committee_attestation.ts +49 -3
  81. package/src/contract/contract_instance_update.ts +7 -6
  82. package/src/contract/interfaces/contract_data_source.ts +5 -2
  83. package/src/contract/interfaces/contract_instance_update.ts +4 -3
  84. package/src/hash/hash.ts +7 -3
  85. package/src/interfaces/archiver.ts +1 -1
  86. package/src/interfaces/aztec-node.ts +1 -1
  87. package/src/interfaces/client.ts +1 -0
  88. package/src/interfaces/proving-job.ts +21 -0
  89. package/src/interfaces/server.ts +1 -0
  90. package/src/interfaces/server_circuit_prover.ts +9 -0
  91. package/src/kernel/hints/rollup_validation_requests.ts +8 -10
  92. package/src/kernel/private_circuit_public_inputs.ts +8 -8
  93. package/src/proofs/proving_request_type.ts +1 -0
  94. package/src/rollup/base_or_merge_rollup_public_inputs.ts +0 -8
  95. package/src/rollup/empty_block_root_rollup_inputs.ts +2 -7
  96. package/src/rollup/index.ts +1 -0
  97. package/src/rollup/padding_block_root_rollup_inputs.ts +47 -0
  98. package/src/shared_mutable/scheduled_delay_change.ts +6 -6
  99. package/src/shared_mutable/scheduled_value_change.ts +7 -5
  100. package/src/shared_mutable/shared_mutable_values.ts +9 -9
  101. package/src/stats/stats.ts +1 -0
  102. package/src/tests/factories.ts +4 -6
  103. package/src/tx/include_by_timestamp.ts +90 -0
  104. package/src/tx/index.ts +1 -1
  105. package/src/tx/offchain_effect.ts +1 -0
  106. package/src/tx/validator/error_texts.ts +2 -2
  107. package/src/types/shared.ts +0 -9
  108. package/src/vks/verification_key.ts +6 -0
  109. package/dest/tx/max_block_number.d.ts +0 -54
  110. package/dest/tx/max_block_number.d.ts.map +0 -1
  111. package/dest/tx/max_block_number.js +0 -64
  112. package/src/tx/max_block_number.ts +0 -81
@@ -2,6 +2,7 @@ import type { Fr } from '@aztec/foundation/fields';
2
2
 
3
3
  import type { FunctionSelector } from '../../abi/index.js';
4
4
  import type { AztecAddress } from '../../aztec-address/index.js';
5
+ import type { UInt64 } from '../../types/shared.js';
5
6
  import type { ContractClassPublic } from './contract_class.js';
6
7
  import type { ContractInstanceWithAddress } from './contract_instance.js';
7
8
 
@@ -23,9 +24,11 @@ export interface ContractDataSource {
23
24
  /**
24
25
  * Returns a publicly deployed contract instance given its address.
25
26
  * @param address - Address of the deployed contract.
26
- * @param blockNumber - Block number at which to retrieve the contract instance. If not provided, the latest block should be used.
27
+ * @param timestamp - Timestamp at which to retrieve the contract instance. If not provided, the latest block should
28
+ * be used.
29
+ * TODO(#15170): Fix the implementations ignoring the timestamp param and make timestamp required.
27
30
  */
28
- getContract(address: AztecAddress, blockNumber?: number): Promise<ContractInstanceWithAddress | undefined>;
31
+ getContract(address: AztecAddress, timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined>;
29
32
 
30
33
  /**
31
34
  * Returns the list of all class ids known.
@@ -4,6 +4,7 @@ import { z } from 'zod';
4
4
 
5
5
  import type { AztecAddress } from '../../aztec-address/index.js';
6
6
  import { type ZodFor, schemas } from '../../schemas/index.js';
7
+ import type { UInt64 } from '../../types/shared.js';
7
8
 
8
9
  /**
9
10
  * An update to a contract instance, changing its contract class.
@@ -13,8 +14,8 @@ export interface ContractInstanceUpdate {
13
14
  prevContractClassId: Fr;
14
15
  /** Identifier of the new contract class for this instance. */
15
16
  newContractClassId: Fr;
16
- /** The block number where the contract class in use will be the new one */
17
- blockOfChange: number;
17
+ /** The timestamp at which the contract class in use will be the new one */
18
+ timestampOfChange: UInt64;
18
19
  }
19
20
 
20
21
  export type ContractInstanceUpdateWithAddress = ContractInstanceUpdate & { address: AztecAddress };
@@ -22,7 +23,7 @@ export type ContractInstanceUpdateWithAddress = ContractInstanceUpdate & { addre
22
23
  export const ContractInstanceUpdateSchema = z.object({
23
24
  prevContractClassId: schemas.Fr,
24
25
  newContractClassId: schemas.Fr,
25
- blockOfChange: z.number().int().nonnegative(),
26
+ timestampOfChange: schemas.BigInt,
26
27
  }) satisfies ZodFor<ContractInstanceUpdate>;
27
28
 
28
29
  export const ContractInstanceUpdateWithAddressSchema = ContractInstanceUpdateSchema.and(
package/src/hash/hash.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GeneratorIndex } from '@aztec/constants';
2
+ import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
3
  import { poseidon2Hash, poseidon2HashWithSeparator, sha256ToField } from '@aztec/foundation/crypto';
3
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
5
  import { Fr } from '@aztec/foundation/fields';
@@ -7,11 +8,14 @@ import type { AztecAddress } from '../aztec-address/index.js';
7
8
 
8
9
  /**
9
10
  * Computes a hash of a given verification key.
10
- * @param vkBuf - The verification key as fields.
11
+ * @param keyAsFields - The verification key as fields.
11
12
  * @returns The hash of the verification key.
12
13
  */
13
- export function hashVK(keyAsFields: Fr[]): Promise<Fr> {
14
- return poseidon2Hash(keyAsFields);
14
+ export async function hashVK(keyAsFields: Fr[]): Promise<Fr> {
15
+ // Should match the implementation in barretenberg/cpp/src/barretenberg/flavor/flavor.hpp > hash()
16
+ const hash = (await poseidon2Hash(keyAsFields)).toBuffer();
17
+ // Taking the last 16 bytes (128 bits) of the hash.
18
+ return new Fr(toBigIntBE(hash.subarray(Fr.SIZE_IN_BYTES - 16)));
15
19
  }
16
20
 
17
21
  /**
@@ -65,7 +65,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
65
65
  getBytecodeCommitment: z.function().args(schemas.Fr).returns(schemas.Fr),
66
66
  getContract: z
67
67
  .function()
68
- .args(schemas.AztecAddress, optional(schemas.Integer))
68
+ .args(schemas.AztecAddress, optional(schemas.BigInt))
69
69
  .returns(ContractInstanceWithAddressSchema.optional()),
70
70
  getContractClassIds: z.function().args().returns(z.array(schemas.Fr)),
71
71
  registerContractFunctionSignatures: z.function().args(z.array(z.string())).returns(z.void()),
@@ -407,7 +407,7 @@ export interface AztecNode
407
407
  /**
408
408
  * Returns true if the transaction is valid for inclusion at the current state. Valid transactions can be
409
409
  * made invalid by *other* transactions if e.g. they emit the same nullifiers, or come become invalid
410
- * due to e.g. the max_block_number property.
410
+ * due to e.g. the include_by_timestamp property.
411
411
  * @param tx - The transaction to validate for correctness.
412
412
  * @param isSimulation - True if the transaction is a simulated one without generated proofs. (Optional)
413
413
  * @param skipFeeEnforcement - True if the validation of the fee should be skipped. Useful when the simulation is for estimating fee (Optional)
@@ -3,3 +3,4 @@ export * from './aztec-node.js';
3
3
  export * from './aztec-node-admin.js';
4
4
  export * from './private_kernel_prover.js';
5
5
  export * from './get_logs_response.js';
6
+ export * from './api_limit.js';
@@ -21,6 +21,7 @@ import { BlockMergeRollupInputs } from '../rollup/block_merge_rollup.js';
21
21
  import { BlockRootOrBlockMergePublicInputs } from '../rollup/block_root_or_block_merge_public_inputs.js';
22
22
  import { BlockRootRollupInputs, SingleTxBlockRootRollupInputs } from '../rollup/block_root_rollup.js';
23
23
  import { EmptyBlockRootRollupInputs } from '../rollup/empty_block_root_rollup_inputs.js';
24
+ import { PaddingBlockRootRollupInputs } from '../rollup/index.js';
24
25
  import { MergeRollupInputs } from '../rollup/merge_rollup.js';
25
26
  import { PrivateBaseRollupInputs } from '../rollup/private_base_rollup_inputs.js';
26
27
  import { PublicBaseRollupInputs } from '../rollup/public_base_rollup_inputs.js';
@@ -87,6 +88,8 @@ export function mapProvingRequestTypeToCircuitName(type: ProvingRequestType): Se
87
88
  return 'merge-rollup';
88
89
  case ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP:
89
90
  return 'empty-block-root-rollup';
91
+ case ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP:
92
+ return 'padding-block-root-rollup';
90
93
  case ProvingRequestType.BLOCK_ROOT_ROLLUP:
91
94
  return 'block-root-rollup';
92
95
  case ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP:
@@ -121,6 +124,10 @@ export const ProvingJobInputs = z.discriminatedUnion('type', [
121
124
  inputs: SingleTxBlockRootRollupInputs.schema,
122
125
  }),
123
126
  z.object({ type: z.literal(ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP), inputs: EmptyBlockRootRollupInputs.schema }),
127
+ z.object({
128
+ type: z.literal(ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP),
129
+ inputs: PaddingBlockRootRollupInputs.schema,
130
+ }),
124
131
  z.object({ type: z.literal(ProvingRequestType.BLOCK_MERGE_ROLLUP), inputs: BlockMergeRollupInputs.schema }),
125
132
  z.object({ type: z.literal(ProvingRequestType.ROOT_ROLLUP), inputs: RootRollupInputs.schema }),
126
133
  z.object({ type: z.literal(ProvingRequestType.TUBE_PROOF), inputs: TubeInputs.schema }),
@@ -138,6 +145,8 @@ export function getProvingJobInputClassFor(type: ProvingRequestType) {
138
145
  return MergeRollupInputs;
139
146
  case ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP:
140
147
  return EmptyBlockRootRollupInputs;
148
+ case ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP:
149
+ return PaddingBlockRootRollupInputs;
141
150
  case ProvingRequestType.BLOCK_ROOT_ROLLUP:
142
151
  return BlockRootRollupInputs;
143
152
  case ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP:
@@ -167,6 +176,7 @@ export type ProvingJobInputsMap = {
167
176
  [ProvingRequestType.PUBLIC_BASE_ROLLUP]: PublicBaseRollupInputs;
168
177
  [ProvingRequestType.MERGE_ROLLUP]: MergeRollupInputs;
169
178
  [ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP]: EmptyBlockRootRollupInputs;
179
+ [ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP]: PaddingBlockRootRollupInputs;
170
180
  [ProvingRequestType.BLOCK_ROOT_ROLLUP]: BlockRootRollupInputs;
171
181
  [ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP]: SingleTxBlockRootRollupInputs;
172
182
  [ProvingRequestType.BLOCK_MERGE_ROLLUP]: BlockMergeRollupInputs;
@@ -209,6 +219,13 @@ export const ProvingJobResult = z.discriminatedUnion('type', [
209
219
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
210
220
  ),
211
221
  }),
222
+ z.object({
223
+ type: z.literal(ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP),
224
+ result: schemaForPublicInputsAndRecursiveProof(
225
+ BlockRootOrBlockMergePublicInputs.schema,
226
+ NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
227
+ ),
228
+ }),
212
229
  z.object({
213
230
  type: z.literal(ProvingRequestType.BLOCK_ROOT_ROLLUP),
214
231
  result: schemaForPublicInputsAndRecursiveProof(
@@ -266,6 +283,10 @@ export type ProvingJobResultsMap = {
266
283
  BlockRootOrBlockMergePublicInputs,
267
284
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
268
285
  >;
286
+ [ProvingRequestType.PADDING_BLOCK_ROOT_ROLLUP]: PublicInputsAndRecursiveProof<
287
+ BlockRootOrBlockMergePublicInputs,
288
+ typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
289
+ >;
269
290
  [ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP]: PublicInputsAndRecursiveProof<
270
291
  BlockRootOrBlockMergePublicInputs,
271
292
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
@@ -19,3 +19,4 @@ export * from './server_circuit_prover.js';
19
19
  export * from './service.js';
20
20
  export * from './tx-collector.js';
21
21
  export * from './world_state.js';
22
+ export * from './api_limit.js';
@@ -15,6 +15,7 @@ import type { BlockMergeRollupInputs } from '../rollup/block_merge_rollup.js';
15
15
  import type { BlockRootOrBlockMergePublicInputs } from '../rollup/block_root_or_block_merge_public_inputs.js';
16
16
  import type { BlockRootRollupInputs, SingleTxBlockRootRollupInputs } from '../rollup/block_root_rollup.js';
17
17
  import type { EmptyBlockRootRollupInputs } from '../rollup/empty_block_root_rollup_inputs.js';
18
+ import type { PaddingBlockRootRollupInputs } from '../rollup/index.js';
18
19
  import type { MergeRollupInputs } from '../rollup/merge_rollup.js';
19
20
  import type { PrivateBaseRollupInputs } from '../rollup/private_base_rollup_inputs.js';
20
21
  import type { PublicBaseRollupInputs } from '../rollup/public_base_rollup_inputs.js';
@@ -121,6 +122,14 @@ export interface ServerCircuitProver {
121
122
  PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
122
123
  >;
123
124
 
125
+ getPaddingBlockRootRollupProof(
126
+ input: PaddingBlockRootRollupInputs,
127
+ signal?: AbortSignal,
128
+ epochNumber?: number,
129
+ ): Promise<
130
+ PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
131
+ >;
132
+
124
133
  /**
125
134
  * Creates a proof for the given input.
126
135
  * @param input - Input to the circuit.
@@ -4,17 +4,15 @@ import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from
4
4
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
5
5
  import type { FieldsOf } from '@aztec/foundation/types';
6
6
 
7
- import { MaxBlockNumber } from '../../tx/max_block_number.js';
7
+ import { IncludeByTimestamp } from '../../tx/include_by_timestamp.js';
8
8
 
9
9
  /**
10
10
  * Validation requests directed at the rollup, accumulated during the execution of the transaction.
11
11
  */
12
12
  export class RollupValidationRequests {
13
13
  constructor(
14
- /**
15
- * The largest block number in which this transaction can be included.
16
- */
17
- public maxBlockNumber: MaxBlockNumber,
14
+ /** The highest timestamp of a block in which this transaction can still be included. */
15
+ public includeByTimestamp: IncludeByTimestamp,
18
16
  ) {}
19
17
 
20
18
  getSize() {
@@ -22,7 +20,7 @@ export class RollupValidationRequests {
22
20
  }
23
21
 
24
22
  toBuffer() {
25
- return serializeToBuffer(this.maxBlockNumber);
23
+ return serializeToBuffer(this.includeByTimestamp);
26
24
  }
27
25
 
28
26
  toString() {
@@ -30,12 +28,12 @@ export class RollupValidationRequests {
30
28
  }
31
29
 
32
30
  static getFields(fields: FieldsOf<RollupValidationRequests>) {
33
- return [fields.maxBlockNumber] as const;
31
+ return [fields.includeByTimestamp] as const;
34
32
  }
35
33
 
36
34
  static fromFields(fields: Fr[] | FieldReader) {
37
35
  const reader = FieldReader.asReader(fields);
38
- return new RollupValidationRequests(MaxBlockNumber.fromFields(reader));
36
+ return new RollupValidationRequests(IncludeByTimestamp.fromFields(reader));
39
37
  }
40
38
 
41
39
  toFields(): Fr[] {
@@ -55,7 +53,7 @@ export class RollupValidationRequests {
55
53
  */
56
54
  static fromBuffer(buffer: Buffer | BufferReader) {
57
55
  const reader = BufferReader.asReader(buffer);
58
- return new RollupValidationRequests(reader.readObject(MaxBlockNumber));
56
+ return new RollupValidationRequests(reader.readObject(IncludeByTimestamp));
59
57
  }
60
58
 
61
59
  /**
@@ -68,6 +66,6 @@ export class RollupValidationRequests {
68
66
  }
69
67
 
70
68
  static empty() {
71
- return new RollupValidationRequests(MaxBlockNumber.empty());
69
+ return new RollupValidationRequests(IncludeByTimestamp.empty());
72
70
  }
73
71
  }
@@ -30,7 +30,7 @@ import { PrivateLogData } from '../kernel/private_log_data.js';
30
30
  import { CountedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
31
31
  import { BlockHeader } from '../tx/block_header.js';
32
32
  import { CallContext } from '../tx/call_context.js';
33
- import { MaxBlockNumber } from '../tx/max_block_number.js';
33
+ import { IncludeByTimestamp } from '../tx/include_by_timestamp.js';
34
34
  import { TxContext } from '../tx/tx_context.js';
35
35
  import { ReadRequest } from './hints/read_request.js';
36
36
  import { NoteHash } from './note_hash.js';
@@ -64,9 +64,9 @@ export class PrivateCircuitPublicInputs {
64
64
  */
65
65
  public isFeePayer: boolean,
66
66
  /**
67
- * The maximum block number in which this transaction can be included and be valid.
67
+ * The highest timestamp of a block in which the transaction can still be included.
68
68
  */
69
- public maxBlockNumber: MaxBlockNumber,
69
+ public includeByTimestamp: IncludeByTimestamp,
70
70
  /**
71
71
  * Read requests created by the corresponding function call.
72
72
  */
@@ -158,7 +158,7 @@ export class PrivateCircuitPublicInputs {
158
158
  reader.readObject(Fr),
159
159
  reader.readObject(Fr),
160
160
  reader.readBoolean(),
161
- reader.readObject(MaxBlockNumber),
161
+ reader.readObject(IncludeByTimestamp),
162
162
  reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest),
163
163
  reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest),
164
164
  reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_CALL, KeyValidationRequestAndGenerator),
@@ -185,7 +185,7 @@ export class PrivateCircuitPublicInputs {
185
185
  reader.readField(),
186
186
  reader.readField(),
187
187
  reader.readBoolean(),
188
- reader.readObject(MaxBlockNumber),
188
+ reader.readObject(IncludeByTimestamp),
189
189
  reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest),
190
190
  reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest),
191
191
  reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_CALL, KeyValidationRequestAndGenerator),
@@ -215,7 +215,7 @@ export class PrivateCircuitPublicInputs {
215
215
  Fr.ZERO,
216
216
  Fr.ZERO,
217
217
  false,
218
- MaxBlockNumber.empty(),
218
+ IncludeByTimestamp.empty(),
219
219
  makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest.empty),
220
220
  makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest.empty),
221
221
  makeTuple(MAX_KEY_VALIDATION_REQUESTS_PER_CALL, KeyValidationRequestAndGenerator.empty),
@@ -241,7 +241,7 @@ export class PrivateCircuitPublicInputs {
241
241
  this.returnsHash.isZero() &&
242
242
  this.minRevertibleSideEffectCounter.isZero() &&
243
243
  !this.isFeePayer &&
244
- this.maxBlockNumber.isEmpty() &&
244
+ this.includeByTimestamp.isEmpty() &&
245
245
  isEmptyArray(this.noteHashReadRequests) &&
246
246
  isEmptyArray(this.nullifierReadRequests) &&
247
247
  isEmptyArray(this.keyValidationRequestsAndGenerators) &&
@@ -272,7 +272,7 @@ export class PrivateCircuitPublicInputs {
272
272
  fields.returnsHash,
273
273
  fields.minRevertibleSideEffectCounter,
274
274
  fields.isFeePayer,
275
- fields.maxBlockNumber,
275
+ fields.includeByTimestamp,
276
276
  fields.noteHashReadRequests,
277
277
  fields.nullifierReadRequests,
278
278
  fields.keyValidationRequestsAndGenerators,
@@ -5,6 +5,7 @@ export enum ProvingRequestType {
5
5
  PUBLIC_BASE_ROLLUP,
6
6
  MERGE_ROLLUP,
7
7
  EMPTY_BLOCK_ROOT_ROLLUP,
8
+ PADDING_BLOCK_ROOT_ROLLUP,
8
9
  BLOCK_ROOT_ROLLUP,
9
10
  SINGLE_TX_BLOCK_ROOT_ROLLUP,
10
11
  BLOCK_MERGE_ROLLUP,
@@ -5,7 +5,6 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
6
6
 
7
7
  import { PartialStateReference } from '../tx/partial_state_reference.js';
8
- import { RollupTypes } from '../types/shared.js';
9
8
  import { BlockConstantData } from './block_constant_data.js';
10
9
 
11
10
  /**
@@ -13,10 +12,6 @@ import { BlockConstantData } from './block_constant_data.js';
13
12
  */
14
13
  export class BaseOrMergeRollupPublicInputs {
15
14
  constructor(
16
- /**
17
- * Specifies from which type of rollup circuit these inputs are from.
18
- */
19
- public rollupType: RollupTypes,
20
15
  /**
21
16
  * Number of txs in this rollup.
22
17
  */
@@ -59,7 +54,6 @@ export class BaseOrMergeRollupPublicInputs {
59
54
  /** Returns an empty instance. */
60
55
  static empty() {
61
56
  return new BaseOrMergeRollupPublicInputs(
62
- RollupTypes.Base,
63
57
  0,
64
58
  BlockConstantData.empty(),
65
59
  PartialStateReference.empty(),
@@ -81,7 +75,6 @@ export class BaseOrMergeRollupPublicInputs {
81
75
  static fromBuffer(buffer: Buffer | BufferReader): BaseOrMergeRollupPublicInputs {
82
76
  const reader = BufferReader.asReader(buffer);
83
77
  return new BaseOrMergeRollupPublicInputs(
84
- reader.readNumber(),
85
78
  reader.readNumber(),
86
79
  reader.readObject(BlockConstantData),
87
80
  reader.readObject(PartialStateReference),
@@ -100,7 +93,6 @@ export class BaseOrMergeRollupPublicInputs {
100
93
  */
101
94
  toBuffer() {
102
95
  return serializeToBuffer(
103
- this.rollupType,
104
96
  this.numTxs,
105
97
  this.constants,
106
98
 
@@ -13,7 +13,6 @@ export class EmptyBlockRootRollupInputs {
13
13
  constructor(
14
14
  public readonly data: BlockRootRollupData,
15
15
  public readonly constants: BlockConstantData,
16
- public readonly isPadding: boolean,
17
16
  ) {}
18
17
 
19
18
  /**
@@ -47,7 +46,7 @@ export class EmptyBlockRootRollupInputs {
47
46
  * @returns An array of fields.
48
47
  */
49
48
  static getFields(fields: FieldsOf<EmptyBlockRootRollupInputs>) {
50
- return [fields.data, fields.constants, fields.isPadding] as const;
49
+ return [fields.data, fields.constants] as const;
51
50
  }
52
51
 
53
52
  /**
@@ -57,11 +56,7 @@ export class EmptyBlockRootRollupInputs {
57
56
  */
58
57
  static fromBuffer(buffer: Buffer | BufferReader): EmptyBlockRootRollupInputs {
59
58
  const reader = BufferReader.asReader(buffer);
60
- return new EmptyBlockRootRollupInputs(
61
- reader.readObject(BlockRootRollupData),
62
- reader.readObject(BlockConstantData),
63
- reader.readBoolean(),
64
- );
59
+ return new EmptyBlockRootRollupInputs(reader.readObject(BlockRootRollupData), reader.readObject(BlockConstantData));
65
60
  }
66
61
 
67
62
  /**
@@ -8,6 +8,7 @@ export * from './empty_block_root_rollup_inputs.js';
8
8
  export * from './epoch_constant_data.js';
9
9
  export * from './block_root_rollup.js';
10
10
  export * from './merge_rollup.js';
11
+ export * from './padding_block_root_rollup_inputs.js';
11
12
  export * from './previous_rollup_block_data.js';
12
13
  export * from './previous_rollup_data.js';
13
14
  export * from './private_base_rollup_inputs.js';
@@ -0,0 +1,47 @@
1
+ import { bufferSchemaFor } from '@aztec/foundation/schemas';
2
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
+ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
4
+ import type { FieldsOf } from '@aztec/foundation/types';
5
+
6
+ import { EpochConstantData } from './epoch_constant_data.js';
7
+
8
+ /**
9
+ * Inputs of the padding block root rollup circuit.
10
+ */
11
+ export class PaddingBlockRootRollupInputs {
12
+ constructor(public readonly constants: EpochConstantData) {}
13
+
14
+ static from(fields: FieldsOf<PaddingBlockRootRollupInputs>): PaddingBlockRootRollupInputs {
15
+ return new PaddingBlockRootRollupInputs(...PaddingBlockRootRollupInputs.getFields(fields));
16
+ }
17
+
18
+ static getFields(fields: FieldsOf<PaddingBlockRootRollupInputs>) {
19
+ return [fields.constants] as const;
20
+ }
21
+
22
+ static fromBuffer(buffer: Buffer | BufferReader): PaddingBlockRootRollupInputs {
23
+ const reader = BufferReader.asReader(buffer);
24
+ return new PaddingBlockRootRollupInputs(reader.readObject(EpochConstantData));
25
+ }
26
+
27
+ toBuffer() {
28
+ return serializeToBuffer(...PaddingBlockRootRollupInputs.getFields(this));
29
+ }
30
+
31
+ static fromString(str: string) {
32
+ return PaddingBlockRootRollupInputs.fromBuffer(hexToBuffer(str));
33
+ }
34
+
35
+ toString() {
36
+ return bufferToHex(this.toBuffer());
37
+ }
38
+
39
+ /** Returns a buffer representation for JSON serialization. */
40
+ toJSON() {
41
+ return this.toBuffer();
42
+ }
43
+
44
+ static get schema() {
45
+ return bufferSchemaFor(PaddingBlockRootRollupInputs);
46
+ }
47
+ }
@@ -1,17 +1,17 @@
1
- import type { UInt32 } from '../types/shared.js';
1
+ import type { UInt64 } from '../types/shared.js';
2
2
 
3
3
  export class ScheduledDelayChange {
4
4
  constructor(
5
- public pre: UInt32 | undefined,
6
- public post: UInt32 | undefined,
7
- public blockOfChange: UInt32,
5
+ public pre: UInt64 | undefined,
6
+ public post: UInt64 | undefined,
7
+ public timestampOfChange: UInt64,
8
8
  ) {}
9
9
 
10
10
  static empty() {
11
- return new this(undefined, undefined, 0);
11
+ return new this(undefined, undefined, 0n);
12
12
  }
13
13
 
14
14
  isEmpty(): boolean {
15
- return this.pre === undefined && this.post === undefined && this.blockOfChange === 0;
15
+ return this.pre === undefined && this.post === undefined && this.timestampOfChange === 0n;
16
16
  }
17
17
  }
@@ -1,10 +1,12 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
2
 
3
+ import type { UInt64 } from '../types/shared.js';
4
+
3
5
  export class ScheduledValueChange {
4
6
  constructor(
5
7
  public previous: Fr[],
6
8
  public post: Fr[],
7
- public blockOfChange: number,
9
+ public timestampOfChange: UInt64,
8
10
  ) {
9
11
  if (this.previous.length !== this.post.length) {
10
12
  throw new Error('Previous and post must have the same length');
@@ -12,15 +14,15 @@ export class ScheduledValueChange {
12
14
  }
13
15
 
14
16
  static empty(valueSize: number) {
15
- return new this(Array(valueSize).fill(new Fr(0)), Array(valueSize).fill(new Fr(0)), 0);
17
+ return new this(Array(valueSize).fill(new Fr(0)), Array(valueSize).fill(new Fr(0)), 0n);
16
18
  }
17
19
 
18
20
  isEmpty(): boolean {
19
- return this.previous.every(v => v.isZero()) && this.post.every(v => v.isZero()) && this.blockOfChange === 0;
21
+ return this.previous.every(v => v.isZero()) && this.post.every(v => v.isZero()) && this.timestampOfChange === 0n;
20
22
  }
21
23
 
22
- getCurrentAt(blockNumber: number) {
23
- if (blockNumber < this.blockOfChange) {
24
+ getCurrentAt(timestamp: UInt64) {
25
+ if (timestamp < this.timestampOfChange) {
24
26
  return this.previous;
25
27
  } else {
26
28
  return this.post;
@@ -22,20 +22,20 @@ export class SharedMutableValues {
22
22
  // Extract fields for ScheduledValueChange
23
23
  const svcPre = reader.readFieldArray(UPDATES_VALUE_SIZE);
24
24
  const svcPost = reader.readFieldArray(UPDATES_VALUE_SIZE);
25
- const svcBlockOfChange = firstField & 0xffffffffn;
26
- const svc = new ScheduledValueChange(svcPre, svcPost, Number(svcBlockOfChange));
25
+ const svcTimestampOfChange = firstField & 0xffffffffn;
26
+ const svc = new ScheduledValueChange(svcPre, svcPost, svcTimestampOfChange);
27
27
 
28
28
  // Extract fields for ScheduledDelayChange from first field
29
- const sdcBlockOfChange = (firstField >> 32n) & 0xffffffffn;
29
+ const sdcTimestampOfChange = (firstField >> 32n) & 0xffffffffn;
30
30
  const sdcIsPostSome = (firstField >> 64n) & 1n;
31
31
  const sdcPost = (firstField >> 72n) & 0xffffffffn;
32
32
  const sdcIsPreSome = (firstField >> 104n) & 1n;
33
33
  const sdcPre = (firstField >> 112n) & 0xffffffffn;
34
34
 
35
35
  const sdc = new ScheduledDelayChange(
36
- sdcIsPreSome ? Number(sdcPre) : undefined,
37
- sdcIsPostSome ? Number(sdcPost) : undefined,
38
- Number(sdcBlockOfChange),
36
+ sdcIsPreSome ? sdcPre : undefined,
37
+ sdcIsPostSome ? sdcPost : undefined,
38
+ sdcTimestampOfChange,
39
39
  );
40
40
 
41
41
  return new this(svc, sdc);
@@ -43,9 +43,9 @@ export class SharedMutableValues {
43
43
 
44
44
  toFields(): Fr[] {
45
45
  // Pack format matches Noir implementation:
46
- // [ sdc.pre_inner: u32 | sdc.pre_is_some: u8 | sdc.post_inner: u32 | sdc.post_is_some: u8 | sdc.block_of_change: u32 | svc.block_of_change: u32 ]
47
- let firstField = BigInt(this.svc.blockOfChange);
48
- firstField |= BigInt(this.sdc.blockOfChange) << 32n;
46
+ // [ sdc.pre_inner: u32 | sdc.pre_is_some: u8 | sdc.post_inner: u32 | sdc.post_is_some: u8 | sdc.timestamp_of_change: u32 | svc.timestamp_of_change: u32 ]
47
+ let firstField = this.svc.timestampOfChange;
48
+ firstField |= this.sdc.timestampOfChange << 32n;
49
49
  firstField |= (this.sdc.post === undefined ? 0n : 1n) << 64n;
50
50
  firstField |= BigInt(this.sdc.post || 0) << 72n;
51
51
  firstField |= (this.sdc.pre === undefined ? 0n : 1n) << 104n;
@@ -92,6 +92,7 @@ export type ServerCircuitName =
92
92
  | 'block-root-rollup'
93
93
  | 'single-tx-block-root-rollup'
94
94
  | 'empty-block-root-rollup'
95
+ | 'padding-block-root-rollup'
95
96
  | 'block-merge-rollup'
96
97
  | 'root-rollup'
97
98
  | 'avm-circuit'
@@ -165,7 +165,7 @@ import { CallContext } from '../tx/call_context.js';
165
165
  import { ContentCommitment } from '../tx/content_commitment.js';
166
166
  import { FunctionData } from '../tx/function_data.js';
167
167
  import { GlobalVariables } from '../tx/global_variables.js';
168
- import { MaxBlockNumber } from '../tx/max_block_number.js';
168
+ import { IncludeByTimestamp } from '../tx/include_by_timestamp.js';
169
169
  import { PartialStateReference } from '../tx/partial_state_reference.js';
170
170
  import { makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '../tx/processed_tx.js';
171
171
  import { PublicCallRequestWithCalldata } from '../tx/public_call_request_with_calldata.js';
@@ -174,7 +174,7 @@ import { TreeSnapshots } from '../tx/tree_snapshots.js';
174
174
  import { TxConstantData } from '../tx/tx_constant_data.js';
175
175
  import { TxContext } from '../tx/tx_context.js';
176
176
  import { TxRequest } from '../tx/tx_request.js';
177
- import { RollupTypes, Vector } from '../types/index.js';
177
+ import { Vector } from '../types/index.js';
178
178
  import { VkData } from '../vks/index.js';
179
179
  import { VerificationKey, VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
180
180
  import { mockTx } from './mocks.js';
@@ -308,7 +308,7 @@ export function makeContractStorageRead(seed = 1): ContractStorageRead {
308
308
  }
309
309
 
310
310
  export function makeRollupValidationRequests(seed = 1) {
311
- return new RollupValidationRequests(new MaxBlockNumber(true, seed + 0x31415));
311
+ return new RollupValidationRequests(new IncludeByTimestamp(true, BigInt(seed + 0x31415)));
312
312
  }
313
313
 
314
314
  function makeTxConstantData(seed = 1) {
@@ -567,7 +567,7 @@ export function makeTxRequest(seed = 1): TxRequest {
567
567
  */
568
568
  export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicInputs {
569
569
  return PrivateCircuitPublicInputs.from({
570
- maxBlockNumber: new MaxBlockNumber(true, seed + 0x31415),
570
+ includeByTimestamp: new IncludeByTimestamp(true, BigInt(seed + 0x31415)),
571
571
  callContext: makeCallContext(seed, { isStaticCall: true }),
572
572
  argsHash: fr(seed + 0x100),
573
573
  returnsHash: fr(seed + 0x200),
@@ -684,7 +684,6 @@ export function makeBaseOrMergeRollupPublicInputs(
684
684
  globalVariables: GlobalVariables | undefined = undefined,
685
685
  ): BaseOrMergeRollupPublicInputs {
686
686
  return new BaseOrMergeRollupPublicInputs(
687
- RollupTypes.Base,
688
687
  1,
689
688
  makeBlockConstantData(seed + 0x200, globalVariables),
690
689
  makePartialStateReference(seed + 0x300),
@@ -833,7 +832,6 @@ export function makeEmptyBlockRootRollupInputs(
833
832
  return new EmptyBlockRootRollupInputs(
834
833
  makeBlockRootRollupData(seed + 0x1000),
835
834
  makeBlockConstantData(0x2500, globalVariables),
836
- true,
837
835
  );
838
836
  }
839
837