@aztec/txe 0.0.1-commit.96dac018d → 0.0.1-commit.9a89641

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 (168) hide show
  1. package/dest/AuthRegistry-QVGDDH5X.js +3 -0
  2. package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
  3. package/dest/ContractClassRegistry-PVNCKGG7.js +3 -0
  4. package/dest/ContractClassRegistry-PVNCKGG7.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-WLOZKTR6.js +3 -0
  6. package/dest/ContractInstanceRegistry-WLOZKTR6.js.map +7 -0
  7. package/dest/FeeJuice-MAQJU53K.js +3 -0
  8. package/dest/FeeJuice-MAQJU53K.js.map +7 -0
  9. package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
  10. package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
  12. package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
  13. package/dest/SchnorrAccount-ADD65DYA.js +3 -0
  14. package/dest/SchnorrAccount-ADD65DYA.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  18. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  19. package/dest/bin/check_txe_oracle_version.js +22 -0
  20. package/dest/bin/index.js +3 -30
  21. package/dest/bin/index.js.map +7 -0
  22. package/dest/bin/oracle_test_server.d.ts +3 -0
  23. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  24. package/dest/bin/oracle_test_server.js +41 -0
  25. package/dest/chunk-32UHX7YY.js +3 -0
  26. package/dest/chunk-32UHX7YY.js.map +7 -0
  27. package/dest/chunk-RVEPNDEP.js +304 -0
  28. package/dest/chunk-RVEPNDEP.js.map +7 -0
  29. package/dest/chunk-XWIMXLKD.js +258 -0
  30. package/dest/chunk-XWIMXLKD.js.map +7 -0
  31. package/dest/constants.d.ts +5 -1
  32. package/dest/constants.d.ts.map +1 -1
  33. package/dest/constants.js +9 -1
  34. package/dest/dispatcher_pool.d.ts +67 -0
  35. package/dest/dispatcher_pool.d.ts.map +1 -0
  36. package/dest/dispatcher_pool.js +286 -0
  37. package/dest/index.d.ts +51 -7
  38. package/dest/index.d.ts.map +1 -1
  39. package/dest/index.js +72 -188
  40. package/dest/metafile.json +38833 -0
  41. package/dest/msgpackr_fr_extension.d.ts +2 -0
  42. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  43. package/dest/msgpackr_fr_extension.js +21 -0
  44. package/dest/oracle/interfaces.d.ts +68 -30
  45. package/dest/oracle/interfaces.d.ts.map +1 -1
  46. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  47. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  48. package/dest/oracle/tagging_secret_strategy.js +12 -0
  49. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  50. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  51. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  52. package/dest/oracle/test-resolver/index.d.ts +9 -0
  53. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  54. package/dest/oracle/test-resolver/index.js +32 -0
  55. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  56. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  57. package/dest/oracle/test-resolver/resolver.js +181 -0
  58. package/dest/oracle/txe_oracle_public_context.d.ts +38 -14
  59. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  60. package/dest/oracle/txe_oracle_public_context.js +61 -13
  61. package/dest/oracle/txe_oracle_registry.d.ts +172 -0
  62. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  63. package/dest/oracle/txe_oracle_registry.js +767 -0
  64. package/dest/oracle/txe_oracle_top_level_context.d.ts +68 -27
  65. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  66. package/dest/oracle/txe_oracle_top_level_context.js +571 -312
  67. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  68. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  69. package/dest/oracle/txe_oracle_version.js +14 -0
  70. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  71. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  72. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  73. package/dest/rpc_server.d.ts +14 -0
  74. package/dest/rpc_server.d.ts.map +1 -0
  75. package/dest/rpc_server.js +78 -0
  76. package/dest/rpc_translator.d.ts +116 -228
  77. package/dest/rpc_translator.d.ts.map +1 -1
  78. package/dest/rpc_translator.js +909 -636
  79. package/dest/server.bundle.js +3 -0
  80. package/dest/server.bundle.js.map +7 -0
  81. package/dest/state_machine/archiver.d.ts +6 -5
  82. package/dest/state_machine/archiver.d.ts.map +1 -1
  83. package/dest/state_machine/archiver.js +28 -20
  84. package/dest/state_machine/dummy_p2p_client.d.ts +16 -7
  85. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  86. package/dest/state_machine/dummy_p2p_client.js +25 -4
  87. package/dest/state_machine/global_variable_builder.d.ts +10 -6
  88. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  89. package/dest/state_machine/global_variable_builder.js +8 -5
  90. package/dest/state_machine/index.d.ts +11 -5
  91. package/dest/state_machine/index.d.ts.map +1 -1
  92. package/dest/state_machine/index.js +50 -10
  93. package/dest/state_machine/mock_epoch_cache.d.ts +17 -3
  94. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  95. package/dest/state_machine/mock_epoch_cache.js +32 -2
  96. package/dest/state_machine/synchronizer.d.ts +14 -6
  97. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  98. package/dest/state_machine/synchronizer.js +22 -9
  99. package/dest/txe_session.d.ts +92 -19
  100. package/dest/txe_session.d.ts.map +1 -1
  101. package/dest/txe_session.js +325 -61
  102. package/dest/utils/block_creation.d.ts +2 -2
  103. package/dest/utils/block_creation.d.ts.map +1 -1
  104. package/dest/utils/block_creation.js +2 -2
  105. package/dest/utils/encoding.d.ts +194 -0
  106. package/dest/utils/encoding.d.ts.map +1 -0
  107. package/dest/{util → utils}/encoding.js +7 -2
  108. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  109. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  110. package/dest/utils/tx_effect_creation.d.ts +1 -1
  111. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  112. package/dest/utils/tx_effect_creation.js +0 -1
  113. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  114. package/dest/utils/txe_account_store.d.ts.map +1 -0
  115. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  116. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  117. package/dest/utils/txe_artifact_resolver.js +161 -0
  118. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  119. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  120. package/dest/{util → utils}/txe_public_contract_data_source.js +8 -7
  121. package/dest/worker.bundle.js +3 -0
  122. package/dest/worker.bundle.js.map +7 -0
  123. package/dest/worker.d.ts +2 -0
  124. package/dest/worker.d.ts.map +1 -0
  125. package/dest/worker.js +92 -0
  126. package/package.json +38 -21
  127. package/src/bin/check_txe_oracle_version.ts +31 -0
  128. package/src/bin/index.ts +11 -2
  129. package/src/bin/oracle_test_server.ts +51 -0
  130. package/src/constants.ts +11 -1
  131. package/src/dispatcher_pool.ts +317 -0
  132. package/src/index.ts +99 -224
  133. package/src/msgpackr_fr_extension.ts +23 -0
  134. package/src/oracle/interfaces.ts +70 -35
  135. package/src/oracle/tagging_secret_strategy.ts +25 -0
  136. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  137. package/src/oracle/test-resolver/index.ts +44 -0
  138. package/src/oracle/test-resolver/resolver.ts +245 -0
  139. package/src/oracle/txe_oracle_public_context.ts +74 -12
  140. package/src/oracle/txe_oracle_registry.ts +556 -0
  141. package/src/oracle/txe_oracle_top_level_context.ts +380 -128
  142. package/src/oracle/txe_oracle_version.ts +17 -0
  143. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  144. package/src/rpc_server.ts +87 -0
  145. package/src/rpc_translator.ts +1126 -1021
  146. package/src/state_machine/archiver.ts +41 -20
  147. package/src/state_machine/dummy_p2p_client.ts +44 -11
  148. package/src/state_machine/global_variable_builder.ts +12 -11
  149. package/src/state_machine/index.ts +63 -28
  150. package/src/state_machine/mock_epoch_cache.ts +42 -3
  151. package/src/state_machine/synchronizer.ts +31 -10
  152. package/src/txe_session.ts +564 -75
  153. package/src/utils/block_creation.ts +2 -1
  154. package/src/{util → utils}/encoding.ts +8 -2
  155. package/src/utils/tx_effect_creation.ts +0 -2
  156. package/src/utils/txe_artifact_resolver.ts +217 -0
  157. package/src/{util → utils}/txe_public_contract_data_source.ts +6 -6
  158. package/src/worker.ts +98 -0
  159. package/dest/util/encoding.d.ts +0 -720
  160. package/dest/util/encoding.d.ts.map +0 -1
  161. package/dest/util/expected_failure_error.d.ts.map +0 -1
  162. package/dest/util/txe_account_store.d.ts.map +0 -1
  163. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  164. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  165. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  166. /package/dest/{util → utils}/txe_account_store.js +0 -0
  167. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  168. /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, { epochDuration: 32 });
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
  }
