@aztec/txe 0.0.0-test.1 → 0.0.1-commit.017a351

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 (182) hide show
  1. package/dest/ContractClassRegistry-PII7Q556.js +3 -0
  2. package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
  3. package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
  4. package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
  5. package/dest/FeeJuice-TQV5AQK7.js +3 -0
  6. package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
  7. package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
  8. package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
  9. package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
  10. package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
  11. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  12. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  13. package/dest/bin/check_txe_oracle_version.js +61 -0
  14. package/dest/bin/index.d.ts +1 -1
  15. package/dest/bin/index.js +3 -29
  16. package/dest/bin/index.js.map +7 -0
  17. package/dest/bin/oracle_test_server.d.ts +3 -0
  18. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  19. package/dest/bin/oracle_test_server.js +41 -0
  20. package/dest/chunk-BA54BEZH.js +265 -0
  21. package/dest/chunk-BA54BEZH.js.map +7 -0
  22. package/dest/chunk-BJVAAXNA.js +3 -0
  23. package/dest/chunk-BJVAAXNA.js.map +7 -0
  24. package/dest/chunk-ZKW35DT6.js +304 -0
  25. package/dest/chunk-ZKW35DT6.js.map +7 -0
  26. package/dest/constants.d.ts +7 -0
  27. package/dest/constants.d.ts.map +1 -0
  28. package/dest/constants.js +10 -0
  29. package/dest/dispatcher_pool.d.ts +67 -0
  30. package/dest/dispatcher_pool.d.ts.map +1 -0
  31. package/dest/dispatcher_pool.js +284 -0
  32. package/dest/index.d.ts +185 -7
  33. package/dest/index.d.ts.map +1 -1
  34. package/dest/index.js +76 -132
  35. package/dest/metafile.json +38691 -0
  36. package/dest/msgpackr_fr_extension.d.ts +2 -0
  37. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  38. package/dest/msgpackr_fr_extension.js +21 -0
  39. package/dest/oracle/interfaces.d.ts +83 -0
  40. package/dest/oracle/interfaces.d.ts.map +1 -0
  41. package/dest/oracle/interfaces.js +3 -0
  42. package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
  43. package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
  44. package/dest/oracle/test-resolver/fixtures.js +39 -0
  45. package/dest/oracle/test-resolver/index.d.ts +9 -0
  46. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  47. package/dest/oracle/test-resolver/index.js +33 -0
  48. package/dest/oracle/test-resolver/resolver.d.ts +34 -0
  49. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  50. package/dest/oracle/test-resolver/resolver.js +114 -0
  51. package/dest/oracle/txe_oracle_public_context.d.ts +58 -0
  52. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
  53. package/dest/oracle/txe_oracle_public_context.js +164 -0
  54. package/dest/oracle/txe_oracle_registry.d.ts +147 -0
  55. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  56. package/dest/oracle/txe_oracle_registry.js +562 -0
  57. package/dest/oracle/txe_oracle_top_level_context.d.ts +85 -0
  58. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
  59. package/dest/oracle/txe_oracle_top_level_context.js +634 -0
  60. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  61. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  62. package/dest/oracle/txe_oracle_version.js +14 -0
  63. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  64. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  65. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  66. package/dest/rpc_server.d.ts +14 -0
  67. package/dest/rpc_server.d.ts.map +1 -0
  68. package/dest/rpc_server.js +78 -0
  69. package/dest/rpc_translator.d.ts +120 -0
  70. package/dest/rpc_translator.d.ts.map +1 -0
  71. package/dest/rpc_translator.js +882 -0
  72. package/dest/server.bundle.js +3 -0
  73. package/dest/server.bundle.js.map +7 -0
  74. package/dest/state_machine/archiver.d.ts +32 -0
  75. package/dest/state_machine/archiver.d.ts.map +1 -0
  76. package/dest/state_machine/archiver.js +96 -0
  77. package/dest/state_machine/dummy_p2p_client.d.ts +65 -0
  78. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
  79. package/dest/state_machine/dummy_p2p_client.js +165 -0
  80. package/dest/state_machine/global_variable_builder.d.ts +16 -0
  81. package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
  82. package/dest/state_machine/global_variable_builder.js +28 -0
  83. package/dest/state_machine/index.d.ts +20 -0
  84. package/dest/state_machine/index.d.ts.map +1 -0
  85. package/dest/state_machine/index.js +86 -0
  86. package/dest/state_machine/mock_epoch_cache.d.ts +42 -0
  87. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
  88. package/dest/state_machine/mock_epoch_cache.js +85 -0
  89. package/dest/state_machine/synchronizer.d.ts +33 -0
  90. package/dest/state_machine/synchronizer.d.ts.map +1 -0
  91. package/dest/state_machine/synchronizer.js +59 -0
  92. package/dest/txe_session.d.ts +140 -0
  93. package/dest/txe_session.d.ts.map +1 -0
  94. package/dest/txe_session.js +499 -0
  95. package/dest/utils/block_creation.d.ts +28 -0
  96. package/dest/utils/block_creation.d.ts.map +1 -0
  97. package/dest/utils/block_creation.js +58 -0
  98. package/dest/utils/encoding.d.ts +191 -0
  99. package/dest/utils/encoding.d.ts.map +1 -0
  100. package/dest/utils/encoding.js +136 -0
  101. package/dest/utils/expected_failure_error.d.ts +4 -0
  102. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  103. package/dest/utils/tx_effect_creation.d.ts +5 -0
  104. package/dest/utils/tx_effect_creation.d.ts.map +1 -0
  105. package/dest/utils/tx_effect_creation.js +13 -0
  106. package/dest/utils/txe_account_store.d.ts +10 -0
  107. package/dest/utils/txe_account_store.d.ts.map +1 -0
  108. package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
  109. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  110. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  111. package/dest/utils/txe_artifact_resolver.js +161 -0
  112. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  113. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  114. package/dest/utils/txe_public_contract_data_source.js +48 -0
  115. package/dest/worker.bundle.js +3 -0
  116. package/dest/worker.bundle.js.map +7 -0
  117. package/dest/worker.d.ts +2 -0
  118. package/dest/worker.d.ts.map +1 -0
  119. package/dest/worker.js +92 -0
  120. package/package.json +52 -29
  121. package/src/bin/check_txe_oracle_version.ts +70 -0
  122. package/src/bin/index.ts +14 -4
  123. package/src/bin/oracle_test_server.ts +51 -0
  124. package/src/constants.ts +13 -0
  125. package/src/dispatcher_pool.ts +316 -0
  126. package/src/index.ts +113 -175
  127. package/src/msgpackr_fr_extension.ts +23 -0
  128. package/src/oracle/interfaces.ts +109 -0
  129. package/src/oracle/test-resolver/fixtures.ts +84 -0
  130. package/src/oracle/test-resolver/index.ts +45 -0
  131. package/src/oracle/test-resolver/resolver.ts +165 -0
  132. package/src/oracle/txe_oracle_public_context.ts +218 -0
  133. package/src/oracle/txe_oracle_registry.ts +401 -0
  134. package/src/oracle/txe_oracle_top_level_context.ts +898 -0
  135. package/src/oracle/txe_oracle_version.ts +17 -0
  136. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  137. package/src/rpc_server.ts +87 -0
  138. package/src/rpc_translator.ts +1103 -0
  139. package/src/state_machine/archiver.ts +119 -0
  140. package/src/state_machine/dummy_p2p_client.ts +247 -0
  141. package/src/state_machine/global_variable_builder.ts +53 -0
  142. package/src/state_machine/index.ts +135 -0
  143. package/src/state_machine/mock_epoch_cache.ts +107 -0
  144. package/src/state_machine/synchronizer.ts +88 -0
  145. package/src/txe_session.ts +799 -0
  146. package/src/utils/block_creation.ts +97 -0
  147. package/src/utils/encoding.ts +172 -0
  148. package/src/utils/tx_effect_creation.ts +30 -0
  149. package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
  150. package/src/utils/txe_artifact_resolver.ts +217 -0
  151. package/src/utils/txe_public_contract_data_source.ts +58 -0
  152. package/src/worker.ts +98 -0
  153. package/dest/node/txe_node.d.ts +0 -358
  154. package/dest/node/txe_node.d.ts.map +0 -1
  155. package/dest/node/txe_node.js +0 -504
  156. package/dest/oracle/txe_oracle.d.ts +0 -152
  157. package/dest/oracle/txe_oracle.d.ts.map +0 -1
  158. package/dest/oracle/txe_oracle.js +0 -833
  159. package/dest/txe_service/txe_service.d.ts +0 -212
  160. package/dest/txe_service/txe_service.d.ts.map +0 -1
  161. package/dest/txe_service/txe_service.js +0 -572
  162. package/dest/util/encoding.d.ts +0 -103
  163. package/dest/util/encoding.d.ts.map +0 -1
  164. package/dest/util/encoding.js +0 -76
  165. package/dest/util/expected_failure_error.d.ts +0 -4
  166. package/dest/util/expected_failure_error.d.ts.map +0 -1
  167. package/dest/util/txe_account_data_provider.d.ts +0 -10
  168. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  169. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  170. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  171. package/dest/util/txe_public_contract_data_source.js +0 -88
  172. package/dest/util/txe_world_state_db.d.ts +0 -14
  173. package/dest/util/txe_world_state_db.d.ts.map +0 -1
  174. package/dest/util/txe_world_state_db.js +0 -27
  175. package/src/node/txe_node.ts +0 -725
  176. package/src/oracle/txe_oracle.ts +0 -1241
  177. package/src/txe_service/txe_service.ts +0 -749
  178. package/src/util/encoding.ts +0 -92
  179. package/src/util/txe_public_contract_data_source.ts +0 -101
  180. package/src/util/txe_world_state_db.ts +0 -38
  181. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  182. /package/src/{util → utils}/expected_failure_error.ts +0 -0
