@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
@@ -7,8 +7,8 @@ import { z } from 'zod';
7
7
  import { SimulationError } from '../errors/simulation_error.js';
8
8
  import { Gas } from '../gas/gas.js';
9
9
  import type { GasUsed } from '../gas/gas_used.js';
10
- import { CombinedConstantData } from '../kernel/combined_constant_data.js';
11
10
  import { TxEffect } from '../tx/tx_effect.js';
11
+ import { GlobalVariables } from './global_variables.js';
12
12
 
13
13
  /** Return values of simulating a circuit. */
14
14
  export type ProcessReturnValues = Fr[] | undefined;
@@ -50,7 +50,7 @@ export class NestedProcessReturnValues {
50
50
  export class PublicSimulationOutput {
51
51
  constructor(
52
52
  public revertReason: SimulationError | undefined,
53
- public constants: CombinedConstantData,
53
+ public globalVariables: GlobalVariables,
54
54
  public txEffect: TxEffect,
55
55
  public publicReturnValues: NestedProcessReturnValues[],
56
56
  public gasUsed: GasUsed,
@@ -60,7 +60,7 @@ export class PublicSimulationOutput {
60
60
  return z
61
61
  .object({
62
62
  revertReason: SimulationError.schema.optional(),
63
- constants: CombinedConstantData.schema,
63
+ globalVariables: GlobalVariables.schema,
64
64
  txEffect: TxEffect.schema,
65
65
  publicReturnValues: z.array(NestedProcessReturnValues.schema),
66
66
  gasUsed: z.object({
@@ -74,7 +74,7 @@ export class PublicSimulationOutput {
74
74
  fields =>
75
75
  new PublicSimulationOutput(
76
76
  fields.revertReason,
77
- fields.constants,
77
+ fields.globalVariables,
78
78
  fields.txEffect,
79
79
  fields.publicReturnValues,
80
80
  fields.gasUsed,
@@ -85,7 +85,7 @@ export class PublicSimulationOutput {
85
85
  static async random() {
86
86
  return new PublicSimulationOutput(
87
87
  await SimulationError.random(),
88
- CombinedConstantData.empty(),
88
+ GlobalVariables.empty(),
89
89
  TxEffect.empty(),
90
90
  times(2, NestedProcessReturnValues.random),
91
91
  { teardownGas: Gas.random(), totalGas: Gas.random(), publicGas: Gas.random(), billedGas: Gas.random() },
@@ -1,4 +1,5 @@
1
1
  import { STATE_REFERENCE_LENGTH } from '@aztec/constants';
2
+ import type { ViemStateReference } from '@aztec/ethereum';
2
3
  import type { Fr } from '@aztec/foundation/fields';
3
4
  import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
 
@@ -33,7 +34,7 @@ export class StateReference {
33
34
  }
34
35
 
35
36
  toBuffer() {
36
- // Note: The order here must match the order in the HeaderLib solidity library.
37
+ // Note: The order here must match the order in the ProposedHeaderLib solidity library.
37
38
  return serializeToBuffer(this.l1ToL2MessageTree, this.partial);
38
39
  }
39
40
 
@@ -61,12 +62,30 @@ export class StateReference {
61
62
  return new StateReference(l1ToL2MessageTree, partial);
62
63
  }
63
64
 
65
+ static fromViem(stateReference: ViemStateReference) {
66
+ return new StateReference(
67
+ AppendOnlyTreeSnapshot.fromViem(stateReference.l1ToL2MessageTree),
68
+ PartialStateReference.fromViem(stateReference.partialStateReference),
69
+ );
70
+ }
71
+
64
72
  static empty(): StateReference {
65
- return new StateReference(AppendOnlyTreeSnapshot.zero(), PartialStateReference.empty());
73
+ return new StateReference(AppendOnlyTreeSnapshot.empty(), PartialStateReference.empty());
74
+ }
75
+
76
+ toViem(): ViemStateReference {
77
+ return {
78
+ l1ToL2MessageTree: this.l1ToL2MessageTree.toViem(),
79
+ partialStateReference: this.partial.toViem(),
80
+ };
81
+ }
82
+
83
+ toAbi(): [ReturnType<AppendOnlyTreeSnapshot['toAbi']>, ReturnType<PartialStateReference['toAbi']>] {
84
+ return [this.l1ToL2MessageTree.toAbi(), [...this.partial.toAbi()]];
66
85
  }
67
86
 
68
87
  isEmpty(): boolean {
69
- return this.l1ToL2MessageTree.isZero() && this.partial.isEmpty();
88
+ return this.l1ToL2MessageTree.isEmpty() && this.partial.isEmpty();
70
89
  }
71
90
 
72
91
  toInspect() {
@@ -52,7 +52,7 @@ export class TreeSnapshots {
52
52
  }
53
53
 
54
54
  toBuffer() {
55
- // Note: The order here must match the order in the HeaderLib solidity library.
55
+ // Note: The order here must match the order in the ProposedHeaderLib solidity library.
56
56
  return serializeToBuffer(this.l1ToL2MessageTree, this.noteHashTree, this.nullifierTree, this.publicDataTree);
57
57
  }
58
58
 
@@ -84,19 +84,19 @@ export class TreeSnapshots {
84
84
 
85
85
  static empty(): TreeSnapshots {
86
86
  return new TreeSnapshots(
87
- AppendOnlyTreeSnapshot.zero(),
88
- AppendOnlyTreeSnapshot.zero(),
89
- AppendOnlyTreeSnapshot.zero(),
90
- AppendOnlyTreeSnapshot.zero(),
87
+ AppendOnlyTreeSnapshot.empty(),
88
+ AppendOnlyTreeSnapshot.empty(),
89
+ AppendOnlyTreeSnapshot.empty(),
90
+ AppendOnlyTreeSnapshot.empty(),
91
91
  );
92
92
  }
93
93
 
94
94
  isEmpty(): boolean {
95
95
  return (
96
- this.l1ToL2MessageTree.isZero() &&
97
- this.noteHashTree.isZero() &&
98
- this.nullifierTree.isZero() &&
99
- this.publicDataTree.isZero()
96
+ this.l1ToL2MessageTree.isEmpty() &&
97
+ this.noteHashTree.isEmpty() &&
98
+ this.nullifierTree.isEmpty() &&
99
+ this.publicDataTree.isEmpty()
100
100
  );
101
101
  }
102
102
 
package/src/tx/tx.ts CHANGED
@@ -163,7 +163,7 @@ export class Tx extends Gossipable {
163
163
 
164
164
  /**
165
165
  * Gets either revertible or non revertible contract class logs emitted by this tx.
166
- * @param revertible - true for revertible only logs, false for non reverible only logs.
166
+ * @param revertible - true for revertible only logs, false for non revertible only logs.
167
167
  * @returns The requested logs.
168
168
  */
169
169
  getSplitContractClassLogs(revertible: boolean): ContractClassLog[] {
package/src/tx/tx_hash.ts CHANGED
@@ -5,6 +5,7 @@ import { schemas } from '../schemas/index.js';
5
5
 
6
6
  /**
7
7
  * A class representing hash of Aztec transaction.
8
+ * @dev Computed by hashing the public inputs of the private kernel tail circuit (see Tx::getTxHash function).
8
9
  */
9
10
  export class TxHash {
10
11
  constructor(
@@ -1,71 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { type ZodFor } from '@aztec/foundation/schemas';
3
- import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
4
- import type { FieldsOf } from '@aztec/foundation/types';
5
- import { BlockHeader } from '../tx/block_header.js';
6
- import { GlobalVariables } from '../tx/global_variables.js';
7
- import type { TxConstantData } from '../tx/tx_constant_data.js';
8
- import { TxContext } from '../tx/tx_context.js';
9
- /**
10
- * Data that is constant/not modified by neither of the kernels.
11
- */
12
- export declare class CombinedConstantData {
13
- /** Header of a block whose state is used during execution (not the block the transaction is included in). */
14
- historicalHeader: BlockHeader;
15
- /**
16
- * Context of the transaction.
17
- *
18
- * Note: `chainId` and `version` in txContext are not redundant to the values in
19
- * self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
20
- * a situation we could be using header from a block before the upgrade took place but be using the updated
21
- * protocol to execute and prove the transaction.
22
- */
23
- txContext: TxContext;
24
- /**
25
- * Root of the vk tree for the protocol circuits.
26
- */
27
- vkTreeRoot: Fr;
28
- /**
29
- * Root of the tree for the protocol contracts.
30
- */
31
- protocolContractTreeRoot: Fr;
32
- /** Present when output by a public kernel, empty otherwise. */
33
- globalVariables: GlobalVariables;
34
- constructor(
35
- /** Header of a block whose state is used during execution (not the block the transaction is included in). */
36
- historicalHeader: BlockHeader,
37
- /**
38
- * Context of the transaction.
39
- *
40
- * Note: `chainId` and `version` in txContext are not redundant to the values in
41
- * self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
42
- * a situation we could be using header from a block before the upgrade took place but be using the updated
43
- * protocol to execute and prove the transaction.
44
- */
45
- txContext: TxContext,
46
- /**
47
- * Root of the vk tree for the protocol circuits.
48
- */
49
- vkTreeRoot: Fr,
50
- /**
51
- * Root of the tree for the protocol contracts.
52
- */
53
- protocolContractTreeRoot: Fr,
54
- /** Present when output by a public kernel, empty otherwise. */
55
- globalVariables: GlobalVariables);
56
- static combine(TxConstantData: TxConstantData, globalVariables: GlobalVariables): CombinedConstantData;
57
- static get schema(): ZodFor<CombinedConstantData>;
58
- toBuffer(): Buffer<ArrayBufferLike>;
59
- clone(): CombinedConstantData;
60
- getSize(): number;
61
- static from({ historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables, }: FieldsOf<CombinedConstantData>): CombinedConstantData;
62
- /**
63
- * Deserializes from a buffer or reader, corresponding to a write in cpp.
64
- * @param buffer - Buffer or buffer reader to read from.
65
- * @returns A new instance of CombinedConstantData.
66
- */
67
- static fromBuffer(buffer: Buffer | BufferReader): CombinedConstantData;
68
- static fromFields(fields: Fr[] | FieldReader): CombinedConstantData;
69
- static empty(): CombinedConstantData;
70
- }
71
- //# sourceMappingURL=combined_constant_data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combined_constant_data.d.ts","sourceRoot":"","sources":["../../src/kernel/combined_constant_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAyB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,qBAAa,oBAAoB;IAE7B,6GAA6G;IACtG,gBAAgB,EAAE,WAAW;IACpC;;;;;;;OAOG;IACI,SAAS,EAAE,SAAS;IAC3B;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC,+DAA+D;IACxD,eAAe,EAAE,eAAe;;IApBvC,6GAA6G;IACtG,gBAAgB,EAAE,WAAW;IACpC;;;;;;;OAOG;IACI,SAAS,EAAE,SAAS;IAC3B;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC,+DAA+D;IACxD,eAAe,EAAE,eAAe;IAGzC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe;IAU/E,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAWhD;IAED,QAAQ;IAUR,KAAK,IAAI,oBAAoB;IAI7B,OAAO;IAUP,MAAM,CAAC,IAAI,CAAC,EACV,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,wBAAwB,EACxB,eAAe,GAChB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,oBAAoB;IAIxD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,oBAAoB;IAWtE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,oBAAoB;IAWnE,MAAM,CAAC,KAAK;CAGb"}
@@ -1,73 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { hexSchemaFor, schemas } from '@aztec/foundation/schemas';
3
- import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { z } from 'zod';
5
- import { BlockHeader } from '../tx/block_header.js';
6
- import { GlobalVariables } from '../tx/global_variables.js';
7
- import { TxContext } from '../tx/tx_context.js';
8
- /**
9
- * Data that is constant/not modified by neither of the kernels.
10
- */ export class CombinedConstantData {
11
- historicalHeader;
12
- txContext;
13
- vkTreeRoot;
14
- protocolContractTreeRoot;
15
- globalVariables;
16
- constructor(/** Header of a block whose state is used during execution (not the block the transaction is included in). */ historicalHeader, /**
17
- * Context of the transaction.
18
- *
19
- * Note: `chainId` and `version` in txContext are not redundant to the values in
20
- * self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
21
- * a situation we could be using header from a block before the upgrade took place but be using the updated
22
- * protocol to execute and prove the transaction.
23
- */ txContext, /**
24
- * Root of the vk tree for the protocol circuits.
25
- */ vkTreeRoot, /**
26
- * Root of the tree for the protocol contracts.
27
- */ protocolContractTreeRoot, /** Present when output by a public kernel, empty otherwise. */ globalVariables){
28
- this.historicalHeader = historicalHeader;
29
- this.txContext = txContext;
30
- this.vkTreeRoot = vkTreeRoot;
31
- this.protocolContractTreeRoot = protocolContractTreeRoot;
32
- this.globalVariables = globalVariables;
33
- }
34
- static combine(TxConstantData, globalVariables) {
35
- return new CombinedConstantData(TxConstantData.historicalHeader, TxConstantData.txContext, TxConstantData.vkTreeRoot, TxConstantData.protocolContractTreeRoot, globalVariables);
36
- }
37
- static get schema() {
38
- return z.object({
39
- historicalHeader: BlockHeader.schema,
40
- txContext: TxContext.schema,
41
- vkTreeRoot: schemas.Fr,
42
- protocolContractTreeRoot: schemas.Fr,
43
- globalVariables: GlobalVariables.schema
44
- }).transform(CombinedConstantData.from).or(hexSchemaFor(CombinedConstantData));
45
- }
46
- toBuffer() {
47
- return serializeToBuffer(this.historicalHeader, this.txContext, this.vkTreeRoot, this.protocolContractTreeRoot, this.globalVariables);
48
- }
49
- clone() {
50
- return CombinedConstantData.fromBuffer(this.toBuffer());
51
- }
52
- getSize() {
53
- return this.historicalHeader.getSize() + this.txContext.getSize() + this.vkTreeRoot.size + this.protocolContractTreeRoot.size + this.globalVariables.getSize();
54
- }
55
- static from({ historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables }) {
56
- return new CombinedConstantData(historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables);
57
- }
58
- /**
59
- * Deserializes from a buffer or reader, corresponding to a write in cpp.
60
- * @param buffer - Buffer or buffer reader to read from.
61
- * @returns A new instance of CombinedConstantData.
62
- */ static fromBuffer(buffer) {
63
- const reader = BufferReader.asReader(buffer);
64
- return new CombinedConstantData(reader.readObject(BlockHeader), reader.readObject(TxContext), Fr.fromBuffer(reader), Fr.fromBuffer(reader), reader.readObject(GlobalVariables));
65
- }
66
- static fromFields(fields) {
67
- const reader = FieldReader.asReader(fields);
68
- return new CombinedConstantData(reader.readObject(BlockHeader), reader.readObject(TxContext), reader.readField(), reader.readField(), reader.readObject(GlobalVariables));
69
- }
70
- static empty() {
71
- return new CombinedConstantData(BlockHeader.empty(), TxContext.empty(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
72
- }
73
- }
@@ -1,45 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import type { FieldsOf } from '@aztec/foundation/types';
4
- import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
5
- import { GlobalVariables } from '../tx/global_variables.js';
6
- /**
7
- * Data which is forwarded through the base rollup circuits unchanged.
8
- */
9
- export declare class ConstantRollupData {
10
- /** Archive tree snapshot at the very beginning of the entire rollup. */
11
- lastArchive: AppendOnlyTreeSnapshot;
12
- /**
13
- * Root of the verification key tree.
14
- */
15
- vkTreeRoot: Fr;
16
- /**
17
- * Root of the protocol contract tree.
18
- */
19
- protocolContractTreeRoot: Fr;
20
- /**
21
- * Global variables for the block
22
- */
23
- globalVariables: GlobalVariables;
24
- constructor(
25
- /** Archive tree snapshot at the very beginning of the entire rollup. */
26
- lastArchive: AppendOnlyTreeSnapshot,
27
- /**
28
- * Root of the verification key tree.
29
- */
30
- vkTreeRoot: Fr,
31
- /**
32
- * Root of the protocol contract tree.
33
- */
34
- protocolContractTreeRoot: Fr,
35
- /**
36
- * Global variables for the block
37
- */
38
- globalVariables: GlobalVariables);
39
- static from(fields: FieldsOf<ConstantRollupData>): ConstantRollupData;
40
- static fromBuffer(buffer: Buffer | BufferReader): ConstantRollupData;
41
- static getFields(fields: FieldsOf<ConstantRollupData>): readonly [AppendOnlyTreeSnapshot, Fr, Fr, GlobalVariables];
42
- static empty(): ConstantRollupData;
43
- toBuffer(): Buffer<ArrayBufferLike>;
44
- }
45
- //# sourceMappingURL=constant_rollup_data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constant_rollup_data.d.ts","sourceRoot":"","sources":["../../src/rollup/constant_rollup_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,qBAAa,kBAAkB;IAE3B,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,eAAe,EAAE,eAAe;;IAbvC,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,eAAe,EAAE,eAAe;IAGzC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,kBAAkB;IAIrE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,kBAAkB;IAUpE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAIrD,MAAM,CAAC,KAAK;IAIZ,QAAQ;CAGT"}
@@ -1,128 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { type ZodFor, hexSchemaFor, schemas } from '@aztec/foundation/schemas';
3
- import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import type { FieldsOf } from '@aztec/foundation/types';
5
-
6
- import { z } from 'zod';
7
-
8
- import { BlockHeader } from '../tx/block_header.js';
9
- import { GlobalVariables } from '../tx/global_variables.js';
10
- import type { TxConstantData } from '../tx/tx_constant_data.js';
11
- import { TxContext } from '../tx/tx_context.js';
12
-
13
- /**
14
- * Data that is constant/not modified by neither of the kernels.
15
- */
16
- export class CombinedConstantData {
17
- constructor(
18
- /** Header of a block whose state is used during execution (not the block the transaction is included in). */
19
- public historicalHeader: BlockHeader,
20
- /**
21
- * Context of the transaction.
22
- *
23
- * Note: `chainId` and `version` in txContext are not redundant to the values in
24
- * self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
25
- * a situation we could be using header from a block before the upgrade took place but be using the updated
26
- * protocol to execute and prove the transaction.
27
- */
28
- public txContext: TxContext,
29
- /**
30
- * Root of the vk tree for the protocol circuits.
31
- */
32
- public vkTreeRoot: Fr,
33
- /**
34
- * Root of the tree for the protocol contracts.
35
- */
36
- public protocolContractTreeRoot: Fr,
37
- /** Present when output by a public kernel, empty otherwise. */
38
- public globalVariables: GlobalVariables,
39
- ) {}
40
-
41
- static combine(TxConstantData: TxConstantData, globalVariables: GlobalVariables) {
42
- return new CombinedConstantData(
43
- TxConstantData.historicalHeader,
44
- TxConstantData.txContext,
45
- TxConstantData.vkTreeRoot,
46
- TxConstantData.protocolContractTreeRoot,
47
- globalVariables,
48
- );
49
- }
50
-
51
- static get schema(): ZodFor<CombinedConstantData> {
52
- return z
53
- .object({
54
- historicalHeader: BlockHeader.schema,
55
- txContext: TxContext.schema,
56
- vkTreeRoot: schemas.Fr,
57
- protocolContractTreeRoot: schemas.Fr,
58
- globalVariables: GlobalVariables.schema,
59
- })
60
- .transform(CombinedConstantData.from)
61
- .or(hexSchemaFor(CombinedConstantData));
62
- }
63
-
64
- toBuffer() {
65
- return serializeToBuffer(
66
- this.historicalHeader,
67
- this.txContext,
68
- this.vkTreeRoot,
69
- this.protocolContractTreeRoot,
70
- this.globalVariables,
71
- );
72
- }
73
-
74
- clone(): CombinedConstantData {
75
- return CombinedConstantData.fromBuffer(this.toBuffer());
76
- }
77
-
78
- getSize() {
79
- return (
80
- this.historicalHeader.getSize() +
81
- this.txContext.getSize() +
82
- this.vkTreeRoot.size +
83
- this.protocolContractTreeRoot.size +
84
- this.globalVariables.getSize()
85
- );
86
- }
87
-
88
- static from({
89
- historicalHeader,
90
- txContext,
91
- vkTreeRoot,
92
- protocolContractTreeRoot,
93
- globalVariables,
94
- }: FieldsOf<CombinedConstantData>): CombinedConstantData {
95
- return new CombinedConstantData(historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables);
96
- }
97
-
98
- /**
99
- * Deserializes from a buffer or reader, corresponding to a write in cpp.
100
- * @param buffer - Buffer or buffer reader to read from.
101
- * @returns A new instance of CombinedConstantData.
102
- */
103
- static fromBuffer(buffer: Buffer | BufferReader): CombinedConstantData {
104
- const reader = BufferReader.asReader(buffer);
105
- return new CombinedConstantData(
106
- reader.readObject(BlockHeader),
107
- reader.readObject(TxContext),
108
- Fr.fromBuffer(reader),
109
- Fr.fromBuffer(reader),
110
- reader.readObject(GlobalVariables),
111
- );
112
- }
113
-
114
- static fromFields(fields: Fr[] | FieldReader): CombinedConstantData {
115
- const reader = FieldReader.asReader(fields);
116
- return new CombinedConstantData(
117
- reader.readObject(BlockHeader),
118
- reader.readObject(TxContext),
119
- reader.readField(),
120
- reader.readField(),
121
- reader.readObject(GlobalVariables),
122
- );
123
- }
124
-
125
- static empty() {
126
- return new CombinedConstantData(BlockHeader.empty(), TxContext.empty(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
127
- }
128
- }
@@ -1,54 +0,0 @@
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
- * Data which is forwarded through the base rollup circuits unchanged.
10
- */
11
- export class ConstantRollupData {
12
- constructor(
13
- /** Archive tree snapshot at the very beginning of the entire rollup. */
14
- public lastArchive: AppendOnlyTreeSnapshot,
15
- /**
16
- * Root of the verification key tree.
17
- */
18
- public vkTreeRoot: Fr,
19
- /**
20
- * Root of the protocol contract tree.
21
- */
22
- public protocolContractTreeRoot: Fr,
23
- /**
24
- * Global variables for the block
25
- */
26
- public globalVariables: GlobalVariables,
27
- ) {}
28
-
29
- static from(fields: FieldsOf<ConstantRollupData>): ConstantRollupData {
30
- return new ConstantRollupData(...ConstantRollupData.getFields(fields));
31
- }
32
-
33
- static fromBuffer(buffer: Buffer | BufferReader): ConstantRollupData {
34
- const reader = BufferReader.asReader(buffer);
35
- return new ConstantRollupData(
36
- reader.readObject(AppendOnlyTreeSnapshot),
37
- Fr.fromBuffer(reader),
38
- Fr.fromBuffer(reader),
39
- reader.readObject(GlobalVariables),
40
- );
41
- }
42
-
43
- static getFields(fields: FieldsOf<ConstantRollupData>) {
44
- return [fields.lastArchive, fields.vkTreeRoot, fields.protocolContractTreeRoot, fields.globalVariables] as const;
45
- }
46
-
47
- static empty() {
48
- return new ConstantRollupData(AppendOnlyTreeSnapshot.zero(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
49
- }
50
-
51
- toBuffer() {
52
- return serializeToBuffer(...ConstantRollupData.getFields(this));
53
- }
54
- }