@aztec/sequencer-client 0.7.0 → 0.7.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 (111) hide show
  1. package/Dockerfile +21 -0
  2. package/package.json +10 -10
  3. package/src/block_builder/solo_block_builder.test.ts +4 -4
  4. package/src/block_builder/solo_block_builder.ts +80 -24
  5. package/src/publisher/viem-tx-sender.ts +4 -1
  6. package/src/sequencer/sequencer.ts +15 -4
  7. package/src/simulator/public_executor.ts +2 -16
  8. package/src/simulator/rollup.ts +7 -4
  9. package/.tsbuildinfo +0 -1
  10. package/dest/block_builder/index.d.ts +0 -19
  11. package/dest/block_builder/index.d.ts.map +0 -1
  12. package/dest/block_builder/index.js +0 -2
  13. package/dest/block_builder/solo_block_builder.d.ts +0 -77
  14. package/dest/block_builder/solo_block_builder.d.ts.map +0 -1
  15. package/dest/block_builder/solo_block_builder.js +0 -454
  16. package/dest/block_builder/solo_block_builder.test.d.ts +0 -3
  17. package/dest/block_builder/solo_block_builder.test.d.ts.map +0 -1
  18. package/dest/block_builder/solo_block_builder.test.js +0 -277
  19. package/dest/block_builder/types.d.ts +0 -12
  20. package/dest/block_builder/types.d.ts.map +0 -1
  21. package/dest/block_builder/types.js +0 -2
  22. package/dest/client/index.d.ts +0 -2
  23. package/dest/client/index.d.ts.map +0 -1
  24. package/dest/client/index.js +0 -2
  25. package/dest/client/sequencer-client.d.ts +0 -32
  26. package/dest/client/sequencer-client.d.ts.map +0 -1
  27. package/dest/client/sequencer-client.js +0 -47
  28. package/dest/config.d.ts +0 -12
  29. package/dest/config.d.ts.map +0 -1
  30. package/dest/config.js +0 -28
  31. package/dest/global_variable_builder/config.d.ts +0 -19
  32. package/dest/global_variable_builder/config.d.ts.map +0 -1
  33. package/dest/global_variable_builder/config.js +0 -2
  34. package/dest/global_variable_builder/global_builder.d.ts +0 -58
  35. package/dest/global_variable_builder/global_builder.d.ts.map +0 -1
  36. package/dest/global_variable_builder/global_builder.js +0 -36
  37. package/dest/global_variable_builder/index.d.ts +0 -12
  38. package/dest/global_variable_builder/index.d.ts.map +0 -1
  39. package/dest/global_variable_builder/index.js +0 -12
  40. package/dest/global_variable_builder/viem-reader.d.ts +0 -16
  41. package/dest/global_variable_builder/viem-reader.d.ts.map +0 -1
  42. package/dest/global_variable_builder/viem-reader.js +0 -37
  43. package/dest/index.d.ts +0 -12
  44. package/dest/index.d.ts.map +0 -1
  45. package/dest/index.js +0 -14
  46. package/dest/mocks/verification_keys.d.ts +0 -28
  47. package/dest/mocks/verification_keys.d.ts.map +0 -1
  48. package/dest/mocks/verification_keys.js +0 -14
  49. package/dest/prover/empty.d.ts +0 -41
  50. package/dest/prover/empty.d.ts.map +0 -1
  51. package/dest/prover/empty.js +0 -57
  52. package/dest/prover/index.d.ts +0 -40
  53. package/dest/prover/index.d.ts.map +0 -1
  54. package/dest/prover/index.js +0 -2
  55. package/dest/publisher/config.d.ts +0 -32
  56. package/dest/publisher/config.d.ts.map +0 -1
  57. package/dest/publisher/config.js +0 -2
  58. package/dest/publisher/index.d.ts +0 -10
  59. package/dest/publisher/index.d.ts.map +0 -1
  60. package/dest/publisher/index.js +0 -11
  61. package/dest/publisher/l1-publisher.d.ts +0 -105
  62. package/dest/publisher/l1-publisher.d.ts.map +0 -1
  63. package/dest/publisher/l1-publisher.js +0 -156
  64. package/dest/publisher/l1-publisher.test.d.ts +0 -2
  65. package/dest/publisher/l1-publisher.test.d.ts.map +0 -1
  66. package/dest/publisher/l1-publisher.test.js +0 -58
  67. package/dest/publisher/viem-tx-sender.d.ts +0 -42
  68. package/dest/publisher/viem-tx-sender.d.ts.map +0 -1
  69. package/dest/publisher/viem-tx-sender.js +0 -118
  70. package/dest/receiver.d.ts +0 -13
  71. package/dest/receiver.d.ts.map +0 -1
  72. package/dest/receiver.js +0 -2
  73. package/dest/sequencer/config.d.ts +0 -26
  74. package/dest/sequencer/config.d.ts.map +0 -1
  75. package/dest/sequencer/config.js +0 -2
  76. package/dest/sequencer/index.d.ts +0 -4
  77. package/dest/sequencer/index.d.ts.map +0 -1
  78. package/dest/sequencer/index.js +0 -4
  79. package/dest/sequencer/processed_tx.d.ts +0 -51
  80. package/dest/sequencer/processed_tx.d.ts.map +0 -1
  81. package/dest/sequencer/processed_tx.js +0 -40
  82. package/dest/sequencer/public_processor.d.ts +0 -75
  83. package/dest/sequencer/public_processor.d.ts.map +0 -1
  84. package/dest/sequencer/public_processor.js +0 -269
  85. package/dest/sequencer/public_processor.test.d.ts +0 -2
  86. package/dest/sequencer/public_processor.test.d.ts.map +0 -1
  87. package/dest/sequencer/public_processor.test.js +0 -164
  88. package/dest/sequencer/sequencer.d.ts +0 -133
  89. package/dest/sequencer/sequencer.d.ts.map +0 -1
  90. package/dest/sequencer/sequencer.js +0 -297
  91. package/dest/sequencer/sequencer.test.d.ts +0 -2
  92. package/dest/sequencer/sequencer.test.d.ts.map +0 -1
  93. package/dest/sequencer/sequencer.test.js +0 -99
  94. package/dest/sequencer/utils.d.ts +0 -7
  95. package/dest/sequencer/utils.d.ts.map +0 -1
  96. package/dest/sequencer/utils.js +0 -12
  97. package/dest/simulator/index.d.ts +0 -43
  98. package/dest/simulator/index.d.ts.map +0 -1
  99. package/dest/simulator/index.js +0 -2
  100. package/dest/simulator/public_executor.d.ts +0 -22
  101. package/dest/simulator/public_executor.d.ts.map +0 -1
  102. package/dest/simulator/public_executor.js +0 -99
  103. package/dest/simulator/public_kernel.d.ts +0 -20
  104. package/dest/simulator/public_kernel.d.ts.map +0 -1
  105. package/dest/simulator/public_kernel.js +0 -27
  106. package/dest/simulator/rollup.d.ts +0 -34
  107. package/dest/simulator/rollup.d.ts.map +0 -1
  108. package/dest/simulator/rollup.js +0 -50
  109. package/dest/utils.d.ts +0 -12
  110. package/dest/utils.d.ts.map +0 -1
  111. package/dest/utils.js +0 -16