@@ -79,12 +95,12 @@ export class TXEArchiver extends ArchiverDataSourceBase {
79
95
  };
80
96
  }
81
97
 
82
- public getL2SlotNumber(): Promise<SlotNumber | undefined> {
83
- throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
98
+ public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
99
+ throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
84
100
  }
85
101
 
86
- public getL2EpochNumber(): Promise<EpochNumber | undefined> {
87
- throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
102
+ public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
103
+ throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
88
104
  }
89
105
 
90
106
  public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
@@ -94,4 +110,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
94
110
  public syncImmediate(): Promise<void> {
95
111
  throw new Error('TXE Archiver does not implement "syncImmediate"');
96
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
+ }
97
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
20
  import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
20
- import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
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 {
@@ -61,8 +68,12 @@ export class DummyP2P implements P2P {
61
68
  throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
62
69
  }
63
70
 
64
- public registerCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
65
- throw new Error('DummyP2P does not implement "registerCheckpointProposalHandler"');
71
+ public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
72
+ throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
73
+ }
74
+
75
+ public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
76
+ throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
66
77
  }
67
78
 
68
79
  public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
@@ -111,6 +122,10 @@ export class DummyP2P implements P2P {
111
122
  throw new Error('DummyP2P does not implement "getPendingTxCount"');
112
123
  }
