@aztec/txe 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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 (170) hide show
  1. package/dest/AuthRegistry-56AMRLSQ.js +3 -0
  2. package/dest/AuthRegistry-56AMRLSQ.js.map +7 -0
  3. package/dest/ContractClassRegistry-CRN27URB.js +3 -0
  4. package/dest/ContractClassRegistry-CRN27URB.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-GRGL26IC.js +3 -0
  6. package/dest/ContractInstanceRegistry-GRGL26IC.js.map +7 -0
  7. package/dest/FeeJuice-J23RVHLW.js +3 -0
  8. package/dest/FeeJuice-J23RVHLW.js.map +7 -0
  9. package/dest/HandshakeRegistry-5.0.1-PEFCLEGP.js +3 -0
  10. package/dest/HandshakeRegistry-5.0.1-PEFCLEGP.js.map +7 -0
  11. package/dest/HandshakeRegistry-GNFACTEE.js +3 -0
  12. package/dest/HandshakeRegistry-GNFACTEE.js.map +7 -0
  13. package/dest/MultiCallEntrypoint-MIDICLQB.js +3 -0
  14. package/dest/MultiCallEntrypoint-MIDICLQB.js.map +7 -0
  15. package/dest/SchnorrAccount-ZRENHSMV.js +3 -0
  16. package/dest/SchnorrAccount-ZRENHSMV.js.map +7 -0
  17. package/dest/SchnorrInitializerlessAccount-L56LOFSV.js +3 -0
  18. package/dest/SchnorrInitializerlessAccount-L56LOFSV.js.map +7 -0
  19. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  20. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  21. package/dest/bin/check_txe_oracle_version.js +53 -0
  22. package/dest/bin/index.js +3 -30
  23. package/dest/bin/index.js.map +7 -0
  24. package/dest/bin/oracle_test_server.d.ts +3 -0
  25. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  26. package/dest/bin/oracle_test_server.js +41 -0
  27. package/dest/chunk-BJVAAXNA.js +3 -0
  28. package/dest/chunk-BJVAAXNA.js.map +7 -0
  29. package/dest/chunk-LVLJKGGH.js +266 -0
  30. package/dest/chunk-LVLJKGGH.js.map +7 -0
  31. package/dest/chunk-OVMCQ5A6.js +304 -0
  32. package/dest/chunk-OVMCQ5A6.js.map +7 -0
  33. package/dest/constants.d.ts +5 -1
  34. package/dest/constants.d.ts.map +1 -1
  35. package/dest/constants.js +9 -1
  36. package/dest/dispatcher_pool.d.ts +67 -0
  37. package/dest/dispatcher_pool.d.ts.map +1 -0
  38. package/dest/dispatcher_pool.js +286 -0
  39. package/dest/index.d.ts +51 -7
  40. package/dest/index.d.ts.map +1 -1
  41. package/dest/index.js +72 -190
  42. package/dest/metafile.json +40494 -0
  43. package/dest/msgpackr_fr_extension.d.ts +2 -0
  44. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  45. package/dest/msgpackr_fr_extension.js +21 -0
  46. package/dest/oracle/interfaces.d.ts +47 -9
  47. package/dest/oracle/interfaces.d.ts.map +1 -1
  48. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  49. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  50. package/dest/oracle/tagging_secret_strategy.js +12 -0
  51. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  52. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  53. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  54. package/dest/oracle/test-resolver/index.d.ts +9 -0
  55. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  56. package/dest/oracle/test-resolver/index.js +32 -0
  57. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  58. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  59. package/dest/oracle/test-resolver/resolver.js +181 -0
  60. package/dest/oracle/txe_oracle_public_context.d.ts +26 -2
  61. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  62. package/dest/oracle/txe_oracle_public_context.js +49 -1
  63. package/dest/oracle/txe_oracle_registry.d.ts +172 -0
  64. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  65. package/dest/oracle/txe_oracle_registry.js +767 -0
  66. package/dest/oracle/txe_oracle_top_level_context.d.ts +58 -18
  67. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  68. package/dest/oracle/txe_oracle_top_level_context.js +286 -97
  69. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  70. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  71. package/dest/oracle/txe_oracle_version.js +14 -0
  72. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  73. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  74. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  75. package/dest/rpc_server.d.ts +14 -0
  76. package/dest/rpc_server.d.ts.map +1 -0
  77. package/dest/rpc_server.js +78 -0
  78. package/dest/rpc_translator.d.ts +115 -233
  79. package/dest/rpc_translator.d.ts.map +1 -1
  80. package/dest/rpc_translator.js +791 -647
  81. package/dest/server.bundle.js +3 -0
  82. package/dest/server.bundle.js.map +7 -0
  83. package/dest/state_machine/archiver.d.ts +4 -3
  84. package/dest/state_machine/archiver.d.ts.map +1 -1
  85. package/dest/state_machine/archiver.js +25 -16
  86. package/dest/state_machine/dummy_p2p_client.d.ts +16 -7
  87. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  88. package/dest/state_machine/dummy_p2p_client.js +26 -2
  89. package/dest/state_machine/global_variable_builder.d.ts +10 -6
  90. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  91. package/dest/state_machine/global_variable_builder.js +8 -5
  92. package/dest/state_machine/index.d.ts +11 -7
  93. package/dest/state_machine/index.d.ts.map +1 -1
  94. package/dest/state_machine/index.js +52 -14
  95. package/dest/state_machine/mock_epoch_cache.d.ts +1 -2
  96. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  97. package/dest/state_machine/mock_epoch_cache.js +0 -3
  98. package/dest/state_machine/synchronizer.d.ts +5 -2
  99. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  100. package/dest/state_machine/synchronizer.js +7 -3
  101. package/dest/txe_session.d.ts +90 -20
  102. package/dest/txe_session.d.ts.map +1 -1
  103. package/dest/txe_session.js +313 -67
  104. package/dest/utils/block_creation.d.ts +2 -2
  105. package/dest/utils/block_creation.d.ts.map +1 -1
  106. package/dest/utils/block_creation.js +2 -2
  107. package/dest/utils/encoding.d.ts +192 -0
  108. package/dest/utils/encoding.d.ts.map +1 -0
  109. package/dest/{util → utils}/encoding.js +7 -2
  110. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  111. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  112. package/dest/utils/tx_effect_creation.d.ts +1 -1
  113. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  114. package/dest/utils/tx_effect_creation.js +0 -1
  115. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  116. package/dest/utils/txe_account_store.d.ts.map +1 -0
  117. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  118. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  119. package/dest/utils/txe_artifact_resolver.js +161 -0
  120. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  121. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  122. package/dest/{util → utils}/txe_public_contract_data_source.js +7 -4
  123. package/dest/worker.bundle.js +3 -0
  124. package/dest/worker.bundle.js.map +7 -0
  125. package/dest/worker.d.ts +2 -0
  126. package/dest/worker.d.ts.map +1 -0
  127. package/dest/worker.js +92 -0
  128. package/package.json +38 -21
  129. package/src/bin/check_txe_oracle_version.ts +67 -0
  130. package/src/bin/index.ts +11 -2
  131. package/src/bin/oracle_test_server.ts +51 -0
  132. package/src/constants.ts +11 -1
  133. package/src/dispatcher_pool.ts +317 -0
  134. package/src/index.ts +99 -227
  135. package/src/msgpackr_fr_extension.ts +23 -0
  136. package/src/oracle/interfaces.ts +47 -8
  137. package/src/oracle/tagging_secret_strategy.ts +25 -0
  138. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  139. package/src/oracle/test-resolver/index.ts +44 -0
  140. package/src/oracle/test-resolver/resolver.ts +245 -0
  141. package/src/oracle/txe_oracle_public_context.ts +62 -0
  142. package/src/oracle/txe_oracle_registry.ts +556 -0
  143. package/src/oracle/txe_oracle_top_level_context.ts +357 -118
  144. package/src/oracle/txe_oracle_version.ts +17 -0
  145. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  146. package/src/rpc_server.ts +87 -0
  147. package/src/rpc_translator.ts +890 -938
  148. package/src/state_machine/archiver.ts +37 -17
  149. package/src/state_machine/dummy_p2p_client.ts +43 -10
  150. package/src/state_machine/global_variable_builder.ts +12 -17
  151. package/src/state_machine/index.ts +63 -32
  152. package/src/state_machine/mock_epoch_cache.ts +0 -4
  153. package/src/state_machine/synchronizer.ts +9 -3
  154. package/src/txe_session.ts +545 -80
  155. package/src/utils/block_creation.ts +2 -1
  156. package/src/{util → utils}/encoding.ts +8 -2
  157. package/src/utils/tx_effect_creation.ts +0 -2
  158. package/src/utils/txe_artifact_resolver.ts +217 -0
  159. package/src/{util → utils}/txe_public_contract_data_source.ts +6 -4
  160. package/src/worker.ts +98 -0
  161. package/dest/util/encoding.d.ts +0 -788
  162. package/dest/util/encoding.d.ts.map +0 -1
  163. package/dest/util/expected_failure_error.d.ts.map +0 -1
  164. package/dest/util/txe_account_store.d.ts.map +0 -1
  165. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  166. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  167. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  168. /package/dest/{util → utils}/txe_account_store.js +0 -0
  169. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  170. /package/src/{util → utils}/txe_account_store.ts +0 -0