package/Dockerfile ADDED
@@ -0,0 +1,21 @@
1
+ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder
2
+
3
+ # (1) project
4
+ COPY . .
5
+
6
+ # (2) build
7
+ WORKDIR /usr/src/yarn-project/sequencer-client
8
+ RUN yarn build && yarn formatting
9
+
10
+ # (3) test
11
+ RUN yarn test
12
+
13
+ # (4) Prune dev dependencies. See comment in base image.
14
+ RUN yarn cache clean
15
+ RUN yarn workspaces focus --production > /dev/null
16
+
17
+ # (5) set up entry point
18
+ FROM node:18-alpine
19
+ COPY --from=builder /usr/src/yarn-project /usr/src/yarn-project
20
+ WORKDIR /usr/src/yarn-project/sequencer-client
21
+ ENTRYPOINT ["yarn", "test"]
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "exports": "./dest/index.js",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@aztec/acir-simulator": "0.7.0",
8
- "@aztec/circuits.js": "0.7.0",
9
- "@aztec/ethereum": "0.7.0",
10
- "@aztec/foundation": "0.7.0",
11
- "@aztec/l1-artifacts": "0.7.0",
12
- "@aztec/merkle-tree": "0.7.0",
13
- "@aztec/p2p": "0.7.0",
14
- "@aztec/types": "0.7.0",
15
- "@aztec/world-state": "0.7.0",
7
+ "@aztec/acir-simulator": "0.7.2",
8
+ "@aztec/circuits.js": "0.7.2",
9
+ "@aztec/ethereum": "0.7.2",
10
+ "@aztec/foundation": "0.7.2",
11
+ "@aztec/l1-artifacts": "0.7.2",
12
+ "@aztec/merkle-tree": "0.7.2",
13
+ "@aztec/p2p": "0.7.2",
14
+ "@aztec/types": "0.7.2",
15
+ "@aztec/world-state": "0.7.2",
16
16
  "lodash.chunk": "^4.2.0",