113
124
 
125
+ public hasEligiblePendingTxs(_minCount: number): Promise<boolean> {
126
+ throw new Error('DummyP2P does not implement "hasEligiblePendingTxs"');
127
+ }
128
+
114
129
  public start(): Promise<void> {
115
130
  throw new Error('DummyP2P does not implement "start"');
116
131
  }
@@ -143,7 +158,10 @@ export class DummyP2P implements P2P {
143
158
  throw new Error('DummyP2P does not implement "getTxsByHash"');
144
159
  }
145
160
 
146
- public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
161
+ public getCheckpointAttestationsForSlot(
162
+ _slot: SlotNumber,
163
+ _proposalPayloadHash?: CheckpointProposalHash,
164
+ ): Promise<CheckpointAttestation[]> {
147
165
  throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
148
166
  }
149
167
 
@@ -151,6 +169,17 @@ export class DummyP2P implements P2P {
151
169
  throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
152
170
  }
153
171
 
172
+ public getProposalsForSlot(_slot: SlotNumber): Promise<{
173
+ blockProposals: BlockProposal[];
174
+ checkpointProposals: CheckpointProposalCore[];
175
+ }> {
176
+ return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
177
+ }
178
+
179
+ public hasCheckpointProposalForSlot(_slot: SlotNumber): Promise<boolean> {
180
+ return Promise.resolve(false);
181
+ }
182
+
154
183
  public getL2BlockHash(_number: number): Promise<string | undefined> {
155
184
  throw new Error('DummyP2P does not implement "getL2BlockHash"');
156
185
  }
@@ -199,11 +228,7 @@ export class DummyP2P implements P2P {
199
228
  return Promise.resolve();
200
229
  }
201
230
 
