@aztec/aztec 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2

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 (46) hide show
  1. package/dest/bin/index.js +2 -0
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +6 -1
  5. package/dest/cli/cli.d.ts +1 -1
  6. package/dest/cli/cli.d.ts.map +1 -1
  7. package/dest/cli/cli.js +9 -53
  8. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  9. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  10. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  11. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  12. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  13. package/dest/cli/cmds/start_archiver.js +5 -7
  14. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  15. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  16. package/dest/cli/cmds/start_prover_agent.js +1 -1
  17. package/dest/cli/util.js +1 -1
  18. package/dest/local-network/local-network.d.ts +1 -1
  19. package/dest/local-network/local-network.d.ts.map +1 -1
  20. package/dest/local-network/local-network.js +18 -5
  21. package/dest/testing/cheat_codes.d.ts +3 -1
  22. package/dest/testing/cheat_codes.d.ts.map +1 -1
  23. package/dest/testing/epoch_test_settler.d.ts +17 -0
  24. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  25. package/dest/testing/epoch_test_settler.js +52 -0
  26. package/dest/testing/index.d.ts +2 -1
  27. package/dest/testing/index.d.ts.map +1 -1
  28. package/dest/testing/index.js +1 -0
  29. package/package.json +37 -35
  30. package/scripts/aztec.sh +63 -0
  31. package/scripts/compile.sh +44 -0
  32. package/scripts/extract_function.js +47 -0
  33. package/scripts/flamegraph.sh +59 -0
  34. package/scripts/init.sh +35 -0
  35. package/scripts/new.sh +59 -0
  36. package/scripts/setup_project.sh +31 -0
  37. package/src/bin/index.ts +2 -0
  38. package/src/cli/aztec_start_action.ts +5 -0
  39. package/src/cli/cli.ts +12 -56
  40. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  41. package/src/cli/cmds/start_archiver.ts +2 -13
  42. package/src/cli/cmds/start_prover_agent.ts +1 -9
  43. package/src/cli/util.ts +1 -1
  44. package/src/local-network/local-network.ts +26 -10
  45. package/src/testing/epoch_test_settler.ts +59 -0
  46. package/src/testing/index.ts +1 -0
@@ -0,0 +1,59 @@
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
+ import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
+ import { EpochMonitor } from '@aztec/prover-node';
5
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
6
+ import { computeL2ToL1MembershipWitnessFromMessagesInEpoch } from '@aztec/stdlib/messaging';
7
+
8
+ export class EpochTestSettler {
9
+ private rollupCheatCodes: RollupCheatCodes;
10
+ private epochMonitor?: EpochMonitor;
11
+
12
+ constructor(
13
+ cheatcodes: EthCheatCodes,
14
+ rollupAddress: EthAddress,
15
+ private l2BlockSource: L2BlockSource,
16
+ private options: { pollingIntervalMs: number; provingDelayMs?: number },
17
+ ) {
18
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
19
+ }
20
+
21
+ async start() {
22
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
23
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
24
+ this.epochMonitor.start(this);
25
+ }
26
+
27
+ async stop() {
28
+ await this.epochMonitor?.stop();
29
+ }
30
+
31
+ async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
32
+ const blocks = await this.l2BlockSource.getBlocksForEpoch(epoch);
33
+ const messagesInEpoch: Fr[][][][] = [];
34
+ let previousSlotNumber = SlotNumber.ZERO;
35
+ let checkpointIndex = -1;
36
+ for (const block of blocks) {
37
+ const slotNumber = block.header.globalVariables.slotNumber;
38
+ if (slotNumber !== previousSlotNumber) {
39
+ checkpointIndex++;
40
+ messagesInEpoch[checkpointIndex] = [];
41
+ previousSlotNumber = slotNumber;
42
+ }
43
+ messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
44
+ }
45
+
46
+ const [firstMessage] = messagesInEpoch.flat(3);
47
+ if (firstMessage) {
48
+ const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
49
+ await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
50
+ }
51
+
52
+ // Mark the blocks as proven.
53
+ for (const block of blocks) {
54
+ await this.rollupCheatCodes.markAsProven(block.number);
55
+ }
56
+
57
+ return true;
58
+ }
59
+ }
@@ -1,3 +1,4 @@
1
1
  export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
2
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
3
  export { CheatCodes } from './cheat_codes.js';
4
+ export { EpochTestSettler } from './epoch_test_settler.js';