17
17
  "lodash.flatmap": "^4.5.0",
18
18
  "lodash.pick": "^4.4.0",
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  AppendOnlyTreeSnapshot,
3
3
  BaseOrMergeRollupPublicInputs,
4
- BaseRollupInputs,
5
4
  CircuitsWasm,
6
5
  Fr,
7
6
  GlobalVariables,
@@ -11,6 +10,7 @@ import {
11
10
  MAX_NEW_NULLIFIERS_PER_TX,
12
11
  MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
13
12
  MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
13
+ NULLIFIER_SUBTREE_HEIGHT,
14
14
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
15
15
  Proof,
16
16
  PublicDataUpdateRequest,
@@ -138,7 +138,7 @@ describe('sequencer/solo_block_builder', () => {
138
138
  await expectsDb.batchInsert(
139
139
  MerkleTreeId.NULLIFIER_TREE,
140
140
  flatMap(txs, tx => tx.data.end.newNullifiers.map(x => x.toBuffer())),
141
- BaseRollupInputs.NULLIFIER_SUBTREE_HEIGHT,
141
+ NULLIFIER_SUBTREE_HEIGHT,
142
142
  );
143
143
  for (const write of txs.flatMap(tx => tx.data.end.publicDataUpdateRequests)) {
144
144
  await expectsDb.updateLeaf(MerkleTreeId.PUBLIC_DATA_TREE, write.newValue.toBuffer(), write.leafIndex.value);
@@ -384,7 +384,7 @@ describe('sequencer/solo_block_builder', () => {
384
384
 
385
385
  const [l2Block] = await builder.buildL2Block(globalVariables, txs, l1ToL2Messages);
386
386
  expect(l2Block.number).toEqual(blockNumber);
387
- }, 20_000);
387
+ }, 40_000);
388
388
 
389
389
  // This test specifically tests nullifier values which previously caused e2e_private_token test to fail
390
390
  it('e2e_private_token edge case regression test on nullifier values', async () => {
@@ -411,7 +411,7 @@ describe('sequencer/solo_block_builder', () => {
411
411
  await builderDb.batchInsert(
412
412
  MerkleTreeId.NULLIFIER_TREE,
413
413
  updateVals.map(v => toBufferBE(v, 32)),
414
- BaseRollupInputs.NULLIFIER_SUBTREE_HEIGHT,
414
+ NULLIFIER_SUBTREE_HEIGHT,
415
415
  );
416
416
 
417
417
  const [l2Block] = await builder.buildL2Block(globalVariables, txs, mockL1ToL2Messages);
@@ -2,17 +2,29 @@ import {
2
2
  AppendOnlyTreeSnapshot,
3
3
  BaseOrMergeRollupPublicInputs,
4
4
  BaseRollupInputs,
5
+ CONTRACT_SUBTREE_HEIGHT,
6
+ CONTRACT_SUBTREE_SIBLING_PATH_LENGTH,
5
7
  CircuitsWasm,
6
8
  ConstantRollupData,
7
9
  GlobalVariables,
8
10
  HISTORIC_BLOCKS_TREE_HEIGHT,
9
11
  L1_TO_L2_MSG_SUBTREE_HEIGHT,
10
12
  L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
13
+ MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP,
14
+ MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP,
15
+ MAX_PUBLIC_DATA_READS_PER_TX,
16
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_BASE_ROLLUP,
17
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
11
18
  MembershipWitness,
12
19
  MergeRollupInputs,
20
+ NULLIFIER_SUBTREE_HEIGHT,
21
+ NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH,
13
22
  NULLIFIER_TREE_HEIGHT,
14
23
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
15
24
  NullifierLeafPreimage,
25
+ PRIVATE_DATA_SUBTREE_HEIGHT,
26
+ PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH,
27
+ PUBLIC_DATA_TREE_HEIGHT,
16
28
  PreviousKernelData,
17
29
  PreviousRollupData,
18
30
  Proof,
@@ -593,22 +605,38 @@ export class SoloBlockBuilder implements BlockBuilder {
593
605
  }
594
606
 
595
607
  protected async processPublicDataUpdateRequests(tx: ProcessedTx) {
596
- const newPublicDataUpdateRequestsSiblingPaths: Fr[][] = [];
597
- for (const publicDataUpdateRequest of tx.data.end.publicDataUpdateRequests) {
598
- const index = publicDataUpdateRequest.leafIndex.value;
608
+ const newPublicDataUpdateRequestsSiblingPaths: Tuple<
609
+ Tuple<Fr, typeof PUBLIC_DATA_TREE_HEIGHT>,
610
+ typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
611
+ > = makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, () => makeTuple(PUBLIC_DATA_TREE_HEIGHT, Fr.zero));
612
+ for (const i in tx.data.end.publicDataUpdateRequests) {
613
+ const index = tx.data.end.publicDataUpdateRequests[i].leafIndex.value;
614
+ await this.db.updateLeaf(
615
+ MerkleTreeId.PUBLIC_DATA_TREE,
616
+ tx.data.end.publicDataUpdateRequests[i].newValue.toBuffer(),
617
+ index,
618
+ );
599
619
  const path = await this.db.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, index);
600
- await this.db.updateLeaf(MerkleTreeId.PUBLIC_DATA_TREE, publicDataUpdateRequest.newValue.toBuffer(), index);
601
- newPublicDataUpdateRequestsSiblingPaths.push(path.toFieldArray());
620
+ const array = path.toFieldArray();
621
+ newPublicDataUpdateRequestsSiblingPaths[i] = makeTuple(PUBLIC_DATA_TREE_HEIGHT, j =>
622
+ j < array.length ? array[j] : Fr.ZERO,
623
+ );
602
624
  }
603
625
  return newPublicDataUpdateRequestsSiblingPaths;
604
626
  }
605
627
 
606
628
  protected async getPublicDataReadsSiblingPaths(tx: ProcessedTx) {
607
- const newPublicDataReadsSiblingPaths: Fr[][] = [];
608
- for (const publicDataRead of tx.data.end.publicDataReads) {
609
- const index = publicDataRead.leafIndex.value;
629
+ const newPublicDataReadsSiblingPaths: Tuple<
630
+ Tuple<Fr, typeof PUBLIC_DATA_TREE_HEIGHT>,
631
+ typeof MAX_PUBLIC_DATA_READS_PER_TX
632
+ > = makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, () => makeTuple(PUBLIC_DATA_TREE_HEIGHT, Fr.zero));
633
+ for (const i in tx.data.end.publicDataReads) {
634
+ const index = tx.data.end.publicDataReads[i].leafIndex.value;
610
635
  const path = await this.db.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, index);
611
- newPublicDataReadsSiblingPaths.push(path.toFieldArray());
636
+ const array = path.toFieldArray();
637
+ newPublicDataReadsSiblingPaths[i] = makeTuple(PUBLIC_DATA_TREE_HEIGHT, j =>
638
+ j < array.length ? array[j] : Fr.ZERO,
639
+ );
612
640
  }
613
641
  return newPublicDataReadsSiblingPaths;
614
642
  }
@@ -626,13 +654,22 @@ export class SoloBlockBuilder implements BlockBuilder {
626
654
  const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE);
627
655
 
628
656
  // Get the subtree sibling paths for the circuit
629
- const newCommitmentsSubtreeSiblingPath = await this.getSubtreeSiblingPath(
657
+ const newCommitmentsSubtreeSiblingPathArray = await this.getSubtreeSiblingPath(
630
658
  MerkleTreeId.PRIVATE_DATA_TREE,
631
- BaseRollupInputs.PRIVATE_DATA_SUBTREE_HEIGHT,
659
+ PRIVATE_DATA_SUBTREE_HEIGHT,
632
660
  );
633
- const newContractsSubtreeSiblingPath = await this.getSubtreeSiblingPath(
661
+
662
+ const newCommitmentsSubtreeSiblingPath = makeTuple(PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH, i =>
663
+ i < newCommitmentsSubtreeSiblingPathArray.length ? newCommitmentsSubtreeSiblingPathArray[i] : Fr.ZERO,
664
+ );
665
+
666
+ const newContractsSubtreeSiblingPathArray = await this.getSubtreeSiblingPath(
634
667
  MerkleTreeId.CONTRACT_TREE,
635
- BaseRollupInputs.CONTRACT_SUBTREE_HEIGHT,
668
+ CONTRACT_SUBTREE_HEIGHT,
669
+ );
670
+
671
+ const newContractsSubtreeSiblingPath = makeTuple(CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, i =>
672
+ i < newContractsSubtreeSiblingPathArray.length ? newContractsSubtreeSiblingPathArray[i] : Fr.ZERO,
636
673
  );
637
674
 
638
675
  // Update the contract and private data trees with the new items being inserted to get the new roots
@@ -658,11 +695,17 @@ export class SoloBlockBuilder implements BlockBuilder {
658
695
  const rightPublicDataReadSiblingPaths = await this.getPublicDataReadsSiblingPaths(right);
659
696
  const rightPublicDataUpdateRequestsSiblingPaths = await this.processPublicDataUpdateRequests(right);
660
697
 
661
- const newPublicDataReadsSiblingPaths = [...leftPublicDataReadSiblingPaths, ...rightPublicDataReadSiblingPaths];
662
- const newPublicDataUpdateRequestsSiblingPaths = [
663
- ...leftPublicDataUpdateRequestsSiblingPaths,
664
- ...rightPublicDataUpdateRequestsSiblingPaths,
665
- ];
698
+ const newPublicDataReadsSiblingPaths = makeTuple(MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP, i =>
699
+ i < MAX_PUBLIC_DATA_READS_PER_TX
700
+ ? leftPublicDataReadSiblingPaths[i]
701
+ : rightPublicDataReadSiblingPaths[i - MAX_PUBLIC_DATA_READS_PER_TX],
702
+ );
703
+
704
+ const newPublicDataUpdateRequestsSiblingPaths = makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_BASE_ROLLUP, i =>
705
+ i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
706
+ ? leftPublicDataUpdateRequestsSiblingPaths[i]
707
+ : rightPublicDataUpdateRequestsSiblingPaths[i - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX],
708
+ );
666
709
 
667
710
  // Update the nullifier tree, capturing the low nullifier info for each individual operation
668
711
  const newNullifiers = [...left.data.end.newNullifiers, ...right.data.end.newNullifiers];
@@ -670,7 +713,7 @@ export class SoloBlockBuilder implements BlockBuilder {
670
713
  const [nullifierWitnessLeaves, newNullifiersSubtreeSiblingPath] = await this.db.batchInsert(
671
714
  MerkleTreeId.NULLIFIER_TREE,
672
715
  newNullifiers.map(fr => fr.toBuffer()),
673
- BaseRollupInputs.NULLIFIER_SUBTREE_HEIGHT,
716
+ NULLIFIER_SUBTREE_HEIGHT,
674
717
  );
675
718
  if (nullifierWitnessLeaves === undefined) {
676
719
  throw new Error(`Could not craft nullifier batch insertion proofs`);
@@ -682,6 +725,8 @@ export class SoloBlockBuilder implements BlockBuilder {
682
725
  MembershipWitness.fromBufferArray(l.index, assertLength(l.siblingPath.toBufferArray(), NULLIFIER_TREE_HEIGHT)),
683
726
  );
684
727
 
728
+ const newNullifiersSubtreeSiblingPathArray = newNullifiersSubtreeSiblingPath.toFieldArray();
729
+
685
730
  return BaseRollupInputs.from({
686
731
  constants,
687
732
  startNullifierTreeSnapshot,
@@ -691,14 +736,25 @@ export class SoloBlockBuilder implements BlockBuilder {
691
736
  startHistoricBlocksTreeSnapshot,
692
737
  newCommitmentsSubtreeSiblingPath,
693
738
  newContractsSubtreeSiblingPath,
694
- newNullifiersSubtreeSiblingPath: newNullifiersSubtreeSiblingPath.toFieldArray(),
739
+ newNullifiersSubtreeSiblingPath: makeTuple(NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, i =>
740
+ i < newNullifiersSubtreeSiblingPathArray.length ? newNullifiersSubtreeSiblingPathArray[i] : Fr.ZERO,
741
+ ),
695
742
  newPublicDataUpdateRequestsSiblingPaths,
696
743
  newPublicDataReadsSiblingPaths,
697
- lowNullifierLeafPreimages: nullifierWitnessLeaves.map(
698
- ({ leafData }) =>
699
- new NullifierLeafPreimage(new Fr(leafData.value), new Fr(leafData.nextValue), Number(leafData.nextIndex)),
744
+ lowNullifierLeafPreimages: makeTuple(MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, i =>
745
+ i < nullifierWitnessLeaves.length
746
+ ? new NullifierLeafPreimage(
747
+ new Fr(nullifierWitnessLeaves[i].leafData.value),
748
+ new Fr(nullifierWitnessLeaves[i].leafData.nextValue),
749
+ Number(nullifierWitnessLeaves[i].leafData.nextIndex),
750
+ )
751
+ : new NullifierLeafPreimage(Fr.ZERO, Fr.ZERO, 0),
752
+ ),
753
+ lowNullifierMembershipWitness: makeTuple(MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, i =>
754
+ i < lowNullifierMembershipWitnesses.length
755
+ ? lowNullifierMembershipWitnesses[i]
756
+ : this.makeEmptyMembershipWitness(NULLIFIER_TREE_HEIGHT),
700
757
  ),
701
- lowNullifierMembershipWitness: lowNullifierMembershipWitnesses,
702
758
  kernelData: [this.getKernelDataFor(left), this.getKernelDataFor(right)],
703
759
  historicBlocksTreeRootMembershipWitnesses: [
704
760
  await this.getHistoricTreesMembershipWitnessFor(left),
@@ -1,7 +1,7 @@
1
1
  import { createEthereumChain } from '@aztec/ethereum';
2
2
  import { createDebugLogger } from '@aztec/foundation/log';
3
3
  import { ContractDeploymentEmitterAbi, RollupAbi } from '@aztec/l1-artifacts';
4
- import { ExtendedContractData } from '@aztec/types';
4
+ import { BLOB_SIZE_IN_BYTES, ExtendedContractData } from '@aztec/types';
5
5
 
6
6
  import {
7
7
  GetContractReturnType,
@@ -141,6 +141,9 @@ export class ViemTxSender implements L1PublisherTxSender {
141
141
  `0x${extendedContractData.bytecode.toString('hex')}`,
142
142
  ] as const;
143
143
 
144
+ const codeSize = extendedContractData.bytecode.length;
145
+ this.log(`Bytecode is ${codeSize} bytes and require ${codeSize / BLOB_SIZE_IN_BYTES} blobs`);
146
+
144
147
  const gas = await this.contractDeploymentEmitterContract.estimateGas.emitContractDeployment(args, {
145
148
  account: this.account,
146
149
  });
@@ -147,7 +147,11 @@ export class Sequencer {
147
147
  await this.p2pClient.deleteTxs(await Tx.getHashes(failedTxData));
148
148
  }
149
149
 
150
- if (processedTxs.length === 0) {
150
+ // Only accept processed transactions that are not double-spends
151
+ // public functions emitting nullifiers would pass earlier check but fail here
152
+ const processedValidTxs = await this.takeValidProcessedTxs(processedTxs);
153
+
154
+ if (processedValidTxs.length === 0) {
151
155
  this.log('No txs processed correctly to build block. Exiting');
152
156
  return;
153
157
  }
@@ -158,16 +162,16 @@ export class Sequencer {
158
162
  this.log('Successfully retrieved L1 to L2 messages from contract');
159
163
 
160
164
  // Build the new block by running the rollup circuits
161
- this.log(`Assembling block with txs ${processedTxs.map(tx => tx.hash).join(', ')}`);
165
+ this.log(`Assembling block with txs ${processedValidTxs.map(tx => tx.hash).join(', ')}`);
162
166
 
163
167
  const emptyTx = await processor.makeEmptyProcessedTx();
164
- const block = await this.buildBlock(processedTxs, l1ToL2Messages, emptyTx, newGlobalVariables);
168
+ const block = await this.buildBlock(processedValidTxs, l1ToL2Messages, emptyTx, newGlobalVariables);
165
169
  this.log(`Assembled block ${block.number}`);
166
170
 
167
171
  await this.publishExtendedContractData(validTxs, block);
168
172
 
169
173
  await this.publishL2Block(block);
170
- this.log.info(`Submitted rollup block ${block.number} with ${processedTxs.length} transactions`);
174
+ this.log.info(`Submitted rollup block ${block.number} with ${processedValidTxs.length} transactions`);
171
175
  } catch (err) {
172
176
  this.log.error(err);
173
177
  this.log.error(`Rolling back world state DB`);
@@ -249,6 +253,13 @@ export class Sequencer {
249
253
  return validTxs;
250
254
  }
251
255
 
256
+ protected async takeValidProcessedTxs(txs: ProcessedTx[]) {
257
+ const isDoubleSpends = await Promise.all(txs.map(async tx => await this.isTxDoubleSpend(tx as unknown as Tx)));
258
+ const doubleSpends = txs.filter((tx, index) => isDoubleSpends[index]).map(tx => tx.hash);
259
+ await this.p2pClient.deleteTxs(doubleSpends);
260
+ return txs.filter((tx, index) => !isDoubleSpends[index]);
261
+ }
262
+
252
263
  /**
253
264
  * Returns whether the previous block sent has been mined, and all dependencies have caught up with it.
254
265
  * @returns Boolean indicating if our dependencies are synced to the latest block.
@@ -1,5 +1,4 @@
1
1
  import {
2
- CommitmentDataOracleInputs,
3
2
  CommitmentsDB,
4
3
  MessageLoadOracleInputs,
5
4
  PublicContractsDB,
@@ -7,7 +6,6 @@ import {
7
6
  PublicStateDB,
8
7
  } from '@aztec/acir-simulator';
9
8
  import { AztecAddress, CircuitsWasm, EthAddress, Fr, FunctionSelector, HistoricBlockData } from '@aztec/circuits.js';
10
- import { siloCommitment } from '@aztec/circuits.js/abis';
11
9
  import { ContractDataSource, L1ToL2MessageSource, MerkleTreeId } from '@aztec/types';
12
10
  import { MerkleTreeOperations, computePublicDataTreeLeafIndex } from '@aztec/world-state';
13
11
 
@@ -100,19 +98,7 @@ export class WorldStateDB implements CommitmentsDB {
100
98
  };
101
99
  }
102
100
 
103
- public async getCommitmentOracle(address: AztecAddress, innerCommitment: Fr): Promise<CommitmentDataOracleInputs> {
104
- const siloedCommitment = siloCommitment(await CircuitsWasm.get(), address, innerCommitment);
105
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): shoild be
106
- // unique commitment that exists in tree (should be siloed and then made unique via
107
- // nonce). Once public kernel or base rollup circuit injects nonces, this can be updated
108
- // to use uniqueSiloedCommitment.
109
- const index = (await this.db.findLeafIndex(MerkleTreeId.PRIVATE_DATA_TREE, siloedCommitment.toBuffer()))!;
110
- const siblingPath = await this.db.getSiblingPath(MerkleTreeId.PRIVATE_DATA_TREE, index);
111
-
112
- return {
113
- commitment: siloedCommitment,
114
- siblingPath: siblingPath.toFieldArray(),
115
- index,
116
- };
101
+ public async getCommitmentIndex(commitment: Fr): Promise<bigint | undefined> {
102
+ return await this.db.findLeafIndex(MerkleTreeId.PRIVATE_DATA_TREE, commitment.toBuffer());
117
103
  }
118
104
  }
@@ -4,9 +4,9 @@ import {
4
4
  CircuitError,
5
5
  CircuitsWasm,
6
6
  MergeRollupInputs,
7
- RollupWasmWrapper,
8
7
  RootRollupInputs,
9
8
  RootRollupPublicInputs,
9
+ baseRollupSim,
10
10
  mergeRollupSim,
11
11
  rootRollupSim,
12
12
  } from '@aztec/circuits.js';
@@ -17,11 +17,9 @@ import { RollupSimulator } from './index.js';
17
17
  * Implements the rollup circuit simulator using the wasm circuits implementation.
18
18
  */
19
19
  export class WasmRollupCircuitSimulator implements RollupSimulator {
20
- private rollupWasmWrapper: RollupWasmWrapper;
21
20
  private wasm: CircuitsWasm;
22
21
 
23
22
  constructor(wasm: CircuitsWasm) {
24
- this.rollupWasmWrapper = new RollupWasmWrapper(wasm);
25
23
  this.wasm = wasm;
26
24
  }
27
25
 
@@ -39,7 +37,12 @@ export class WasmRollupCircuitSimulator implements RollupSimulator {
39
37
  * @returns The public inputs as outputs of the simulation.
40
38
  */
41
39
  baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
42
- return Promise.resolve(this.rollupWasmWrapper.simulateBaseRollup(input));
40
+ const result = baseRollupSim(this.wasm, input);
41
+ if (result instanceof CircuitError) {
42
+ throw new CircuitError(result.code, result.message);
43
+ }
44
+
45
+ return Promise.resolve(result);
43
46
  }
44
47
  /**
45
48
  * Simulates the merge rollup circuit from its inputs.