@aztec/txe 0.0.1-commit.9593d84 → 0.0.1-commit.96bb3f7

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 (80) hide show
  1. package/dest/constants.d.ts +4 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +3 -0
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +3 -2
  7. package/dest/oracle/interfaces.d.ts +9 -6
  8. package/dest/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +4 -6
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +21 -12
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  14. package/dest/oracle/txe_oracle_top_level_context.js +93 -62
  15. package/dest/rpc_translator.d.ts +11 -5
  16. package/dest/rpc_translator.d.ts.map +1 -1
  17. package/dest/rpc_translator.js +57 -15
  18. package/dest/state_machine/archiver.d.ts +29 -11
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +128 -17
  21. package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +16 -11
  24. package/dest/state_machine/global_variable_builder.d.ts +6 -5
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +13 -1
  27. package/dest/state_machine/index.d.ts +5 -5
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +14 -20
  30. package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
  31. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  32. package/dest/state_machine/mock_epoch_cache.js +3 -0
  33. package/dest/state_machine/synchronizer.d.ts +5 -4
  34. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  35. package/dest/state_machine/synchronizer.js +5 -4
  36. package/dest/txe_session.d.ts +19 -13
  37. package/dest/txe_session.d.ts.map +1 -1
  38. package/dest/txe_session.js +76 -45
  39. package/dest/util/encoding.d.ts +610 -11
  40. package/dest/util/encoding.d.ts.map +1 -1
  41. package/dest/util/encoding.js +1 -1
  42. package/dest/util/txe_account_store.d.ts +10 -0
  43. package/dest/util/txe_account_store.d.ts.map +1 -0
  44. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  45. package/dest/util/txe_contract_store.d.ts +12 -0
  46. package/dest/util/txe_contract_store.d.ts.map +1 -0
  47. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  48. package/dest/util/txe_public_contract_data_source.d.ts +7 -6
  49. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  50. package/dest/util/txe_public_contract_data_source.js +11 -11
  51. package/dest/utils/block_creation.d.ts +19 -4
  52. package/dest/utils/block_creation.d.ts.map +1 -1
  53. package/dest/utils/block_creation.js +24 -4
  54. package/dest/utils/tx_effect_creation.d.ts +4 -3
  55. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  56. package/dest/utils/tx_effect_creation.js +1 -1
  57. package/package.json +17 -17
  58. package/src/constants.ts +4 -0
  59. package/src/index.ts +15 -12
  60. package/src/oracle/interfaces.ts +8 -5
  61. package/src/oracle/txe_oracle_public_context.ts +6 -11
  62. package/src/oracle/txe_oracle_top_level_context.ts +139 -88
  63. package/src/rpc_translator.ts +82 -12
  64. package/src/state_machine/archiver.ts +168 -26
  65. package/src/state_machine/dummy_p2p_client.ts +21 -14
  66. package/src/state_machine/global_variable_builder.ts +21 -4
  67. package/src/state_machine/index.ts +19 -18
  68. package/src/state_machine/mock_epoch_cache.ts +4 -0
  69. package/src/state_machine/synchronizer.ts +8 -7
  70. package/src/txe_session.ts +166 -75
  71. package/src/util/encoding.ts +1 -1
  72. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  73. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  74. package/src/util/txe_public_contract_data_source.ts +13 -12
  75. package/src/utils/block_creation.ts +36 -5
  76. package/src/utils/tx_effect_creation.ts +3 -2
  77. package/dest/util/txe_account_data_provider.d.ts +0 -10
  78. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  79. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  80. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -4,10 +4,10 @@ import {
4
4
  NULLIFIER_SUBTREE_HEIGHT,
5
5
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
6
6
  } from '@aztec/constants';
7
+ import { BlockNumber } from '@aztec/foundation/branded-types';
7
8
  import { padArrayEnd } from '@aztec/foundation/collection';
8
- import { Fr } from '@aztec/foundation/fields';
9
- import { L2BlockHeader } from '@aztec/stdlib/block';
10
- import { makeContentCommitment } from '@aztec/stdlib/testing';
9
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
+ import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
11
11
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
12
12
  import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
13
13
 
@@ -16,7 +16,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
16
16
  * @param blockNumber The number for the block in which there is a single transaction.
17
17
  * @returns The transaction request hash.
18
18
  */
19
- export function getSingleTxBlockRequestHash(blockNumber: number): Fr {
19
+ export function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr {
20
20
  return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
21
21
  }
22
22
 
@@ -52,7 +52,8 @@ export async function makeTXEBlockHeader(
52
52
 
53
53
  return new L2BlockHeader(
54
54
  new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
55
- makeContentCommitment(),
55
+ Fr.ZERO,
56
+ Fr.ZERO,
56
57
  stateReference,
57
58
  globalVariables,
58
59
  Fr.ZERO,
@@ -61,3 +62,33 @@ export async function makeTXEBlockHeader(
61
62
  Fr.ZERO,
62
63
  );
63
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
+ }
@@ -1,4 +1,5 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
3
4
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
4
5
  import { TxEffect, TxHash } from '@aztec/stdlib/tx';
@@ -6,7 +7,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
6
7
  export async function makeTxEffect(
7
8
  noteCache: ExecutionNoteCache,
8
9
  protocolNullifier: Fr,
9
- txBlockNumber: number,
10
+ txBlockNumber: BlockNumber,
10
11
  ): Promise<TxEffect> {
11
12
  const txEffect = TxEffect.empty();
12
13
 
@@ -1,10 +0,0 @@
1
- import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import { CompleteAddress } from '@aztec/stdlib/contract';
4
- export declare class TXEAccountDataProvider {
5
- #private;
6
- constructor(store: AztecAsyncKVStore);
7
- getAccount(key: AztecAddress): Promise<CompleteAddress>;
8
- setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
9
- }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX2FjY291bnRfZGF0YV9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsc0JBQXNCOztJQUdqQyxZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"txe_account_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAsB;;IAGjC,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
@@ -1,12 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
- import { Fr } from '@aztec/aztec.js/fields';
3
- import { ContractDataProvider } from '@aztec/pxe/server';
4
- export type ContractArtifactWithHash = ContractArtifact & {
5
- artifactHash: Fr;
6
- };
7
- export declare class TXEContractDataProvider extends ContractDataProvider {
8
- #private;
9
- addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
10
- getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
11
- }
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X2RhdGFfcHJvdmlkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9jb250cmFjdF9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVDLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRXpELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxn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