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

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 (121) hide show
  1. package/dest/avm/avm.d.ts +304 -304
  2. package/dest/avm/avm_circuit_public_inputs.d.ts +60 -60
  3. package/dest/avm/avm_proving_request.d.ts +184 -184
  4. package/dest/avm/message_pack.d.ts.map +1 -1
  5. package/dest/avm/message_pack.js +2 -1
  6. package/dest/block/l2_block.js +1 -1
  7. package/dest/block/l2_block_code_to_purge.js +1 -1
  8. package/dest/block/l2_block_source.d.ts +2 -0
  9. package/dest/block/l2_block_source.d.ts.map +1 -1
  10. package/dest/fees/transaction_fee.js +3 -3
  11. package/dest/gas/gas.js +1 -1
  12. package/dest/gas/gas_fees.d.ts +15 -14
  13. package/dest/gas/gas_fees.d.ts.map +1 -1
  14. package/dest/gas/gas_fees.js +17 -18
  15. package/dest/gas/gas_settings.d.ts +24 -24
  16. package/dest/gas/gas_settings.d.ts.map +1 -1
  17. package/dest/gas/gas_settings.js +1 -1
  18. package/dest/interfaces/archiver.d.ts.map +1 -1
  19. package/dest/interfaces/archiver.js +1 -0
  20. package/dest/interfaces/proving-job.d.ts +185 -185
  21. package/dest/interfaces/proving-job.d.ts.map +1 -1
  22. package/dest/interfaces/service.d.ts +1 -2
  23. package/dest/interfaces/service.d.ts.map +1 -1
  24. package/dest/interfaces/service.js +0 -7
  25. package/dest/kernel/combined_constant_data.d.ts +71 -0
  26. package/dest/kernel/combined_constant_data.d.ts.map +1 -0
  27. package/dest/kernel/combined_constant_data.js +73 -0
  28. package/dest/kernel/index.d.ts +1 -0
  29. package/dest/kernel/index.d.ts.map +1 -1
  30. package/dest/kernel/index.js +1 -0
  31. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +3 -3
  32. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
  33. package/dest/rollup/base_or_merge_rollup_public_inputs.js +3 -3
  34. package/dest/rollup/base_rollup_hints.d.ts +14 -15
  35. package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
  36. package/dest/rollup/base_rollup_hints.js +12 -13
  37. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +24 -9
  38. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +1 -1
  39. package/dest/rollup/block_root_or_block_merge_public_inputs.js +14 -7
  40. package/dest/rollup/block_root_rollup.d.ts +2 -2
  41. package/dest/rollup/block_root_rollup.js +1 -1
  42. package/dest/rollup/constant_rollup_data.d.ts +45 -0
  43. package/dest/rollup/constant_rollup_data.d.ts.map +1 -0
  44. package/dest/rollup/{block_constant_data.js → constant_rollup_data.js} +13 -10
  45. package/dest/rollup/empty_block_root_rollup_inputs.d.ts +4 -4
  46. package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +1 -1
  47. package/dest/rollup/empty_block_root_rollup_inputs.js +2 -2
  48. package/dest/rollup/index.d.ts +1 -2
  49. package/dest/rollup/index.d.ts.map +1 -1
  50. package/dest/rollup/index.js +1 -2
  51. package/dest/rollup/root_rollup.d.ts +6 -2
  52. package/dest/rollup/root_rollup.d.ts.map +1 -1
  53. package/dest/rollup/root_rollup.js +6 -3
  54. package/dest/tests/factories.d.ts +10 -1
  55. package/dest/tests/factories.d.ts.map +1 -1
  56. package/dest/tests/factories.js +33 -20
  57. package/dest/tests/mocks.js +2 -2
  58. package/dest/trees/append_only_tree_snapshot.d.ts +2 -2
  59. package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
  60. package/dest/trees/append_only_tree_snapshot.js +2 -2
  61. package/dest/tx/block_header.js +2 -2
  62. package/dest/tx/global_variables.d.ts +12 -12
  63. package/dest/tx/global_variables.js +2 -2
  64. package/dest/tx/partial_state_reference.js +2 -2
  65. package/dest/tx/processed_tx.d.ts +3 -2
  66. package/dest/tx/processed_tx.d.ts.map +1 -1
  67. package/dest/tx/processed_tx.js +7 -5
  68. package/dest/tx/proposed_block_header.d.ts +2 -2
  69. package/dest/tx/proposed_block_header.js +1 -1
  70. package/dest/tx/public_simulation_output.d.ts +3 -3
  71. package/dest/tx/public_simulation_output.d.ts.map +1 -1
  72. package/dest/tx/public_simulation_output.js +7 -7
  73. package/dest/tx/state_reference.js +2 -2
  74. package/dest/tx/tree_snapshots.js +2 -2
  75. package/dest/tx/tx_context.d.ts +32 -32
  76. package/dest/types/shared.d.ts +4 -0
  77. package/dest/types/shared.d.ts.map +1 -1
  78. package/dest/zkpassport/index.d.ts +31 -0
  79. package/dest/zkpassport/index.d.ts.map +1 -0
  80. package/dest/zkpassport/index.js +81 -0
  81. package/package.json +9 -8
  82. package/src/avm/message_pack.ts +1 -0
  83. package/src/block/l2_block.ts +1 -1
  84. package/src/block/l2_block_code_to_purge.ts +1 -1
  85. package/src/block/l2_block_source.ts +3 -0
  86. package/src/fees/transaction_fee.ts +5 -5
  87. package/src/gas/gas.ts +1 -1
  88. package/src/gas/gas_fees.ts +27 -23
  89. package/src/gas/gas_settings.ts +1 -5
  90. package/src/interfaces/archiver.ts +1 -0
  91. package/src/interfaces/service.ts +1 -11
  92. package/src/kernel/combined_constant_data.ts +128 -0
  93. package/src/kernel/index.ts +1 -0
  94. package/src/rollup/base_or_merge_rollup_public_inputs.ts +4 -4
  95. package/src/rollup/base_rollup_hints.ts +11 -12
  96. package/src/rollup/block_root_or_block_merge_public_inputs.ts +18 -7
  97. package/src/rollup/block_root_rollup.ts +1 -1
  98. package/src/rollup/constant_rollup_data.ts +54 -0
  99. package/src/rollup/empty_block_root_rollup_inputs.ts +3 -3
  100. package/src/rollup/index.ts +1 -2
  101. package/src/rollup/root_rollup.ts +7 -5
  102. package/src/tests/factories.ts +54 -30
  103. package/src/tests/mocks.ts +2 -2
  104. package/src/trees/append_only_tree_snapshot.ts +2 -2
  105. package/src/tx/block_header.ts +2 -2
  106. package/src/tx/global_variables.ts +2 -2
  107. package/src/tx/partial_state_reference.ts +4 -4
  108. package/src/tx/processed_tx.ts +10 -7
  109. package/src/tx/proposed_block_header.ts +1 -1
  110. package/src/tx/public_simulation_output.ts +5 -5
  111. package/src/tx/state_reference.ts +2 -2
  112. package/src/tx/tree_snapshots.ts +8 -8
  113. package/src/types/shared.ts +5 -0
  114. package/src/zkpassport/index.ts +115 -0
  115. package/dest/rollup/block_constant_data.d.ts +0 -37
  116. package/dest/rollup/block_constant_data.d.ts.map +0 -1
  117. package/dest/rollup/epoch_constant_data.d.ts +0 -39
  118. package/dest/rollup/epoch_constant_data.d.ts.map +0 -1
  119. package/dest/rollup/epoch_constant_data.js +0 -40
  120. package/src/rollup/block_constant_data.ts +0 -63
  121. package/src/rollup/epoch_constant_data.ts +0 -44