@@ -1,12 +1,20 @@
1
- import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, KVArchiverDataStore } from '@aztec/archiver';
1
+ import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
2
2
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
3
3
  import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import type { EthAddress } from '@aztec/foundation/eth-address';
6
6
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
7
- import type { CheckpointId, L2BlockId, L2TipId, L2Tips, ValidateCheckpointResult } from '@aztec/stdlib/block';
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';
8
15
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
- import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
16
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
17
+ import { BlockHeader } from '@aztec/stdlib/tx';
10
18
 
11
19
  /**
12
20
  * TXE Archiver implementation.
@@ -14,11 +22,16 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
14
22
  * without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
15
23
  */
16
24
  export class TXEArchiver extends ArchiverDataSourceBase {
17
- private readonly updater = new ArchiverDataStoreUpdater(this.store);
25
+ private readonly updater = new ArchiverDataStoreUpdater(this.stores);
18
26
 
19
27
  constructor(db: AztecAsyncKVStore) {
20
- const store = new KVArchiverDataStore(db, 9999);
21
- super(store);
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
+ );
22
35
  }
23
36
 
24
37
  public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
@@ -34,7 +47,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
34
47
  }
35
48
 
36
49
  public getL1Constants(): Promise<L1RollupConstants> {
37
- throw new Error('TXE Archiver does not implement "getL1Constants"');
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);
38
53
  }