202
- addReqRespSubProtocol(
203
- _subProtocol: ReqRespSubProtocol,
204
- _handler: ReqRespSubProtocolHandler,
205
- _validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
206
- ): Promise<void> {
231
+ addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
207
232
  throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
208
233
  }
209
234
  handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
@@ -217,10 +242,18 @@ export class DummyP2P implements P2P {
217
242
  throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
218
243
  }
219
244
 
245
+ public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {
246
+ throw new Error('DummyP2P does not implement "registerOversizedProposalCallback"');
247
+ }
248
+
220
249
  public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
221
250
  throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
222
251
  }
223
252
 
253
+ public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
254
+ throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
255
+ }
256
+
224
257
  public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
225
258
  throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
226
259
  }
@@ -1,28 +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 { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
8
+ import type { CheckpointGlobalVariables, FeeProvider, GlobalVariableBuilder } from '@aztec/stdlib/tx';
7
9
 
8
- export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
10
+ /** Simple FeeProvider for TXE that returns zero fees. */
11
+ export class TXEFeeProvider implements FeeProvider {
9
12
  public getCurrentMinFees(): Promise<GasFees> {
10
13
  return Promise.resolve(new GasFees(0, 0));
11
14
  }
12
15
 
13
- public buildGlobalVariables(
14
- _blockNumber: BlockNumber,
15
- _coinbase: EthAddress,
16
- _feeRecipient: AztecAddress,
17
- _slotNumber?: SlotNumber,
18
- ): Promise<GlobalVariables> {
19
- return Promise.resolve(makeGlobalVariables());
16
+ public getPredictedMinFees(): Promise<GasFees[]> {
17
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
20
18
  }
19
+ }
21
20
 
21
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
22
22
  public buildCheckpointGlobalVariables(
23
23
  _coinbase: EthAddress,
24
24
  _feeRecipient: AztecAddress,
25
25
  _slotNumber: SlotNumber,
26
+ _simulationOverridesPlan?: SimulationOverridesPlan,
26
27
  ): Promise<CheckpointGlobalVariables> {
27
28
  const vars = makeGlobalVariables();
28
29
  return Promise.resolve({
@@ -3,21 +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 { 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';
8
15
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
16
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
10
17
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
11
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
12
18
 
13
19
  import { TXEArchiver } from './archiver.js';
14
20
  import { DummyP2P } from './dummy_p2p_client.js';
15
- import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
21
+ import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
16
22
  import { MockEpochCache } from './mock_epoch_cache.js';
17
23
  import { TXESynchronizer } from './synchronizer.js';
18
24
 
19
25
  const VERSION = 1;
20
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';
21
30
 
22
31
  export class TXEStateMachine {
23
32
  constructor(
@@ -26,6 +35,8 @@ export class TXEStateMachine {
26
35
  public archiver: TXEArchiver,
27
36
  public anchorBlockStore: AnchorBlockStore,
28
37
  public contractSyncService: ContractSyncService,
38
+ public contractClassService: ContractClassService,
39
+ public txResolver: TxResolverService,
29
40
  ) {}
30
41
 
31
42
  public static async create(
@@ -38,40 +49,63 @@ export class TXEStateMachine {
38
49
  const aztecNodeConfig = {} as AztecNodeConfig;
39
50
 
40
51
  const log = createLogger('txe_node');
41
- const node = new AztecNodeService(
42
- aztecNodeConfig,
43
- new DummyP2P(),
44
- archiver,
45
- archiver,
46
- archiver,
47
- archiver,
48
- synchronizer,
49
- undefined,
50
- undefined,
51
- undefined,
52
- undefined,
53
- undefined,
54
- VERSION,
55
- CHAIN_ID,
56
- new TXEGlobalVariablesBuilder(),
57
- new MockEpochCache(),
58
- getPackageVersion() ?? '',
59
- new TestCircuitVerifier(),
60
- 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,
61
75
  log,
62
- );
76
+ });
63
77
 
78
+ const contractClassService = new ContractClassService(node, contractStore);
64
79
  const contractSyncService = new ContractSyncService(
65
80
  node,
66
81
  contractStore,
82
+ contractClassService,
67
83
  noteStore,
68
84
  createLogger('txe:contract_sync'),
69
85
  );
70
86
 
71
- return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
87
+ const txResolver = new TxResolverService(node);
88
+
89
+ return new this(
90
+ node,
91
+ synchronizer,
92
+ archiver,
93
+ anchorBlockStore,
94
+ contractSyncService,
95
+ contractClassService,
96
+ txResolver,
97
+ );
98
+ }
99
+
100
+ /** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
101
+ public get l2TipsProvider(): L2TipsProvider {
102
+ const node = this.node;
103
+ return {
104
+ getL2Tips: () => node.getChainTips(),
105
+ };
72
106
  }
73
107
 
74
- public async handleL2Block(block: L2Block) {
108
+ public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
75
109
  // Create a checkpoint from the block manually.
76
110
  // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
77
111
  // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
@@ -90,6 +124,7 @@ export class TXEStateMachine {
90
124
  feeRecipient: block.header.globalVariables.feeRecipient,
91
125
  gasFees: block.header.globalVariables.gasFees,
92
126
  totalManaUsed: block.header.totalManaUsed,
127
+ accumulatedFees: block.header.totalFees,
93
128
  }),
94
129
  [block],
95
130
  checkpointNumber,
@@ -108,7 +143,7 @@ export class TXEStateMachine {
108
143
  this.contractSyncService.wipe();
109
144
 
110
145
  await Promise.all([
111
- this.synchronizer.handleL2Block(block),
146
+ this.synchronizer.handleL2Block(block, l1ToL2Messages),
112
147
  this.archiver.addCheckpoints([publishedCheckpoint], undefined),
113
148
  this.anchorBlockStore.setHeader(block.header),
114
149
  ]);
@@ -8,7 +8,7 @@ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/ep
8
8
  * Since in TXE we don't validate transactions, mock suffices here.
9
9
  */
10
10
  export class MockEpochCache implements EpochCacheInterface {
11
- getCommittee(): Promise<EpochCommitteeInfo> {
11
+ getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
12
12
  return Promise.resolve({
13
13
  committee: undefined,
14
14
  seed: 0n,
@@ -17,6 +17,22 @@ export class MockEpochCache implements EpochCacheInterface {
17
17
  });
18
18
  }
19
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
+
20
36
  getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
21
37
  return {
22
38
  epoch: EpochNumber.ZERO,
@@ -26,15 +42,19 @@ export class MockEpochCache implements EpochCacheInterface {
26
42
  };
27
43
  }
28
44
 
29
- getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint } {
45
+ getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
30
46
  return {
31
47
  epoch: EpochNumber.ZERO,
32
48
  slot: SlotNumber(0),
33
49
  ts: 0n,
34
- now: 0n,
50
+ nowSeconds: 0n,
35
51
  };
36
52
  }
37
53
 
54
+ getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
55
+ return this.getEpochAndSlotInNextL1Slot();
56
+ }
57
+
38
58
  getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
39
59
  return '0x00';
40
60
  }
@@ -50,6 +70,13 @@ export class MockEpochCache implements EpochCacheInterface {
50
70
  };
51
71
  }
52
72
 
73
+ getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
74
+ return {
75
+ targetSlot: SlotNumber(0),
76
+ nextSlot: SlotNumber(0),
77
+ };
78
+ }
79
+
53
80
  getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
54
81
  return Promise.resolve(undefined);
55
82
  }
@@ -66,7 +93,19 @@ export class MockEpochCache implements EpochCacheInterface {
66
93
  return Promise.resolve([]);
67
94
  }
68
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
+
69
104
  getL1Constants(): L1RollupConstants {
70
105
  return EmptyL1RollupConstants;
71
106
  }
107
+
108
+ getLagInEpochsForValidatorSet(): number {
109
+ return 0;
110
+ }
72
111
  }
@@ -1,7 +1,9 @@
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
- import type { L2Block } from '@aztec/stdlib/block';
5
+ import { AvmSimulatorPool } from '@aztec/simulator/server';
6
+ import type { BlockHash, L2Block } from '@aztec/stdlib/block';
5
7
  import type {
6
8
  MerkleTreeReadOperations,
7
9
  MerkleTreeWriteOperations,
@@ -15,30 +17,39 @@ export class TXESynchronizer implements WorldStateSynchronizer {
15
17
  // This works when set to 1 as well.
16
18
  private blockNumber = BlockNumber.ZERO;
17
19
 
20
+ /** AVM execution backend (simulator pool + CDB server) shared across all public simulations. */
21
+ public avmSimulator!: AvmSimulatorPool;
22
+
18
23
  constructor(public nativeWorldStateService: NativeWorldStateService) {}
19
24
 
20
25
  static async create() {
21
- const nativeWorldStateService = await NativeWorldStateService.tmp();
26
+ const nativeWorldStateService = await NativeWorldStateService.ephemeral();
27
+
28
+ const synchronizer = new this(nativeWorldStateService);
22
29
 
23
- return new this(nativeWorldStateService);
30
+ synchronizer.avmSimulator = await AvmSimulatorPool.spawn({
31
+ wsdbIpcPath: nativeWorldStateService.getIpcPath(),
32
+ });
33
+
34
+ return synchronizer;
24
35
  }
25
36
 
26
- public async handleL2Block(block: L2Block) {
37
+ public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
27
38
  await this.nativeWorldStateService.handleL2BlockAndMessages(
28
39
  block,
29
- Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
40
+ padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
30
41
  );
31
42
 
32
43
  this.blockNumber = block.header.globalVariables.blockNumber;
33
44
  }
34
45
 
35
46
  /**
36
- * Forces an immediate sync to an optionally provided minimum block number
47
+ * Forces an immediate sync to an optionally provided minimum block number.
37
48
  * @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
38
- * @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
49
+ * @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
39
50
  * @returns A promise that resolves with the block number the world state was synced to
40
51
  */
41
- public syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber> {
52
+ public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
42
53
  return Promise.resolve(this.blockNumber);
43
54
  }
44
55
 
@@ -57,6 +68,11 @@ export class TXESynchronizer implements WorldStateSynchronizer {
57
68
  return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
58
69
  }
59
70
 
71
+ /** Gets a snapshot at the given block number. The TXE has no reorgs, so the fork hash is not verified. */
72
+ public getVerifiedSnapshot(blockNumber: number, _blockHash: BlockHash): Promise<MerkleTreeReadOperations> {
73
+ return Promise.resolve(this.getSnapshot(blockNumber));
74
+ }
75
+
60
76
  /** Backups the db to the target path. */
61
77
  public backupTo(dstPath: string, compact?: boolean): Promise<Record<Exclude<SnapshotDataKeys, 'archiver'>, string>> {
62
78
  return this.nativeWorldStateService.backupTo(dstPath, compact);
@@ -70,8 +86,8 @@ export class TXESynchronizer implements WorldStateSynchronizer {
70
86
  throw new Error('TXE Synchronizer does not implement "status"');
71
87
  }
72
88
 
73
- public stop(): Promise<void> {
74
- throw new Error('TXE Synchronizer does not implement "stop"');
89
+ public async stop(): Promise<void> {
90
+ await this.closeIpc();
75
91
  }
76
92
 
77
93
  public stopSync(): Promise<void> {
@@ -85,4 +101,9 @@ export class TXESynchronizer implements WorldStateSynchronizer {
85
101
  public clear(): Promise<void> {
86
102
  throw new Error('TXE Synchronizer does not implement "clear"');
87
103
  }
104
+
105
+ /** Clean up IPC resources. */
106
+ public async closeIpc(): Promise<void> {
107
+ await this.avmSimulator?.[Symbol.asyncDispose]();
108
+ }
88
109
  }