@@ -99,6 +99,7 @@ import { KeyValidationRequestAndGenerator } from '../kernel/hints/key_validation
99
99
  import { ReadRequest } from '../kernel/hints/read_request.js';
100
100
  import { RollupValidationRequests } from '../kernel/hints/rollup_validation_requests.js';
101
101
  import {
102
+ CombinedConstantData,
102
103
  PartialPrivateTailPublicInputsForPublic,
103
104
  PartialPrivateTailPublicInputsForRollup,
104
105
  PrivateKernelTailCircuitPublicInputs,
@@ -144,9 +145,8 @@ import {
144
145
  BlockRootRollupInputs,
145
146
  SingleTxBlockRootRollupInputs,
146
147
  } from '../rollup/block_root_rollup.js';
148
+ import { ConstantRollupData } from '../rollup/constant_rollup_data.js';
147
149
  import { EmptyBlockRootRollupInputs } from '../rollup/empty_block_root_rollup_inputs.js';
148
- import { EpochConstantData } from '../rollup/epoch_constant_data.js';
149
- import { BlockConstantData } from '../rollup/index.js';
150
150
  import { MergeRollupInputs } from '../rollup/merge_rollup.js';
151
151
  import { PreviousRollupBlockData } from '../rollup/previous_rollup_block_data.js';
152
152
  import { PreviousRollupData } from '../rollup/previous_rollup_data.js';
@@ -314,6 +314,16 @@ function makeTxConstantData(seed = 1) {
314
314
  return new TxConstantData(makeHeader(seed), makeTxContext(seed + 0x100), new Fr(seed + 0x200), new Fr(seed + 0x201));
315
315
  }
316
316
 
317
+ export function makeCombinedConstantData(seed = 1): CombinedConstantData {
318
+ return new CombinedConstantData(
319
+ makeHeader(seed),
320
+ makeTxContext(seed + 0x100),
321
+ new Fr(seed + 0x200),
322
+ new Fr(seed + 0x201),
323
+ makeGlobalVariables(seed + 0x300),
324
+ );
325
+ }
326
+
317
327
  /**
318
328
  * Creates arbitrary accumulated data.
319
329
  * @param seed - The seed to use for generating the accumulated data.
@@ -603,19 +613,37 @@ export function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<Global
603
613
  timestamp: new Fr(seed + 4),
604
614
  coinbase: EthAddress.fromField(new Fr(seed + 5)),
605
615
  feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
606
- gasFees: new GasFees(new Fr(seed + 7), new Fr(seed + 8)),
616
+ gasFees: new GasFees(seed + 7, seed + 8),
607
617
  ...compact(overrides),
608
618
  });
609
619
  }
610
620
 
611
621
  export function makeGasFees(seed = 1) {
612
- return new GasFees(fr(seed), fr(seed + 1));
622
+ return new GasFees(seed, seed + 1);
613
623
  }
614
624
 
615
625
  export function makeFeeRecipient(seed = 1) {
616
626
  return new FeeRecipient(EthAddress.fromField(fr(seed)), fr(seed + 1));
617
627
  }
618
628
 
629
+ /**
630
+ * Makes constant base rollup data.
631
+ * @param seed - The seed to use for generating the constant base rollup data.
632
+ * @param blockNumber - The block number to use for generating the global variables.
633
+ * @returns A constant base rollup data.
634
+ */
635
+ export function makeConstantRollupData(
636
+ seed = 1,
637
+ globalVariables: GlobalVariables | undefined = undefined,
638
+ ): ConstantRollupData {
639
+ return ConstantRollupData.from({
640
+ lastArchive: makeAppendOnlyTreeSnapshot(seed + 0x300),
641
+ vkTreeRoot: fr(seed + 0x401),
642
+ protocolContractTreeRoot: fr(seed + 0x402),
643
+ globalVariables: globalVariables ?? makeGlobalVariables(seed + 0x500),
644
+ });
645
+ }
646
+
619
647
  /**
620
648
  * Makes arbitrary append only tree snapshot.
621
649
  * @param seed - The seed to use for generating the append only tree snapshot.
@@ -662,16 +690,6 @@ export function makeSchnorrSignature(seed = 1): SchnorrSignature {
662
690
  return new SchnorrSignature(Buffer.alloc(SchnorrSignature.SIZE, seed));
663
691
  }
664
692
 
665
- function makeBlockConstantData(seed = 1, globalVariables?: GlobalVariables) {
666
- return new BlockConstantData(
667
- makeAppendOnlyTreeSnapshot(seed + 0x100),
668
- makeAppendOnlyTreeSnapshot(seed + 0x200),
669
- fr(seed + 0x300),
670
- fr(seed + 0x400),
671
- globalVariables ?? makeGlobalVariables(seed + 0x500),
672
- );
673
- }
674
-
675
693
  /**
676
694
  * Makes arbitrary base or merge rollup circuit public inputs.
677
695
  * @param seed - The seed to use for generating the base rollup circuit public inputs.
@@ -685,7 +703,7 @@ export function makeBaseOrMergeRollupPublicInputs(
685
703
  return new BaseOrMergeRollupPublicInputs(
686
704
  RollupTypes.Base,
687
705
  1,
688
- makeBlockConstantData(seed + 0x200, globalVariables),
706
+ makeConstantRollupData(seed + 0x200, globalVariables),
689
707
  makePartialStateReference(seed + 0x300),
690
708
  makePartialStateReference(seed + 0x400),
691
709
  makeSpongeBlob(seed + 0x500),
@@ -696,10 +714,6 @@ export function makeBaseOrMergeRollupPublicInputs(
696
714
  );
697
715
  }
698
716
 
699
- function makeEpochConstantData(seed = 1) {
700
- return new EpochConstantData(fr(seed), fr(seed + 1), fr(seed + 2));
701
- }
702
-
703
717
  /**
704
718
  * Makes arbitrary block merge or block root rollup circuit public inputs.
705
719
  * @param seed - The seed to use for generating the block merge or block root rollup circuit public inputs.
@@ -711,7 +725,6 @@ export function makeBlockRootOrBlockMergeRollupPublicInputs(
711
725
  globalVariables: GlobalVariables | undefined = undefined,
712
726
  ): BlockRootOrBlockMergePublicInputs {
713
727
  return new BlockRootOrBlockMergePublicInputs(
714
- makeEpochConstantData(seed + 0x100),
715
728
  makeAppendOnlyTreeSnapshot(seed + 0x200),
716
729
  makeAppendOnlyTreeSnapshot(seed + 0x300),
717
730
  globalVariables ?? makeGlobalVariables(seed + 0x400),
@@ -719,6 +732,9 @@ export function makeBlockRootOrBlockMergeRollupPublicInputs(
719
732
  fr(seed + 0x600),
720
733
  makeTuple(AZTEC_MAX_EPOCH_DURATION, () => fr(seed), 0x650),
721
734
  makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x700),
735
+ fr(seed + 0x800),
736
+ fr(seed + 0x801),
737
+ fr(seed + 0x900),
722
738
  makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeBlockBlobPublicInputs(seed), 0x100),
723
739
  );
724
740
  }
@@ -770,10 +786,10 @@ export function makePreviousRollupBlockData(
770
786
  * @returns A root rollup inputs.
771
787
  */
772
788
  export function makeRootRollupInputs(seed = 0, globalVariables?: GlobalVariables): RootRollupInputs {
773
- return new RootRollupInputs([
774
- makePreviousRollupBlockData(seed, globalVariables),
775
- makePreviousRollupBlockData(seed + 0x1000, globalVariables),
776
- ]);
789
+ return new RootRollupInputs(
790
+ [makePreviousRollupBlockData(seed, globalVariables), makePreviousRollupBlockData(seed + 0x1000, globalVariables)],
791
+ fr(seed + 0x2000),
792
+ );
777
793
  }
778
794
 
779
795
  function makeBlockRootRollupData(seed = 0) {
@@ -829,7 +845,7 @@ export function makeEmptyBlockRootRollupInputs(
829
845
  ): EmptyBlockRootRollupInputs {
830
846
  return new EmptyBlockRootRollupInputs(
831
847
  makeBlockRootRollupData(seed + 0x1000),
832
- makeBlockConstantData(0x2500, globalVariables),
848
+ makeConstantRollupData(0x2500, globalVariables),
833
849
  true,
834
850
  );
835
851
  }
@@ -1097,7 +1113,7 @@ function makePrivateBaseRollupHints(seed = 1) {
1097
1113
 
1098
1114
  const contractClassLogsFields = makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeContractClassLogFields, seed + 0x800);
1099
1115
 
1100
- const constants = makeBlockConstantData(0x100);
1116
+ const constants = makeConstantRollupData(0x100);
1101
1117
 
1102
1118
  const feePayerFeeJuiceBalanceReadHint = PublicDataHint.empty();
1103
1119
 
@@ -1113,11 +1129,19 @@ function makePrivateBaseRollupHints(seed = 1) {
1113
1129
  }
1114
1130
 
1115
1131
  function makePublicBaseRollupHints(seed = 1) {
1132
+ const startSpongeBlob = makeSpongeBlob(seed + 0x200);
1133
+
1134
+ const archiveRootMembershipWitness = makeMembershipWitness(ARCHIVE_HEIGHT, seed + 0x9000);
1135
+
1136
+ const contractClassLogsFields = makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeContractClassLogFields, seed + 0x800);
1137
+
1138
+ const constants = makeConstantRollupData(0x100);
1139
+
1116
1140
  return PublicBaseRollupHints.from({
1117
- startSpongeBlob: makeSpongeBlob(seed),
1118
- lastArchive: makeAppendOnlyTreeSnapshot(seed + 0x1000),
1119
- archiveRootMembershipWitness: makeMembershipWitness(ARCHIVE_HEIGHT, seed + 0x2000),
1120
- contractClassLogsFields: makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeContractClassLogFields, seed + 0x3000),
1141
+ startSpongeBlob,
1142
+ archiveRootMembershipWitness,
1143
+ contractClassLogsFields,
1144
+ constants,
1121
1145
  });
1122
1146
  }
