@aztec/txe 3.0.0-nightly.20251214 → 3.0.0-nightly.20251217

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 (39) hide show
  1. package/dest/index.d.ts +1 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +3 -2
  4. package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
  5. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.js +3 -5
  7. package/dest/oracle/txe_oracle_top_level_context.d.ts +1 -1
  8. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_top_level_context.js +13 -14
  10. package/dest/rpc_translator.d.ts +3 -3
  11. package/dest/rpc_translator.d.ts.map +1 -1
  12. package/dest/rpc_translator.js +2 -2
  13. package/dest/state_machine/archiver.d.ts +13 -7
  14. package/dest/state_machine/archiver.d.ts.map +1 -1
  15. package/dest/state_machine/archiver.js +83 -15
  16. package/dest/state_machine/dummy_p2p_client.d.ts +1 -1
  17. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  18. package/dest/state_machine/dummy_p2p_client.js +3 -1
  19. package/dest/state_machine/index.d.ts +5 -5
  20. package/dest/state_machine/index.d.ts.map +1 -1
  21. package/dest/state_machine/index.js +13 -19
  22. package/dest/txe_session.d.ts +1 -1
  23. package/dest/txe_session.d.ts.map +1 -1
  24. package/dest/txe_session.js +10 -9
  25. package/dest/util/encoding.d.ts +601 -2
  26. package/dest/util/encoding.d.ts.map +1 -1
  27. package/dest/utils/block_creation.d.ts +16 -2
  28. package/dest/utils/block_creation.d.ts.map +1 -1
  29. package/dest/utils/block_creation.js +22 -1
  30. package/package.json +15 -15
  31. package/src/index.ts +14 -11
  32. package/src/oracle/txe_oracle_public_context.ts +3 -8
  33. package/src/oracle/txe_oracle_top_level_context.ts +16 -38
  34. package/src/rpc_translator.ts +2 -2
  35. package/src/state_machine/archiver.ts +106 -21
  36. package/src/state_machine/dummy_p2p_client.ts +3 -1
  37. package/src/state_machine/index.ts +18 -17
  38. package/src/txe_session.ts +19 -17
  39. package/src/utils/block_creation.ts +31 -1
@@ -7,7 +7,7 @@ import {
7
7
  import { BlockNumber } from '@aztec/foundation/branded-types';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/curves/bn254';
10
- import { L2BlockHeader } from '@aztec/stdlib/block';
10
+ import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
11
11
  import { makeContentCommitment } from '@aztec/stdlib/testing';
12
12
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
13
13
  import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
@@ -62,3 +62,33 @@ export async function makeTXEBlockHeader(
62
62
  Fr.ZERO,
63
63
  );
64
64
  }
65
+
66
+ /**
67
+ * Creates an L2Block with proper archive chaining.
68
+ * This function:
69
+ * 1. Gets the current archive state as lastArchive for the header
70
+ * 2. Creates the block header
71
+ * 3. Updates the archive tree with the header hash
72
+ * 4. Gets the new archive state for the block's archive
73
+ *
74
+ * @param worldTrees - The world trees to read/write from
75
+ * @param globalVariables - Global variables for the block
76
+ * @param txEffects - Transaction effects to include in the block
77
+ * @returns The created L2Block with proper archive chaining
78
+ */
79
+ export async function makeTXEBlock(
80
+ worldTrees: MerkleTreeWriteOperations,
81
+ globalVariables: GlobalVariables,
82
+ txEffects: TxEffect[],
83
+ ): Promise<L2Block> {
84
+ const header = await makeTXEBlockHeader(worldTrees, globalVariables);
85
+
86
+ // Update the archive tree with this block's header hash
87
+ await worldTrees.updateArchive(header.toBlockHeader());
88
+
89
+ // Get the new archive state after updating
90
+ const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
91
+ const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
92
+
93
+ return new L2Block(newArchive, header, new Body(txEffects));
94
+ }