@@ -0,0 +1,119 @@
1
+ import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
2
+ import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
3
+ import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import type { EthAddress } from '@aztec/foundation/eth-address';
6
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
7
+ import {
8
+ type CheckpointId,
9
+ GENESIS_BLOCK_HEADER_HASH,
10
+ type L2BlockId,
11
+ type L2TipId,
12
+ type L2Tips,
13
+ type ValidateCheckpointResult,
14
+ } from '@aztec/stdlib/block';
15
+ import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
16
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
17
+ import { BlockHeader } from '@aztec/stdlib/tx';
18
+
19
+ /**
20
+ * TXE Archiver implementation.
21
+ * Provides most of the endpoints needed by the node for reading from and writing to state,
22
+ * without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
23
+ */
24
+ export class TXEArchiver extends ArchiverDataSourceBase {
25
+ private readonly updater = new ArchiverDataStoreUpdater(this.stores);
26
+
27
+ constructor(db: AztecAsyncKVStore) {
28
+ super(
29
+ createArchiverDataStores(db, GENESIS_BLOCK_HEADER_HASH),
30
+ undefined,
31
+ BlockHeader.empty(),
32
+ GENESIS_BLOCK_HEADER_HASH,
33
+ new Fr(GENESIS_ARCHIVE_ROOT),
34
+ );
35
+ }
36
+
37
+ public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
38
+ await this.updater.addCheckpoints(checkpoints, result);
39
+ }
40
+
41
+ public getRollupAddress(): Promise<EthAddress> {
42
+ throw new Error('TXE Archiver does not implement "getRollupAddress"');
43
+ }
44
+
45
+ public getRegistryAddress(): Promise<EthAddress> {
46
+ throw new Error('TXE Archiver does not implement "getRegistryAddress"');
47
+ }
48
+
49
+ public getL1Constants(): Promise<L1RollupConstants> {
50
+ // The TXE has no L1, so it serves the empty constants (epochDuration=1) used throughout the TXE state machine
51
+ // (see mock_epoch_cache). The node calls this when assembling a mined tx receipt to derive the epoch number.
52
+ return Promise.resolve(EmptyL1RollupConstants);
53
+ }
54
+
55
+ public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
56
+ return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
57
+ }
58
+
59
+ public getL1Timestamp(): Promise<bigint | undefined> {
60
+ throw new Error('TXE Archiver does not implement "getL1Timestamp"');
61
+ }
62
+
63
+ public async getL2Tips(): Promise<L2Tips> {
64
+ // In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
65
+ // and 'finalized' to the latest block.
66
+ const latestBlockNumber = await this.stores.blocks.getLatestL2BlockNumber();
67
+ if (latestBlockNumber === 0) {
68
+ throw new Error('L2Tips requested from TXE Archiver but no block found');
69
+ }
70
+ const latestBlockData = await this.stores.blocks.getBlockData({ number: latestBlockNumber });
71
+ if (!latestBlockData) {
72
+ throw new Error('L2Tips requested from TXE Archiver but no block header found');
73
+ }
74
+
75
+ const number = latestBlockData.header.globalVariables.blockNumber;
76
+ const hash = latestBlockData.blockHash.toString();
77
+
78
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
79
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
80
+ const checkpoint = await this.stores.blocks.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
81
+ if (checkpoint.length === 0) {
82
+ throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
83
+ }
84
+ const blockId: L2BlockId = { number, hash };
85
+ const checkpointId: CheckpointId = {
86
+ number: checkpoint[0].checkpointNumber,
87
+ hash: checkpoint[0].header.hash().toString(),
88
+ };
89
+ const tipId: L2TipId = { block: blockId, checkpoint: checkpointId };
90
+ return {
91
+ proposed: blockId,
92
+ proven: tipId,
93
+ finalized: tipId,
94
+ checkpointed: tipId,
95
+ proposedCheckpoint: tipId,
96
+ };
97
+ }
98
+
99
+ public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
100
+ throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
101
+ }
102
+
103
+ public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
104
+ throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
105
+ }
106
+
107
+ public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
108
+ throw new Error('TXE Archiver does not implement "isEpochComplete"');
109
+ }
110
+
111
+ public syncImmediate(): Promise<void> {
112
+ throw new Error('TXE Archiver does not implement "syncImmediate"');
113
+ }
114
+
115
+ public getL2ToL1MembershipWitness(): Promise<undefined> {
116
+ // TXE doesn't drive the L2-to-L1 message flow through this archiver.
117
+ return Promise.resolve(undefined);
118
+ }
119
+ }
@@ -0,0 +1,247 @@
1
+ import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type {
3
+ AuthRequest,
4
+ ENR,
5
+ P2P,
6
+ P2PBlockReceivedCallback,
7
+ P2PCheckpointAttestationCallback,
8
+ P2PCheckpointReceivedCallback,
9
+ P2PConfig,
10
+ P2PDuplicateAttestationCallback,
11
+ P2PDuplicateProposalCallback,
12
+ P2PSyncState,
13
+ PeerId,
14
+ ReqRespSubProtocol,
15
+ ReqRespSubProtocolHandler,
16
+ StatusMessage,
17
+ } from '@aztec/p2p';
18
+ import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
19
+ import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
20
+ import type {
21
+ BlockProposal,
22
+ CheckpointAttestation,
23
+ CheckpointProposal,
24
+ CheckpointProposalCore,
25
+ TopicType,
26
+ } from '@aztec/stdlib/p2p';
27
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
28
+
29
+ export class DummyP2P implements P2P {
30
+ public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
31
+ return Promise.resolve();
32
+ }
33
+
34
+ public clear(): Promise<void> {
35
+ throw new Error('DummyP2P does not implement "clear".');
36
+ }
37
+
38
+ public getPendingTxs(): Promise<Tx[]> {
39
+ throw new Error('DummyP2P does not implement "getPendingTxs"');
40
+ }
41
+
42
+ public getEncodedEnr(): Promise<string | undefined> {
43
+ throw new Error('DummyP2P does not implement "getEncodedEnr"');
44
+ }
45
+
46
+ public getPeers(_includePending?: boolean): Promise<PeerInfo[]> {
47
+ throw new Error('DummyP2P does not implement "getPeers"');
48
+ }
49
+
50
+ public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
51
+ return Promise.resolve(0);
52
+ }
53
+
54
+ public broadcastProposal(_proposal: BlockProposal): Promise<void> {
55
+ throw new Error('DummyP2P does not implement "broadcastProposal"');
56
+ }
57
+
58
+ public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
59
+ throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
60
+ }
61
+
62
+ public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
63
+ throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
64
+ }
65
+
66
+ public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
67
+ throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
68
+ }
69
+
70
+ public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
71
+ throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
72
+ }
73
+
74
+ public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
75
+ throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
76
+ }
77
+
78
+ public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
79
+ throw new Error('DummyP2P does not implement "requestTxs"');
80
+ }
81
+
82
+ public requestTxByHash(_txHash: TxHash): Promise<Tx | undefined> {
83
+ throw new Error('DummyP2P does not implement "requestTxByHash"');
84
+ }
85
+
86
+ public sendTx(_tx: Tx): Promise<void> {
87
+ throw new Error('DummyP2P does not implement "sendTx"');
88
+ }
89
+
90
+ public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
91
+ throw new Error('DummyP2P does not implement "handleFailedExecution"');
92
+ }
93
+
94
+ public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
95
+ throw new Error('DummyP2P does not implement "getTxByHashFromPool"');
96
+ }
97
+
98
+ public getTxByHash(_txHash: TxHash): Promise<Tx | undefined> {
99
+ throw new Error('DummyP2P does not implement "getTxByHash"');
100
+ }
101
+
102
+ public getArchivedTxByHash(_txHash: TxHash): Promise<Tx | undefined> {
103
+ throw new Error('DummyP2P does not implement "getArchivedTxByHash"');
104
+ }
105
+
106
+ public getTxStatus(_txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
107
+ // In TXE there is no concept of transactions but we need to implement this because of tagging. We return 'mined'
108
+ // tx status for any tx hash.
109
+ return Promise.resolve('mined');
110
+ }
111
+
112
+ public iteratePendingTxs(): AsyncIterableIterator<Tx> {
113
+ throw new Error('DummyP2P does not implement "iteratePendingTxs"');
114
+ }
115
+
116
+ public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
117
+ throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
118
+ }
119
+
120
+ public getPendingTxCount(): Promise<number> {
121
+ throw new Error('DummyP2P does not implement "getPendingTxCount"');
122
+ }
123
+
124
+ public start(): Promise<void> {
125
+ throw new Error('DummyP2P does not implement "start"');
126
+ }
127
+
128
+ public stop(): Promise<void> {
129
+ throw new Error('DummyP2P does not implement "stop"');
130
+ }
131
+
132
+ public isReady(): boolean {
133
+ throw new Error('DummyP2P does not implement "isReady"');
134
+ }
135
+
136
+ public getStatus(): Promise<P2PSyncState> {
137
+ throw new Error('DummyP2P does not implement "getStatus"');
138
+ }
139
+
140
+ public getEnr(): ENR | undefined {
141
+ throw new Error('DummyP2P does not implement "getEnr"');
142
+ }
143
+
144
+ public isP2PClient(): true {
145
+ throw new Error('DummyP2P does not implement "isP2PClient"');
146
+ }
147
+
148
+ public getTxProvider(): ITxProvider {
149
+ throw new Error('DummyP2P does not implement "getTxProvider"');
150
+ }
151
+
152
+ public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
153
+ throw new Error('DummyP2P does not implement "getTxsByHash"');
154
+ }
155
+
156
+ public getCheckpointAttestationsForSlot(
157
+ _slot: SlotNumber,
158
+ _proposalPayloadHash?: CheckpointProposalHash,
159
+ ): Promise<CheckpointAttestation[]> {
160
+ throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
161
+ }
162
+
163
+ public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
164
+ throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
165
+ }
166
+
167
+ public getProposalsForSlot(_slot: SlotNumber): Promise<{
168
+ blockProposals: BlockProposal[];
169
+ checkpointProposals: CheckpointProposalCore[];
170
+ }> {
171
+ return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
172
+ }
173
+
174
+ public getL2BlockHash(_number: number): Promise<string | undefined> {
175
+ throw new Error('DummyP2P does not implement "getL2BlockHash"');
176
+ }
177
+
178
+ public updateP2PConfig(_config: Partial<P2PConfig>): Promise<void> {
179
+ throw new Error('DummyP2P does not implement "updateP2PConfig"');
180
+ }
181
+
182
+ public getL2Tips(): Promise<L2Tips> {
183
+ throw new Error('DummyP2P does not implement "getL2Tips"');
184
+ }
185
+
186
+ public handleBlockStreamEvent(_event: L2BlockStreamEvent): Promise<void> {
187
+ throw new Error('DummyP2P does not implement "handleBlockStreamEvent"');
188
+ }
189
+
190
+ public sync() {
191
+ throw new Error('DummyP2P does not implement "sync"');
192
+ }
193
+
194
+ public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
195
+ throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
196
+ }
197
+
198
+ public hasTxsInPool(_txHashes: TxHash[]): Promise<boolean[]> {
199
+ throw new Error('DummyP2P does not implement "hasTxsInPool"');
200
+ }
201
+
202
+ public getSyncedLatestBlockNum(): Promise<number> {
203
+ throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
204
+ }
205
+
206
+ public getSyncedProvenBlockNum(): Promise<number> {
207
+ throw new Error('DummyP2P does not implement "getSyncedProvenBlockNum"');
208
+ }
209
+
210
+ public getSyncedLatestSlot(): Promise<bigint> {
211
+ throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
212
+ }
213
+
214
+ protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
215
+ throw new Error('DummyP2P does not implement "protectTxs".');
216
+ }
217
+
218
+ prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
219
+ return Promise.resolve();
220
+ }
221
+
222
+ addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
223
+ throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
224
+ }
225
+ handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
226
+ throw new Error('DummyP2P does not implement "handleAuthRequestFromPeer".');
227
+ }
228
+
229
+ //This is no-op
230
+ public registerThisValidatorAddresses(_address: EthAddress[]): void {}
231
+
232
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
233
+ throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
234
+ }
235
+
236
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
237
+ throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
238
+ }
239
+
240
+ public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
241
+ throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
242
+ }
243
+
244
+ public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
245
+ throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
246
+ }
247
+ }
@@ -0,0 +1,53 @@
1
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
2
+ import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
4
+ import type { EthAddress } from '@aztec/foundation/eth-address';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
7
+ import { makeGlobalVariables } from '@aztec/stdlib/testing';
8
+ import {
9
+ type CheckpointGlobalVariables,
10
+ type FeeProvider,
11
+ type GlobalVariableBuilder,
12
+ GlobalVariables,
13
+ } from '@aztec/stdlib/tx';
14
+
15
+ /** Simple FeeProvider for TXE that returns zero fees. */
16
+ export class TXEFeeProvider implements FeeProvider {
17
+ public getCurrentMinFees(): Promise<GasFees> {
18
+ return Promise.resolve(new GasFees(0, 0));
19
+ }
20
+
21
+ public getPredictedMinFees(): Promise<GasFees[]> {
22
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
23
+ }
24
+ }
25
+
26
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
27
+ public buildGlobalVariables(
28
+ _blockNumber: BlockNumber,
29
+ _coinbase: EthAddress,
30
+ _feeRecipient: AztecAddress,
31
+ _slotNumber?: SlotNumber,
32
+ ): Promise<GlobalVariables> {
33
+ return Promise.resolve(makeGlobalVariables());
34
+ }
35
+
36
+ public buildCheckpointGlobalVariables(
37
+ _coinbase: EthAddress,
38
+ _feeRecipient: AztecAddress,
39
+ _slotNumber: SlotNumber,
40
+ _simulationOverridesPlan?: SimulationOverridesPlan,
41
+ ): Promise<CheckpointGlobalVariables> {
42
+ const vars = makeGlobalVariables();
43
+ return Promise.resolve({
44
+ chainId: vars.chainId,
45
+ version: vars.version,
46
+ slotNumber: vars.slotNumber,
47
+ timestamp: vars.timestamp,
48
+ coinbase: vars.coinbase,
49
+ feeRecipient: vars.feeRecipient,
50
+ gasFees: vars.gasFees,
51
+ });
52
+ }
53
+ }
@@ -0,0 +1,135 @@
1
+ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
2
+ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { createLogger } from '@aztec/foundation/log';
6
+ import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
7
+ import { MessageContextService } from '@aztec/pxe/simulator';
8
+ import { L2Block, type L2TipsProvider } from '@aztec/stdlib/block';
9
+ import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
10
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
11
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
12
+
13
+ import { TXEArchiver } from './archiver.js';
14
+ import { DummyP2P } from './dummy_p2p_client.js';
15
+ import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
16
+ import { MockEpochCache } from './mock_epoch_cache.js';
17
+ import { TXESynchronizer } from './synchronizer.js';
18
+
19
+ const VERSION = 1;
20
+ const CHAIN_ID = 1;
21
+ // Hardcoded so the bundled TXE doesn't try to read stdlib's package.json at a relative path
22
+ // that becomes invalid once bundled
23
+ const PACKAGE_VERSION = 'txe';
24
+
25
+ export class TXEStateMachine {
26
+ constructor(
27
+ public node: AztecNode,
28
+ public synchronizer: TXESynchronizer,
29
+ public archiver: TXEArchiver,
30
+ public anchorBlockStore: AnchorBlockStore,
31
+ public contractSyncService: ContractSyncService,
32
+ public messageContextService: MessageContextService,
33
+ ) {}
34
+
35
+ public static async create(
36
+ archiver: TXEArchiver,
37
+ anchorBlockStore: AnchorBlockStore,
38
+ contractStore: ContractStore,
39
+ noteStore: NoteStore,
40
+ ) {
41
+ const synchronizer = await TXESynchronizer.create();
42
+ const aztecNodeConfig = {} as AztecNodeConfig;
43
+
44
+ const log = createLogger('txe_node');
45
+ const node = new AztecNodeService(
46
+ aztecNodeConfig,
47
+ new DummyP2P(),
48
+ archiver,
49
+ archiver,
50
+ archiver,
51
+ archiver,
52
+ synchronizer,
53
+ undefined,
54
+ undefined,
55
+ undefined,
56
+ undefined,
57
+ async () => {},
58
+ VERSION,
59
+ CHAIN_ID,
60
+ new TXEGlobalVariablesBuilder(),
61
+ new TXEFeeProvider(),
62
+ new MockEpochCache(),
63
+ PACKAGE_VERSION,
64
+ new TestCircuitVerifier(),
65
+ new TestCircuitVerifier(),
66
+ undefined,
67
+ log,
68
+ );
69
+
70
+ const contractSyncService = new ContractSyncService(
71
+ node,
72
+ contractStore,
73
+ noteStore,
74
+ createLogger('txe:contract_sync'),
75
+ );
76
+
77
+ const messageContextService = new MessageContextService(node);
78
+
79
+ return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
80
+ }
81
+
82
+ /** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
83
+ public get l2TipsProvider(): L2TipsProvider {
84
+ const node = this.node;
85
+ return {
86
+ getL2Tips: async () => {
87
+ const tips = await node.getChainTips();
88
+ return { ...tips, proposedCheckpoint: tips.checkpointed };
89
+ },
90
+ };
91
+ }
92
+
93
+ public async handleL2Block(block: L2Block) {
94
+ // Create a checkpoint from the block manually.
95
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
96
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
97
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
98
+ const checkpoint = new Checkpoint(
99
+ block.archive,
100
+ CheckpointHeader.from({
101
+ lastArchiveRoot: block.header.lastArchive.root,
102
+ inHash: Fr.ZERO,
103
+ blobsHash: Fr.ZERO,
104
+ blockHeadersHash: Fr.ZERO,
105
+ epochOutHash: Fr.ZERO,
106
+ slotNumber: block.header.globalVariables.slotNumber,
107
+ timestamp: block.header.globalVariables.timestamp,
108
+ coinbase: block.header.globalVariables.coinbase,
109
+ feeRecipient: block.header.globalVariables.feeRecipient,
110
+ gasFees: block.header.globalVariables.gasFees,
111
+ totalManaUsed: block.header.totalManaUsed,
112
+ }),
113
+ [block],
114
+ checkpointNumber,
115
+ );
116
+
117
+ const publishedCheckpoint = new PublishedCheckpoint(
118
+ checkpoint,
119
+ new L1PublishedData(
120
+ BigInt(block.header.globalVariables.blockNumber),
121
+ block.header.globalVariables.timestamp,
122
+ block.header.globalVariables.blockNumber.toString(),
123
+ ),
124
+ [],
125
+ );
126
+ // Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
127
+ this.contractSyncService.wipe();
128
+
129
+ await Promise.all([
130
+ this.synchronizer.handleL2Block(block),
131
+ this.archiver.addCheckpoints([publishedCheckpoint], undefined),
132
+ this.anchorBlockStore.setHeader(block.header),
133
+ ]);
134
+ }
135
+ }
@@ -0,0 +1,107 @@
1
+ import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
2
+ import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
5
+
6
+ /**
7
+ * Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
8
+ * Since in TXE we don't validate transactions, mock suffices here.
9
+ */
10
+ export class MockEpochCache implements EpochCacheInterface {
11
+ getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
12
+ return Promise.resolve({
13
+ committee: undefined,
14
+ seed: 0n,
15
+ epoch: EpochNumber.ZERO,
16
+ isEscapeHatchOpen: false,
17
+ });
18
+ }
19
+
20
+ getSlotNow(): SlotNumber {
21
+ return SlotNumber(0);
22
+ }
23
+
24
+ getTargetSlot(): SlotNumber {
25
+ return SlotNumber(0);
26
+ }
27
+
28
+ getEpochNow(): EpochNumber {
29
+ return EpochNumber.ZERO;
30
+ }
31
+
32
+ getTargetEpoch(): EpochNumber {
33
+ return EpochNumber.ZERO;
34
+ }
35
+
36
+ getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
37
+ return {
38
+ epoch: EpochNumber.ZERO,
39
+ slot: SlotNumber(0),
40
+ ts: 0n,
41
+ nowMs: 0n,
42
+ };
43
+ }
44
+
45
+ getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
46
+ return {
47
+ epoch: EpochNumber.ZERO,
48
+ slot: SlotNumber(0),
49
+ ts: 0n,
50
+ nowSeconds: 0n,
51
+ };
52
+ }
53
+
54
+ getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
55
+ return this.getEpochAndSlotInNextL1Slot();
56
+ }
57
+
58
+ getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
59
+ return '0x00';
60
+ }
61
+
62
+ computeProposerIndex(_slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, _size: bigint): bigint {
63
+ return 0n;
64
+ }
65
+
66
+ getCurrentAndNextSlot(): { currentSlot: SlotNumber; nextSlot: SlotNumber } {
67
+ return {
68
+ currentSlot: SlotNumber(0),
69
+ nextSlot: SlotNumber(0),
70
+ };
71
+ }
72
+
73
+ getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
74
+ return {
75
+ targetSlot: SlotNumber(0),
76
+ nextSlot: SlotNumber(0),
77
+ };
78
+ }
79
+
80
+ getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
81
+ return Promise.resolve(undefined);
82
+ }
83
+
84
+ isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
85
+ return Promise.resolve(false);
86
+ }
87
+
88
+ getRegisteredValidators(): Promise<EthAddress[]> {
89
+ return Promise.resolve([]);
90
+ }
91
+
92
+ filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
93
+ return Promise.resolve([]);
94
+ }
95
+
96
+ isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean> {
97
+ return Promise.resolve(false);
98
+ }
99
+
100
+ isEscapeHatchOpenAtSlot(_slot: SlotTag): Promise<boolean> {
101
+ return Promise.resolve(false);
102
+ }
103
+
104
+ getL1Constants(): L1RollupConstants {
105
+ return EmptyL1RollupConstants;
106
+ }
107
+ }