1123
1147
 
@@ -41,7 +41,7 @@ import { PublicSimulationOutput } from '../tx/public_simulation_output.js';
41
41
  import { TxSimulationResult, accumulatePrivateReturnValues } from '../tx/simulated_tx.js';
42
42
  import { TxEffect } from '../tx/tx_effect.js';
43
43
  import { TxHash } from '../tx/tx_hash.js';
44
- import { makeGas, makeGlobalVariables, makeHeader, makePublicCallRequest } from './factories.js';
44
+ import { makeCombinedConstantData, makeGas, makeHeader, makePublicCallRequest } from './factories.js';
45
45
 
46
46
  export const randomTxHash = (): TxHash => TxHash.random();
47
47
 
@@ -190,7 +190,7 @@ export const mockSimulatedTx = async (seed = 1) => {
190
190
  const tx = await mockTx(seed);
191
191
  const output = new PublicSimulationOutput(
192
192
  undefined,
193
- makeGlobalVariables(),
193
+ makeCombinedConstantData(),
194
194
  await TxEffect.random(),
195
195
  [accumulatePrivateReturnValues(privateExecutionResult)],
196
196
  {
@@ -71,11 +71,11 @@ export class AppendOnlyTreeSnapshot {
71
71
  return new AppendOnlyTreeSnapshot(reader.readField(), Number(reader.readField().toBigInt()));
72
72
  }
73
73
 
74
- static empty() {
74
+ static zero() {
75
75
  return new AppendOnlyTreeSnapshot(Fr.ZERO, 0);
76
76
  }
77
77
 
78
- isEmpty(): boolean {
78
+ isZero(): boolean {
79
79
  return this.root.isZero() && this.nextAvailableLeafIndex === 0;
80
80
  }
81
81
 
@@ -124,7 +124,7 @@ export class BlockHeader {
124
124
 
125
125
  static empty(fields: Partial<FieldsOf<BlockHeader>> = {}): BlockHeader {
126
126
  return BlockHeader.from({
127
- lastArchive: AppendOnlyTreeSnapshot.empty(),
127
+ lastArchive: AppendOnlyTreeSnapshot.zero(),
128
128
  contentCommitment: ContentCommitment.empty(),
129
129
  state: StateReference.empty(),
130
130
  globalVariables: GlobalVariables.empty(),
@@ -136,7 +136,7 @@ export class BlockHeader {
136
136
 
137
137
  isEmpty(): boolean {
138
138
  return (
139
- this.lastArchive.isEmpty() &&
139
+ this.lastArchive.isZero() &&
140
140
  this.contentCommitment.isEmpty() &&
141
141
  this.state.isEmpty() &&
142
142
  this.globalVariables.isEmpty() &&
@@ -169,8 +169,8 @@ export class GlobalVariables {
169
169
  timestamp: this.timestamp.toNumber(),
170
170
  coinbase: this.coinbase.toString(),
171
171
  feeRecipient: this.feeRecipient.toString(),
172
- feePerDaGas: this.gasFees.feePerDaGas.toNumber(),
173
- feePerL2Gas: this.gasFees.feePerL2Gas.toNumber(),
172
+ feePerDaGas: Number(this.gasFees.feePerDaGas),
173
+ feePerL2Gas: Number(this.gasFees.feePerL2Gas),
174
174
  };
175
175
  }
176
176
 
@@ -57,9 +57,9 @@ export class PartialStateReference {
57
57
 
58
58
  static empty(): PartialStateReference {
59
59
  return new PartialStateReference(
60
- AppendOnlyTreeSnapshot.empty(),
61
- AppendOnlyTreeSnapshot.empty(),
62
- AppendOnlyTreeSnapshot.empty(),
60
+ AppendOnlyTreeSnapshot.zero(),
61
+ AppendOnlyTreeSnapshot.zero(),
62
+ AppendOnlyTreeSnapshot.zero(),
63
63
  );
64
64
  }
65
65
 
@@ -82,7 +82,7 @@ export class PartialStateReference {
82
82
  }
83
83
 
84
84
  isEmpty(): boolean {
85
- return this.noteHashTree.isEmpty() && this.nullifierTree.isEmpty() && this.publicDataTree.isEmpty();
85
+ return this.noteHashTree.isZero() && this.nullifierTree.isZero() && this.publicDataTree.isZero();
86
86
  }
87
87
 
88
88
  public equals(other: this): boolean {
@@ -7,6 +7,7 @@ import type { SimulationError } from '../errors/simulation_error.js';
7
7
  import { Gas } from '../gas/gas.js';
8
8
  import type { GasUsed } from '../gas/gas_used.js';
9
9
  import { siloL2ToL1Message } from '../hash/hash.js';
10
+ import { CombinedConstantData } from '../kernel/combined_constant_data.js';
10
11
  import type { PrivateKernelTailCircuitPublicInputs } from '../kernel/private_kernel_tail_circuit_public_inputs.js';
11
12
  import type { ClientIvcProof } from '../proofs/client_ivc_proof.js';
12
13
  import type { GlobalVariables } from './global_variables.js';
@@ -42,9 +43,9 @@ export type ProcessedTx = {
42
43
  */
43
44
  avmProvingRequest: AvmProvingRequest | undefined;
44
45
  /**
45
- * `GlobalVariables` injected by the sequencer. It's the same for all the txs in a block.
46
+ * Combining `TxConstantData` specified by the user, and `GlobalVariables` injected by the sequencer.
46
47
  */
47
- globalVariables: GlobalVariables;
48
+ constants: CombinedConstantData;
48
49
  /**
49
50
  * Output data of the tx.
50
51
  */
@@ -83,6 +84,8 @@ export async function makeProcessedTxFromPrivateOnlyTx(
83
84
  feePaymentPublicDataWrite: PublicDataWrite,
84
85
  globalVariables: GlobalVariables,
85
86
  ): Promise<ProcessedTx> {
87
+ const constants = CombinedConstantData.combine(tx.data.constants, globalVariables);
88
+
86
89
  const data = tx.data.forRollup!;
87
90
  const txEffect = new TxEffect(
88
91
  RevertCode.OK,
@@ -91,7 +94,7 @@ export async function makeProcessedTxFromPrivateOnlyTx(
91
94
  data.end.noteHashes.filter(h => !h.isZero()),
92
95
  data.end.nullifiers.filter(h => !h.isZero()),
93
96
  data.end.l2ToL1Msgs
94
- .map(message => siloL2ToL1Message(message, globalVariables.version, globalVariables.chainId))
97
+ .map(message => siloL2ToL1Message(message, constants.txContext.version, constants.txContext.chainId))
95
98
  .filter(h => !h.isZero()),
96
99
  [feePaymentPublicDataWrite],
97
100
  data.end.privateLogs.filter(l => !l.isEmpty()),
@@ -112,7 +115,7 @@ export async function makeProcessedTxFromPrivateOnlyTx(
112
115
  data: tx.data,
113
116
  clientIvcProof: tx.clientIvcProof,
114
117
  avmProvingRequest: undefined,
115
- globalVariables,
118
+ constants,
116
119
  txEffect,
117
120
  gasUsed,
118
121
  revertCode: RevertCode.OK,
@@ -135,7 +138,7 @@ export async function makeProcessedTxFromTxWithPublicCalls(
135
138
  ): Promise<ProcessedTx> {
136
139
  const avmPublicInputs = avmProvingRequest.inputs.publicInputs;
137
140
 
138
- const globalVariables = avmPublicInputs.globalVariables;
141
+ const constants = CombinedConstantData.combine(tx.data.constants, avmPublicInputs.globalVariables);
139
142
 
140
143
  const publicDataWrites = avmPublicInputs.accumulatedData.publicDataWrites.filter(w => !w.isEmpty());
141
144
 
@@ -155,7 +158,7 @@ export async function makeProcessedTxFromTxWithPublicCalls(
155
158
  avmPublicInputs.accumulatedData.noteHashes.filter(h => !h.isZero()),
156
159
  avmPublicInputs.accumulatedData.nullifiers.filter(h => !h.isZero()),
157
160
  avmPublicInputs.accumulatedData.l2ToL1Msgs
158
- .map(message => siloL2ToL1Message(message, globalVariables.version, globalVariables.chainId))
161
+ .map(message => siloL2ToL1Message(message, constants.txContext.version, constants.txContext.chainId))
159
162
  .filter(h => !h.isZero()),
160
163
  publicDataWrites,
161
164
  privateLogs,
@@ -168,7 +171,7 @@ export async function makeProcessedTxFromTxWithPublicCalls(
168
171
  data: tx.data,
169
172
  clientIvcProof: tx.clientIvcProof,
170
173
  avmProvingRequest,
171
- globalVariables,
174
+ constants,
172
175
  txEffect,
173
176
  gasUsed,
174
177
  revertCode,
@@ -154,7 +154,7 @@ export class ProposedBlockHeader {
154
154
  }
155
155
 
156
156
  [inspect.custom]() {
157
- const gasfees = `da:${this.gasFees.feePerDaGas.toBigInt()}, l2:${this.gasFees.feePerL2Gas.toBigInt()}`;
157
+ const gasfees = `da:${this.gasFees.feePerDaGas}, l2:${this.gasFees.feePerL2Gas}`;
158
158
  return `Header {
159
159
  lastArchiveRoot: ${this.lastArchiveRoot.toString()},
160
160
  contentCommitment: ${inspect(this.contentCommitment)},
@@ -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';
10
11
  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 globalVariables: GlobalVariables,
53
+ public constants: CombinedConstantData,
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
- globalVariables: GlobalVariables.schema,
63
+ constants: CombinedConstantData.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.globalVariables,
77
+ fields.constants,
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
- GlobalVariables.empty(),
88
+ CombinedConstantData.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() },
@@ -62,11 +62,11 @@ export class StateReference {
62
62
  }
63
63
 
64
64
  static empty(): StateReference {
65
- return new StateReference(AppendOnlyTreeSnapshot.empty(), PartialStateReference.empty());
65
+ return new StateReference(AppendOnlyTreeSnapshot.zero(), PartialStateReference.empty());
66
66
  }
67
67
 
68
68
  isEmpty(): boolean {
69
- return this.l1ToL2MessageTree.isEmpty() && this.partial.isEmpty();
69
+ return this.l1ToL2MessageTree.isZero() && this.partial.isEmpty();
70
70
  }
71
71
 
72
72
  toInspect() {
@@ -84,19 +84,19 @@ export class TreeSnapshots {
84
84
 
85
85
  static empty(): TreeSnapshots {
86
86
  return new TreeSnapshots(
87
- AppendOnlyTreeSnapshot.empty(),
88
- AppendOnlyTreeSnapshot.empty(),
89
- AppendOnlyTreeSnapshot.empty(),
90
- AppendOnlyTreeSnapshot.empty(),
87
+ AppendOnlyTreeSnapshot.zero(),
88
+ AppendOnlyTreeSnapshot.zero(),
89
+ AppendOnlyTreeSnapshot.zero(),
90
+ AppendOnlyTreeSnapshot.zero(),
91
91
  );
92
92
  }
93
93
 
94
94
  isEmpty(): boolean {
95
95
  return (
96
- this.l1ToL2MessageTree.isEmpty() &&
97
- this.noteHashTree.isEmpty() &&
98
- this.nullifierTree.isEmpty() &&
99
- this.publicDataTree.isEmpty()
96
+ this.l1ToL2MessageTree.isZero() &&
97
+ this.noteHashTree.isZero() &&
98
+ this.nullifierTree.isZero() &&
99
+ this.publicDataTree.isZero()
100
100
  );
101
101
  }
102
102
 
@@ -30,6 +30,11 @@ export type UInt32 = number;
30
30
  */
31
31
  export type UInt64 = bigint;
32
32
 
33
+ /**
34
+ * A type alias for a 128-bit unsigned integer.
35
+ */
36
+ export type UInt128 = bigint;
37
+
33
38
  /**
34
39
  * CircuitType replaces ComposerType for now. When using Plonk, CircuitType is equivalent to the information of the proving system that will be used
35
40
  * to construct a proof. In the future Aztec zk stack, more information must be specified (e.g., the curve over which circuits are constructed;
@@ -0,0 +1,115 @@
1
+ import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { randomBytes } from '@aztec/foundation/crypto';
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
+ import { withoutHexPrefix } from '@aztec/foundation/string';
6
+
7
+ export type ViemZkPassportProofParams = {
8
+ vkeyHash: `0x${string}`;
9
+ proof: `0x${string}`;
10
+ publicInputs: `0x${string}`[];
11
+ committedInputs: `0x${string}`;
12
+ committedInputCounts: bigint[];
13
+ validityPeriodInDays: bigint;
14
+ scope: string;
15
+ subscope: string;
16
+ devMode: boolean;
17
+ };
18
+
19
+ // NOTE: Must match the ZkPassportProofParams struct in the zkpassport verifier contract
20
+ // find here: ROOT/l1-contracts/lib/circuits/src/solidity/src/ZKPassportVerifier.sol
21
+ export class ZkPassportProofParams {
22
+ constructor(
23
+ public devMode: boolean,
24
+ public vkeyHash: Buffer32,
25
+ public proof: Buffer,
26
+ public publicInputs: Fr[],
27
+ public committedInputs: Buffer,
28
+ public committedInputCounts: bigint[],
29
+ public validityPeriodInDays: bigint,
30
+ public scope: string,
31
+ public subscope: string,
32
+ ) {}
33
+
34
+ toBuffer() {
35
+ return serializeToBuffer([
36
+ this.devMode,
37
+ this.vkeyHash,
38
+ this.proof.length,
39
+ this.proof,
40
+ this.publicInputs.length,
41
+ this.publicInputs,
42
+ this.committedInputs.length,
43
+ this.committedInputs,
44
+ this.committedInputCounts.length,
45
+ this.committedInputCounts,
46
+ this.validityPeriodInDays,
47
+ this.scope,
48
+ this.subscope,
49
+ ]);
50
+ }
51
+
52
+ static random() {
53
+ const committedInputCounts = [BigInt(1), BigInt(2), BigInt(3), BigInt(4)];
54
+ const numberOfCommittedInputs = committedInputCounts.reduce((acc, count) => acc + count, BigInt(0));
55
+ const committedInputs = randomBytes(Number(numberOfCommittedInputs) * 32);
56
+
57
+ const publicInputsCount = numberOfCommittedInputs + 16n;
58
+ const publicInputs = Array.from({ length: Number(publicInputsCount) }, () => Fr.random());
59
+
60
+ return new ZkPassportProofParams(
61
+ false,
62
+ Buffer32.random(),
63
+ randomBytes(1024),
64
+ publicInputs,
65
+ committedInputs,
66
+ committedInputCounts,
67
+ BigInt(100),
68
+ 'sequencer.alpha-testnet.aztec.network',
69
+ 'personhood',
70
+ );
71
+ }
72
+
73
+ static fromBuffer(buffer: Buffer) {
74
+ const reader = BufferReader.asReader(buffer);
75
+ return new ZkPassportProofParams(
76
+ reader.readBoolean(),
77
+ reader.readObject(Buffer32),
78
+ reader.readBuffer(),
79
+ reader.readVector(Fr),
80
+ reader.readBuffer(),
81
+ reader.readUint256Vector(),
82
+ reader.readUInt256(),
83
+ reader.readString(),
84
+ reader.readString(),
85
+ );
86
+ }
87
+
88
+ static fromViem(params: ViemZkPassportProofParams) {
89
+ return new ZkPassportProofParams(
90
+ params.devMode,
91
+ Buffer32.fromString(params.vkeyHash),
92
+ Buffer.from(withoutHexPrefix(params.proof), 'hex'),
93
+ params.publicInputs.map(input => Fr.fromString(input)),
94
+ Buffer.from(withoutHexPrefix(params.committedInputs), 'hex'),
95
+ params.committedInputCounts,
96
+ params.validityPeriodInDays,
97
+ params.scope,
98
+ params.subscope,
99
+ );
100
+ }
101
+
102
+ toViem(): ViemZkPassportProofParams {
103
+ return {
104
+ devMode: this.devMode,
105
+ vkeyHash: this.vkeyHash.toString(),
106
+ proof: `0x${this.proof.toString('hex')}`,
107
+ publicInputs: this.publicInputs.map(input => input.toString()),
108
+ committedInputs: `0x${this.committedInputs.toString('hex')}`,
109
+ committedInputCounts: this.committedInputCounts,
110
+ validityPeriodInDays: this.validityPeriodInDays,
111
+ scope: this.scope,
112
+ subscope: this.subscope,
113
+ };
114
+ }
115
+ }
@@ -1,37 +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
- * Constants that are the same for the entire block.
8
- */
9
- export declare class BlockConstantData {
10
- /** Archive tree snapshot at the very beginning of the entire rollup. */
11
- lastArchive: AppendOnlyTreeSnapshot;
12
- /** L1 to L2 message tree snapshot at the very beginning of the entire rollup. */
13
- lastL1ToL2: AppendOnlyTreeSnapshot;
14
- /** Root of the verification key tree. */
15
- vkTreeRoot: Fr;
16
- /** Root of the protocol contract tree. */
17
- protocolContractTreeRoot: Fr;
18
- /** Global variables for the block. */
19
- globalVariables: GlobalVariables;
20
- constructor(
21
- /** Archive tree snapshot at the very beginning of the entire rollup. */
22
- lastArchive: AppendOnlyTreeSnapshot,
23
- /** L1 to L2 message tree snapshot at the very beginning of the entire rollup. */
24
- lastL1ToL2: AppendOnlyTreeSnapshot,
25
- /** Root of the verification key tree. */
26
- vkTreeRoot: Fr,
27
- /** Root of the protocol contract tree. */
28
- protocolContractTreeRoot: Fr,
29
- /** Global variables for the block. */
30
- globalVariables: GlobalVariables);
31
- static from(fields: FieldsOf<BlockConstantData>): BlockConstantData;
32
- static fromBuffer(buffer: Buffer | BufferReader): BlockConstantData;
33
- static getFields(fields: FieldsOf<BlockConstantData>): readonly [AppendOnlyTreeSnapshot, AppendOnlyTreeSnapshot, Fr, Fr, GlobalVariables];
34
- static empty(): BlockConstantData;
35
- toBuffer(): Buffer<ArrayBufferLike>;
36
- }
37
- //# sourceMappingURL=block_constant_data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"block_constant_data.d.ts","sourceRoot":"","sources":["../../src/rollup/block_constant_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,iBAAiB;IAE1B,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C,iFAAiF;IAC1E,UAAU,EAAE,sBAAsB;IACzC,yCAAyC;IAClC,UAAU,EAAE,EAAE;IACrB,0CAA0C;IACnC,wBAAwB,EAAE,EAAE;IACnC,sCAAsC;IAC/B,eAAe,EAAE,eAAe;;IATvC,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C,iFAAiF;IAC1E,UAAU,EAAE,sBAAsB;IACzC,yCAAyC;IAClC,UAAU,EAAE,EAAE;IACrB,0CAA0C;IACnC,wBAAwB,EAAE,EAAE;IACnC,sCAAsC;IAC/B,eAAe,EAAE,eAAe;IAGzC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,iBAAiB;IAInE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,iBAAiB;IAWnE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAUpD,MAAM,CAAC,KAAK;IAUZ,QAAQ;CAGT"}
@@ -1,39 +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
- /**
5
- * Constants that are the same for the entire epoch.
6
- */
7
- export declare class EpochConstantData {
8
- /**
9
- * Root of the verification key tree.
10
- */
11
- vkTreeRoot: Fr;
12
- /**
13
- * Root of the protocol contract tree.
14
- */
15
- protocolContractTreeRoot: Fr;
16
- /**
17
- * Identifier of the prover of the epoch.
18
- */
19
- proverId: Fr;
20
- constructor(
21
- /**
22
- * Root of the verification key tree.
23
- */
24
- vkTreeRoot: Fr,
25
- /**
26
- * Root of the protocol contract tree.
27
- */
28
- protocolContractTreeRoot: Fr,
29
- /**
30
- * Identifier of the prover of the epoch.
31
- */
32
- proverId: Fr);
33
- static from(fields: FieldsOf<EpochConstantData>): EpochConstantData;
34
- static fromBuffer(buffer: Buffer | BufferReader): EpochConstantData;
35
- static getFields(fields: FieldsOf<EpochConstantData>): readonly [Fr, Fr, Fr];
36
- static empty(): EpochConstantData;
37
- toBuffer(): Buffer<ArrayBufferLike>;
38
- }
39
- //# sourceMappingURL=epoch_constant_data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"epoch_constant_data.d.ts","sourceRoot":"","sources":["../../src/rollup/epoch_constant_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;;GAEG;AACH,qBAAa,iBAAiB;IAE1B;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,QAAQ,EAAE,EAAE;;IAXnB;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,QAAQ,EAAE,EAAE;IAGrB,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,iBAAiB;IAInE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,iBAAiB;IAKnE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAIpD,MAAM,CAAC,KAAK;IAIZ,QAAQ;CAGT"}