39
54
 
40
55
  public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
@@ -48,20 +63,21 @@ export class TXEArchiver extends ArchiverDataSourceBase {
48
63
  public async getL2Tips(): Promise<L2Tips> {
49
64
  // In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
50
65
  // and 'finalized' to the latest block.
51
- const blockHeader = await this.getBlockHeader('latest');
52
- if (!blockHeader) {
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) {
53
72
  throw new Error('L2Tips requested from TXE Archiver but no block header found');
54
73
  }
55
74
 
56
- const number = blockHeader.globalVariables.blockNumber;
57
- const hash = (await blockHeader.hash()).toString();
58
- const checkpointedBlock = await this.getCheckpointedBlock(number);
59
- if (!checkpointedBlock) {
60
- throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
61
- }
75
+ const number = latestBlockData.header.globalVariables.blockNumber;
76
+ const hash = latestBlockData.blockHash.toString();
77
+
62
78
  // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
63
79
  // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
64
- const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
80
+ const checkpoint = await this.stores.blocks.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
65
81
  if (checkpoint.length === 0) {
66
82
  throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
67
83
  }
@@ -76,7 +92,6 @@ export class TXEArchiver extends ArchiverDataSourceBase {
76
92
  proven: tipId,
77
93
  finalized: tipId,
78
94
  checkpointed: tipId,
79
- proposedCheckpoint: tipId,
80
95
  };
81
96
  }
82
97
 
@@ -95,4 +110,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
95
110
  public syncImmediate(): Promise<void> {
96
111
  throw new Error('TXE Archiver does not implement "syncImmediate"');
97
112
  }
113
+
114
+ public getL2ToL1MembershipWitness(): Promise<undefined> {
115
+ // TXE doesn't drive the L2-to-L1 message flow through this archiver.
116
+ return Promise.resolve(undefined);
117
+ }
98
118
  }
@@ -1,23 +1,30 @@
1
- import type { SlotNumber } from '@aztec/foundation/branded-types';
1
+ import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type {
3
3
  AuthRequest,
4
4
  ENR,
5
5
  P2P,
6
6
  P2PBlockReceivedCallback,
7
+ P2PCheckpointAttestationCallback,
7
8
  P2PCheckpointReceivedCallback,
8
9
  P2PConfig,
9
10
  P2PDuplicateAttestationCallback,
10
11
  P2PDuplicateProposalCallback,
12
+ P2POversizedProposalCallback,
11
13
  P2PSyncState,
12
14
  PeerId,
13
15
  ReqRespSubProtocol,
14
16
  ReqRespSubProtocolHandler,
15
- ReqRespSubProtocolValidators,
16
17
  StatusMessage,
17
18
  } from '@aztec/p2p';
18
19
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
19
- import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
20
- import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
20
+ import type { ITxProvider, P2PConnectivity, PeerInfo } from '@aztec/stdlib/interfaces/server';
21
+ import type {
22
+ BlockProposal,
23
+ CheckpointAttestation,
24
+ CheckpointProposal,
25
+ CheckpointProposalCore,
26
+ TopicType,
27
+ } from '@aztec/stdlib/p2p';
21
28
  import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
22
29
 
23
30
  export class DummyP2P implements P2P {
@@ -45,6 +52,10 @@ export class DummyP2P implements P2P {
45
52
  return Promise.resolve(0);
46
53
  }
47
54
 
55
+ public getP2PConnectivity(): Promise<P2PConnectivity> {
56
+ return Promise.resolve({ enabled: false, connectedPeers: 0 });
57
+ }
58
+
48
59
  public broadcastProposal(_proposal: BlockProposal): Promise<void> {
49
60
  throw new Error('DummyP2P does not implement "broadcastProposal"');
50
61
  }
@@ -115,6 +126,10 @@ export class DummyP2P implements P2P {
115
126
  throw new Error('DummyP2P does not implement "getPendingTxCount"');
116
127
  }
117
128
 
129
+ public hasEligiblePendingTxs(_minCount: number): Promise<boolean> {
130
+ throw new Error('DummyP2P does not implement "hasEligiblePendingTxs"');
131
+ }
132
+
118
133
  public start(): Promise<void> {
119
134
  throw new Error('DummyP2P does not implement "start"');
120
135
  }
@@ -147,7 +162,10 @@ export class DummyP2P implements P2P {
147
162
  throw new Error('DummyP2P does not implement "getTxsByHash"');
148
163
  }
149
164
 
150
- public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
165
+ public getCheckpointAttestationsForSlot(
166
+ _slot: SlotNumber,
167
+ _proposalPayloadHash?: CheckpointProposalHash,
168
+ ): Promise<CheckpointAttestation[]> {
151
169
  throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
152
170
  }
153
171
 
@@ -155,6 +173,17 @@ export class DummyP2P implements P2P {
155
173
  throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
156
174
  }
157
175
 
176
+ public getProposalsForSlot(_slot: SlotNumber): Promise<{
177
+ blockProposals: BlockProposal[];
178
+ checkpointProposals: CheckpointProposalCore[];
179
+ }> {
180
+ return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
181
+ }
182
+
183
+ public hasCheckpointProposalForSlot(_slot: SlotNumber): Promise<boolean> {
184
+ return Promise.resolve(false);
185
+ }
186
+
158
187
  public getL2BlockHash(_number: number): Promise<string | undefined> {
159
188
  throw new Error('DummyP2P does not implement "getL2BlockHash"');
160
189
  }
@@ -203,11 +232,7 @@ export class DummyP2P implements P2P {
203
232
  return Promise.resolve();
204
233
  }
205
234
 
206
- addReqRespSubProtocol(
207
- _subProtocol: ReqRespSubProtocol,
208
- _handler: ReqRespSubProtocolHandler,
209
- _validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
210
- ): Promise<void> {
235
+ addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
211
236
  throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
212
237
  }
213
238
  handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
@@ -221,10 +246,18 @@ export class DummyP2P implements P2P {
221
246
  throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
222
247
  }
223
248
 
249
+ public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {
250
+ throw new Error('DummyP2P does not implement "registerOversizedProposalCallback"');
251
+ }
252
+
224
253
  public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
225
254
  throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
226
255
  }
227
256
 
257
+ public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
258
+ throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
259
+ }
260
+
228
261
  public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
229
262
  throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
230
263
  }
@@ -1,34 +1,29 @@
1
- import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
1
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
2
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
2
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { GasFees } from '@aztec/stdlib/gas';
6
+ import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
5
7
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
6
- import {
7
- type BuildCheckpointGlobalVariablesOpts,
8
- type CheckpointGlobalVariables,
9
- type GlobalVariableBuilder,
10
- GlobalVariables,
11
- } from '@aztec/stdlib/tx';
8
+ import type { CheckpointGlobalVariables, FeeProvider, GlobalVariableBuilder } from '@aztec/stdlib/tx';
12
9
 
13
- export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
10
+ /** Simple FeeProvider for TXE that returns zero fees. */
11
+ export class TXEFeeProvider implements FeeProvider {
14
12
  public getCurrentMinFees(): Promise<GasFees> {
15
13
  return Promise.resolve(new GasFees(0, 0));
16
14
  }
17
15
 
18
- public buildGlobalVariables(
19
- _blockNumber: BlockNumber,
20
- _coinbase: EthAddress,
21
- _feeRecipient: AztecAddress,
22
- _slotNumber?: SlotNumber,
23
- ): Promise<GlobalVariables> {
24
- return Promise.resolve(makeGlobalVariables());
16
+ public getPredictedMinFees(): Promise<GasFees[]> {
17
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
25
18
  }
19
+ }
26
20
 
21
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
27
22
  public buildCheckpointGlobalVariables(
28
23
  _coinbase: EthAddress,
29
24
  _feeRecipient: AztecAddress,
30
25
  _slotNumber: SlotNumber,
31
- _opts?: BuildCheckpointGlobalVariablesOpts,
26
+ _simulationOverridesPlan?: SimulationOverridesPlan,
32
27
  ): Promise<CheckpointGlobalVariables> {
33
28
  const vars = makeGlobalVariables();
34
29
  return Promise.resolve({
@@ -3,22 +3,30 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
3
  import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
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 } from '@aztec/stdlib/block';
6
+ import {
7
+ type AnchorBlockStore,
8
+ ContractClassService,
9
+ type ContractStore,
10
+ ContractSyncService,
11
+ type NoteStore,
12
+ } from '@aztec/pxe/server';
13
+ import { TxResolverService } from '@aztec/pxe/simulator';
14
+ import { L2Block, type L2TipsProvider } from '@aztec/stdlib/block';
9
15
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
10
16
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
11
17
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
12
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
13
18
 
14
19
  import { TXEArchiver } from './archiver.js';
15
20
  import { DummyP2P } from './dummy_p2p_client.js';
16
- import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
21
+ import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
17
22
  import { MockEpochCache } from './mock_epoch_cache.js';
18
23
  import { TXESynchronizer } from './synchronizer.js';
19
24
 
20
25
  const VERSION = 1;
21
26
  const CHAIN_ID = 1;
27
+ // Hardcoded so the bundled TXE doesn't try to read stdlib's package.json at a relative path
28
+ // that becomes invalid once bundled
29
+ const PACKAGE_VERSION = 'txe';
22
30
 
23
31
  export class TXEStateMachine {
24
32
  constructor(
@@ -27,7 +35,8 @@ export class TXEStateMachine {
27
35
  public archiver: TXEArchiver,
28
36
  public anchorBlockStore: AnchorBlockStore,
29
37
  public contractSyncService: ContractSyncService,
30
- public messageContextService: MessageContextService,
38
+ public contractClassService: ContractClassService,
39
+ public txResolver: TxResolverService,
31
40
  ) {}
32
41
 
33
42
  public static async create(
@@ -40,43 +49,64 @@ export class TXEStateMachine {
40
49
  const aztecNodeConfig = {} as AztecNodeConfig;
41
50
 
42
51
  const log = createLogger('txe_node');
43
- const node = new AztecNodeService(
44
- aztecNodeConfig,
45
- new DummyP2P(),
46
- archiver,
47
- archiver,
48
- archiver,
49
- archiver,
50
- synchronizer,
51
- undefined,
52
- undefined,
53
- undefined,
54
- undefined,
55
- undefined,
56
- VERSION,
57
- CHAIN_ID,
58
- new TXEGlobalVariablesBuilder(),
59
- new MockEpochCache(),
60
- getPackageVersion() ?? '',
61
- new TestCircuitVerifier(),
62
- new TestCircuitVerifier(),
63
- undefined,
52
+ const node = new AztecNodeService({
53
+ config: aztecNodeConfig,
54
+ p2pClient: new DummyP2P(),
55
+ blockSource: archiver,
56
+ logsSource: archiver,
57
+ contractDataSource: archiver,
58
+ l1ToL2MessageSource: archiver,
59
+ worldStateSynchronizer: synchronizer,
60
+ sequencer: undefined,
61
+ proverNode: undefined,
62
+ slasherClient: undefined,
63
+ validatorsSentinel: undefined,
64
+ stopStartedWatchers: async () => {},
65
+ l1ChainId: CHAIN_ID,
66
+ version: VERSION,
67
+ globalVariableBuilder: new TXEGlobalVariablesBuilder(),
68
+ rollupContract: undefined,
69
+ feeProvider: new TXEFeeProvider(),
70
+ epochCache: new MockEpochCache(),
71
+ packageVersion: PACKAGE_VERSION,
72
+ peerProofVerifier: new TestCircuitVerifier(),
73
+ rpcProofVerifier: new TestCircuitVerifier(),
74
+ telemetry: undefined,
64
75
  log,
65
- );
76
+ });
66
77
 
78
+ const contractClassService = new ContractClassService(node, contractStore);
67
79
  const contractSyncService = new ContractSyncService(
68
80
  node,
69
81
  contractStore,
82
+ contractClassService,
70
83
  noteStore,
71
84
  createLogger('txe:contract_sync'),
85
+ { concurrentContractSyncEnabled: false },
72
86
  );
73
87
 
74
- const messageContextService = new MessageContextService(node);
88
+ const txResolver = new TxResolverService(node);
89
+
90
+ return new this(
91
+ node,
92
+ synchronizer,
93
+ archiver,
94
+ anchorBlockStore,
95
+ contractSyncService,
96
+ contractClassService,
97
+ txResolver,
98
+ );
99
+ }
75
100
 
76
- return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
101
+ /** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
102
+ public get l2TipsProvider(): L2TipsProvider {
103
+ const node = this.node;
104
+ return {
105
+ getL2Tips: () => node.getChainTips(),
106
+ };
77
107
  }
78
108
 
79
- public async handleL2Block(block: L2Block) {
109
+ public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
80
110
  // Create a checkpoint from the block manually.
81
111
  // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
82
112
  // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
@@ -95,6 +125,7 @@ export class TXEStateMachine {
95
125
  feeRecipient: block.header.globalVariables.feeRecipient,
96
126
  gasFees: block.header.globalVariables.gasFees,
97
127
  totalManaUsed: block.header.totalManaUsed,
128
+ accumulatedFees: block.header.totalFees,
98
129
  }),
99
130
  [block],
100
131
  checkpointNumber,
@@ -113,7 +144,7 @@ export class TXEStateMachine {
113
144
  this.contractSyncService.wipe();
114
145
 
115
146
  await Promise.all([
116
- this.synchronizer.handleL2Block(block),
147
+ this.synchronizer.handleL2Block(block, l1ToL2Messages),
117
148
  this.archiver.addCheckpoints([publishedCheckpoint], undefined),
118
149
  this.anchorBlockStore.setHeader(block.header),
119
150
  ]);
@@ -55,10 +55,6 @@ export class MockEpochCache implements EpochCacheInterface {
55
55
  return this.getEpochAndSlotInNextL1Slot();
56
56
  }
57
57
 
58
- isProposerPipeliningEnabled(): boolean {
59
- return false;
60
- }
61
-
62
58
  getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
63
59
  return '0x00';
64
60
  }
@@ -1,5 +1,6 @@
1
1
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import { padArrayEnd } from '@aztec/foundation/collection';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { BlockHash, L2Block } from '@aztec/stdlib/block';
5
6
  import type {
@@ -18,15 +19,15 @@ export class TXESynchronizer implements WorldStateSynchronizer {
18
19
  constructor(public nativeWorldStateService: NativeWorldStateService) {}
19
20
 
20
21
  static async create() {
21
- const nativeWorldStateService = await NativeWorldStateService.tmp();
22
+ const nativeWorldStateService = await NativeWorldStateService.ephemeral();
22
23
 
23
24
  return new this(nativeWorldStateService);
24
25
  }
25
26
 
26
- public async handleL2Block(block: L2Block) {
27
+ public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
27
28
  await this.nativeWorldStateService.handleL2BlockAndMessages(
28
29
  block,
29
- Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
30
+ padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
30
31
  );
31
32
 
32
33
  this.blockNumber = block.header.globalVariables.blockNumber;
@@ -57,6 +58,11 @@ export class TXESynchronizer implements WorldStateSynchronizer {
57
58
  return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
58
59
  }
59
60
 
61
+ /** Gets a snapshot at the given block number. The TXE has no reorgs, so the fork hash is not verified. */
62
+ public getVerifiedSnapshot(blockNumber: number, _blockHash: BlockHash): Promise<MerkleTreeReadOperations> {
63
+ return Promise.resolve(this.getSnapshot(blockNumber));
64
+ }
65
+
60
66
  /** Backups the db to the target path. */
61
67
  public backupTo(dstPath: string, compact?: boolean): Promise<Record<Exclude<SnapshotDataKeys, 'archiver'>, string>> {
62
68
  return this.nativeWorldStateService.backupTo(dstPath, compact);