@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (173) hide show
  1. package/dest/AuthRegistry-HMC7WEOJ.js +3 -0
  2. package/dest/AuthRegistry-HMC7WEOJ.js.map +7 -0
  3. package/dest/ContractClassRegistry-TXCDCFNC.js +3 -0
  4. package/dest/ContractClassRegistry-TXCDCFNC.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-2TZHWOTT.js +3 -0
  6. package/dest/ContractInstanceRegistry-2TZHWOTT.js.map +7 -0
  7. package/dest/FeeJuice-FDF3J2Q5.js +3 -0
  8. package/dest/FeeJuice-FDF3J2Q5.js.map +7 -0
  9. package/dest/HandshakeRegistry-C7JF4R54.js +3 -0
  10. package/dest/HandshakeRegistry-C7JF4R54.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-IGLO227K.js +3 -0
  12. package/dest/MultiCallEntrypoint-IGLO227K.js.map +7 -0
  13. package/dest/SchnorrAccount-KCIHUCXS.js +3 -0
  14. package/dest/SchnorrAccount-KCIHUCXS.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-PVR6XUSN.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-PVR6XUSN.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 +61 -0
  20. package/dest/bin/index.d.ts +1 -1
  21. package/dest/bin/index.js +3 -30
  22. package/dest/bin/index.js.map +7 -0
  23. package/dest/bin/oracle_test_server.d.ts +3 -0
  24. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  25. package/dest/bin/oracle_test_server.js +41 -0
  26. package/dest/chunk-32UHX7YY.js +3 -0
  27. package/dest/chunk-32UHX7YY.js.map +7 -0
  28. package/dest/chunk-FRF5YZEO.js +304 -0
  29. package/dest/chunk-FRF5YZEO.js.map +7 -0
  30. package/dest/chunk-O57S6W5S.js +260 -0
  31. package/dest/chunk-O57S6W5S.js.map +7 -0
  32. package/dest/constants.d.ts +7 -0
  33. package/dest/constants.d.ts.map +1 -0
  34. package/dest/constants.js +10 -0
  35. package/dest/dispatcher_pool.d.ts +67 -0
  36. package/dest/dispatcher_pool.d.ts.map +1 -0
  37. package/dest/dispatcher_pool.js +286 -0
  38. package/dest/index.d.ts +51 -7
  39. package/dest/index.d.ts.map +1 -1
  40. package/dest/index.js +75 -158
  41. package/dest/metafile.json +38497 -0
  42. package/dest/msgpackr_fr_extension.d.ts +2 -0
  43. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  44. package/dest/msgpackr_fr_extension.js +21 -0
  45. package/dest/oracle/interfaces.d.ts +65 -31
  46. package/dest/oracle/interfaces.d.ts.map +1 -1
  47. package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -0
  48. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  49. package/dest/oracle/test-resolver/default_fixtures.js +207 -0
  50. package/dest/oracle/test-resolver/index.d.ts +9 -0
  51. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  52. package/dest/oracle/test-resolver/index.js +32 -0
  53. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  54. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  55. package/dest/oracle/test-resolver/resolver.js +181 -0
  56. package/dest/oracle/txe_oracle_public_context.d.ts +41 -17
  57. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  58. package/dest/oracle/txe_oracle_public_context.js +69 -23
  59. package/dest/oracle/txe_oracle_registry.d.ts +169 -0
  60. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  61. package/dest/oracle/txe_oracle_registry.js +745 -0
  62. package/dest/oracle/txe_oracle_top_level_context.d.ts +66 -30
  63. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  64. package/dest/oracle/txe_oracle_top_level_context.js +630 -275
  65. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  66. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  67. package/dest/oracle/txe_oracle_version.js +14 -0
  68. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  69. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  70. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  71. package/dest/rpc_server.d.ts +14 -0
  72. package/dest/rpc_server.d.ts.map +1 -0
  73. package/dest/rpc_server.js +78 -0
  74. package/dest/rpc_translator.d.ts +112 -213
  75. package/dest/rpc_translator.d.ts.map +1 -1
  76. package/dest/rpc_translator.js +877 -550
  77. package/dest/server.bundle.js +3 -0
  78. package/dest/server.bundle.js.map +7 -0
  79. package/dest/state_machine/archiver.d.ts +23 -52
  80. package/dest/state_machine/archiver.d.ts.map +1 -1
  81. package/dest/state_machine/archiver.js +76 -99
  82. package/dest/state_machine/dummy_p2p_client.d.ts +31 -15
  83. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  84. package/dest/state_machine/dummy_p2p_client.js +63 -22
  85. package/dest/state_machine/global_variable_builder.d.ts +10 -4
  86. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  87. package/dest/state_machine/global_variable_builder.js +20 -5
  88. package/dest/state_machine/index.d.ts +14 -8
  89. package/dest/state_machine/index.d.ts.map +1 -1
  90. package/dest/state_machine/index.js +84 -27
  91. package/dest/state_machine/mock_epoch_cache.d.ts +29 -12
  92. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  93. package/dest/state_machine/mock_epoch_cache.js +50 -15
  94. package/dest/state_machine/synchronizer.d.ts +15 -6
  95. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  96. package/dest/state_machine/synchronizer.js +27 -13
  97. package/dest/txe_session.d.ts +102 -21
  98. package/dest/txe_session.d.ts.map +1 -1
  99. package/dest/txe_session.js +440 -76
  100. package/dest/utils/block_creation.d.ts +22 -7
  101. package/dest/utils/block_creation.d.ts.map +1 -1
  102. package/dest/utils/block_creation.js +40 -6
  103. package/dest/utils/encoding.d.ts +192 -0
  104. package/dest/utils/encoding.d.ts.map +1 -0
  105. package/dest/{util → utils}/encoding.js +8 -3
  106. package/dest/utils/expected_failure_error.d.ts +4 -0
  107. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  108. package/dest/utils/tx_effect_creation.d.ts +3 -3
  109. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  110. package/dest/utils/tx_effect_creation.js +3 -7
  111. package/dest/utils/txe_account_store.d.ts +10 -0
  112. package/dest/utils/txe_account_store.d.ts.map +1 -0
  113. package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
  114. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  115. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  116. package/dest/utils/txe_artifact_resolver.js +161 -0
  117. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  118. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  119. package/dest/utils/txe_public_contract_data_source.js +51 -0
  120. package/dest/worker.bundle.js +3 -0
  121. package/dest/worker.bundle.js.map +7 -0
  122. package/dest/worker.d.ts +2 -0
  123. package/dest/worker.d.ts.map +1 -0
  124. package/dest/worker.js +92 -0
  125. package/package.json +40 -22
  126. package/src/bin/check_txe_oracle_version.ts +70 -0
  127. package/src/bin/index.ts +11 -2
  128. package/src/bin/oracle_test_server.ts +51 -0
  129. package/src/constants.ts +13 -0
  130. package/src/dispatcher_pool.ts +317 -0
  131. package/src/index.ts +113 -201
  132. package/src/msgpackr_fr_extension.ts +23 -0
  133. package/src/oracle/interfaces.ts +68 -36
  134. package/src/oracle/test-resolver/default_fixtures.ts +282 -0
  135. package/src/oracle/test-resolver/index.ts +44 -0
  136. package/src/oracle/test-resolver/resolver.ts +245 -0
  137. package/src/oracle/txe_oracle_public_context.ts +83 -28
  138. package/src/oracle/txe_oracle_registry.ts +536 -0
  139. package/src/oracle/txe_oracle_top_level_context.ts +539 -199
  140. package/src/oracle/txe_oracle_version.ts +17 -0
  141. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  142. package/src/rpc_server.ts +87 -0
  143. package/src/rpc_translator.ts +1086 -909
  144. package/src/state_machine/archiver.ts +82 -115
  145. package/src/state_machine/dummy_p2p_client.ts +96 -33
  146. package/src/state_machine/global_variable_builder.ts +28 -9
  147. package/src/state_machine/index.ts +118 -44
  148. package/src/state_machine/mock_epoch_cache.ts +63 -23
  149. package/src/state_machine/synchronizer.ts +36 -14
  150. package/src/txe_session.ts +719 -125
  151. package/src/utils/block_creation.ts +51 -15
  152. package/src/{util → utils}/encoding.ts +9 -3
  153. package/src/utils/tx_effect_creation.ts +4 -13
  154. package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
  155. package/src/utils/txe_artifact_resolver.ts +217 -0
  156. package/src/utils/txe_public_contract_data_source.ts +60 -0
  157. package/src/worker.ts +98 -0
  158. package/dest/util/encoding.d.ts +0 -121
  159. package/dest/util/encoding.d.ts.map +0 -1
  160. package/dest/util/expected_failure_error.d.ts +0 -4
  161. package/dest/util/expected_failure_error.d.ts.map +0 -1
  162. package/dest/util/txe_account_data_provider.d.ts +0 -10
  163. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  164. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  165. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
  166. package/dest/util/txe_contract_data_provider.js +0 -22
  167. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  168. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  169. package/dest/util/txe_public_contract_data_source.js +0 -67
  170. package/src/util/txe_contract_data_provider.ts +0 -36
  171. package/src/util/txe_public_contract_data_source.ts +0 -85
  172. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  173. /package/src/{util → utils}/expected_failure_error.ts +0 -0
@@ -1,151 +1,118 @@
1
- import { ArchiverStoreHelper, KVArchiverDataStore, type PublishedL2Block } from '@aztec/archiver';
1
+ import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
2
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';
3
5
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
- import { Fr } from '@aztec/foundation/fields';
5
6
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
6
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { L2Block, L2BlockSource, L2Tips, ValidateBlockResult } from '@aztec/stdlib/block';
8
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
9
- import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
10
- import type { BlockHeader } from '@aztec/stdlib/tx';
11
- import type { UInt64 } from '@aztec/stdlib/types';
12
-
13
- // We are extending the ArchiverDataStoreHelper here because it provides most of the endpoints needed by the
14
- // node for reading from and writing to state, without needing any of the extra overhead that the Archiver itself
15
- // requires (i.e. an L1 client)
16
- export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
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
+
17
27
  constructor(db: AztecAsyncKVStore) {
18
- super(new KVArchiverDataStore(db, 9999));
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
+ );
19
35
  }
20
36
 
21
- public override async addBlocks(blocks: PublishedL2Block[]): Promise<boolean> {
22
- const opResults = await Promise.all([
23
- this.store.addLogs(blocks.map(block => block.block)),
24
- this.store.addBlocks(blocks),
25
- ]);
37
+ public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
38
+ await this.updater.addCheckpoints(checkpoints, result);
39
+ }
26
40
 
27
- return opResults.every(Boolean);
41
+ public getRollupAddress(): Promise<EthAddress> {
42
+ throw new Error('TXE Archiver does not implement "getRollupAddress"');
28
43
  }
29
44
 
30
- /**
31
- * Gets the number of the latest L2 block processed by the block source implementation.
32
- * @returns The number of the latest L2 block processed by the block source implementation.
33
- */
34
- public getBlockNumber(): Promise<number> {
35
- return this.store.getSynchedL2BlockNumber();
45
+ public getRegistryAddress(): Promise<EthAddress> {
46
+ throw new Error('TXE Archiver does not implement "getRegistryAddress"');
36
47
  }
37
48
 
38
- /**
39
- * Gets the number of the latest L2 block proven seen by the block source implementation.
40
- * @returns The number of the latest L2 block proven seen by the block source implementation.
41
- */
42
- public getProvenBlockNumber(): Promise<number> {
43
- return this.store.getSynchedL2BlockNumber();
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);
44
53
  }
45
54
 
46
- /**
47
- * Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
48
- * @param number - The block number to return (inclusive).
49
- * @returns The requested L2 block.
50
- */
51
- public override async getPublishedBlock(number: number): Promise<PublishedL2Block | undefined> {
52
- // If the number provided is -ve, then return the latest block.
53
- if (number < 0) {
54
- number = await this.store.getSynchedL2BlockNumber();
55
- }
56
- if (number == 0) {
57
- return undefined;
58
- }
59
- const blocks = await this.store.getPublishedBlocks(number, 1);
60
- return blocks.length === 0 ? undefined : blocks[0];
55
+ public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
56
+ return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
61
57
  }
62
58
 
63
- /**
64
- * Gets an l2 block. If a negative number is passed, the block returned is the most recent.
65
- * @param number - The block number to return (inclusive).
66
- * @returns The requested L2 block.
67
- */
68
- public getBlock(number: number | 'latest'): Promise<L2Block | undefined> {
69
- return this.getPublishedBlock(number != 'latest' ? number : -1).then(block => block?.block);
59
+ public getL1Timestamp(): Promise<bigint | undefined> {
60
+ throw new Error('TXE Archiver does not implement "getL1Timestamp"');
70
61
  }
71
62
 
72
- /**
73
- * Gets an l2 block header.
74
- * @param number - The block number to return or 'latest' for the most recent one.
75
- * @returns The requested L2 block header.
76
- */
77
- public async getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined> {
78
- if (number === 'latest') {
79
- number = await this.store.getSynchedL2BlockNumber();
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');
80
69
  }
81
- if (number === 0) {
82
- return undefined;
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');
83
73
  }
84
- const headers = await this.store.getBlockHeaders(number, 1);
85
- return headers.length === 0 ? undefined : headers[0];
86
- }
87
74
 
88
- public getBlocks(from: number, limit: number, _proven?: boolean): Promise<L2Block[]> {
89
- return this.getPublishedBlocks(from, limit).then(blocks => blocks.map(b => b.block));
90
- }
91
-
92
- public getL2SlotNumber(): Promise<bigint> {
93
- throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
94
- }
75
+ const number = latestBlockData.header.globalVariables.blockNumber;
76
+ const hash = latestBlockData.blockHash.toString();
95
77
 
96
- public getL2EpochNumber(): Promise<bigint> {
97
- throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
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
+ };
98
96
  }
99
97
 
100
- public getBlocksForEpoch(_epochNumber: bigint): Promise<L2Block[]> {
101
- throw new Error('TXE Archiver does not implement "getBlocksForEpoch"');
98
+ public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
99
+ throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
102
100
  }
103
101
 
104
- public getBlockHeadersForEpoch(_epochNumber: bigint): Promise<BlockHeader[]> {
105
- throw new Error('TXE Archiver does not implement "getBlockHeadersForEpoch"');
102
+ public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
103
+ throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
106
104
  }
107
105
 
108
- public isEpochComplete(_epochNumber: bigint): Promise<boolean> {
106
+ public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
109
107
  throw new Error('TXE Archiver does not implement "isEpochComplete"');
110
108
  }
111
109
 
112
- public getL2Tips(): Promise<L2Tips> {
113
- throw new Error('TXE Archiver does not implement "getL2Tips"');
114
- }
115
-
116
- public getL1Constants(): Promise<L1RollupConstants> {
117
- throw new Error('TXE Archiver does not implement "getL2Constants"');
118
- }
119
-
120
- public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
121
- return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
122
- }
123
-
124
110
  public syncImmediate(): Promise<void> {
125
111
  throw new Error('TXE Archiver does not implement "syncImmediate"');
126
112
  }
127
113
 
128
- public getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined> {
129
- throw new Error('TXE Archiver does not implement "getContract"');
130
- }
131
-
132
- public getRollupAddress(): Promise<EthAddress> {
133
- throw new Error('TXE Archiver does not implement "getRollupAddress"');
134
- }
135
-
136
- public getRegistryAddress(): Promise<EthAddress> {
137
- throw new Error('TXE Archiver does not implement "getRegistryAddress"');
138
- }
139
-
140
- public getL1Timestamp(): Promise<bigint> {
141
- throw new Error('TXE Archiver does not implement "getL1Timestamp"');
142
- }
143
-
144
- public isPendingChainInvalid(): Promise<boolean> {
145
- return Promise.resolve(false);
146
- }
147
-
148
- public override getPendingChainValidationStatus(): Promise<ValidateBlockResult> {
149
- return Promise.resolve({ valid: true });
114
+ public getL2ToL1MembershipWitness(): Promise<undefined> {
115
+ // TXE doesn't drive the L2-to-L1 message flow through this archiver.
116
+ return Promise.resolve(undefined);
150
117
  }
151
118
  }
@@ -1,23 +1,34 @@
1
+ import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type {
2
3
  AuthRequest,
3
4
  ENR,
4
5
  P2P,
5
6
  P2PBlockReceivedCallback,
7
+ P2PCheckpointAttestationCallback,
8
+ P2PCheckpointReceivedCallback,
6
9
  P2PConfig,
10
+ P2PDuplicateAttestationCallback,
11
+ P2PDuplicateProposalCallback,
12
+ P2POversizedProposalCallback,
7
13
  P2PSyncState,
8
14
  PeerId,
9
15
  ReqRespSubProtocol,
10
16
  ReqRespSubProtocolHandler,
11
- ReqRespSubProtocolValidators,
12
17
  StatusMessage,
13
18
  } from '@aztec/p2p';
14
19
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
15
- import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
16
- import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
17
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
20
+ import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
21
+ import type {
22
+ BlockProposal,
23
+ CheckpointAttestation,
24
+ CheckpointProposal,
25
+ CheckpointProposalCore,
26
+ TopicType,
27
+ } from '@aztec/stdlib/p2p';
28
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
18
29
 
19
30
  export class DummyP2P implements P2P {
20
- public validate(_txs: Tx[]): Promise<void> {
31
+ public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
21
32
  return Promise.resolve();
22
33
  }
23
34
 
@@ -37,14 +48,34 @@ export class DummyP2P implements P2P {
37
48
  throw new Error('DummyP2P does not implement "getPeers"');
38
49
  }
39
50
 
51
+ public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
52
+ return Promise.resolve(0);
53
+ }
54
+
40
55
  public broadcastProposal(_proposal: BlockProposal): Promise<void> {
41
56
  throw new Error('DummyP2P does not implement "broadcastProposal"');
42
57
  }
43
58
 
59
+ public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
60
+ throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
61
+ }
62
+
63
+ public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
64
+ throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
65
+ }
66
+
44
67
  public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
45
68
  throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
46
69
  }
47
70
 
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"');
77
+ }
78
+
48
79
  public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
49
80
  throw new Error('DummyP2P does not implement "requestTxs"');
50
81
  }
@@ -57,8 +88,8 @@ export class DummyP2P implements P2P {
57
88
  throw new Error('DummyP2P does not implement "sendTx"');
58
89
  }
59
90
 
60
- public deleteTxs(_txHashes: TxHash[]): Promise<void> {
61
- throw new Error('DummyP2P does not implement "deleteTxs"');
91
+ public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
92
+ throw new Error('DummyP2P does not implement "handleFailedExecution"');
62
93
  }
63
94
 
64
95
  public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
@@ -74,17 +105,27 @@ export class DummyP2P implements P2P {
74
105
  }
75
106
 
76
107
  public getTxStatus(_txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
77
- throw new Error('DummyP2P does not implement "getTxStatus"');
108
+ // In TXE there is no concept of transactions but we need to implement this because of tagging. We return 'mined'
109
+ // tx status for any tx hash.
110
+ return Promise.resolve('mined');
78
111
  }
79
112
 
80
113
  public iteratePendingTxs(): AsyncIterableIterator<Tx> {
81
114
  throw new Error('DummyP2P does not implement "iteratePendingTxs"');
82
115
  }
83
116
 
117
+ public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
118
+ throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
119
+ }
120
+
84
121
  public getPendingTxCount(): Promise<number> {
85
122
  throw new Error('DummyP2P does not implement "getPendingTxCount"');
86
123
  }
87
124
 
125
+ public hasEligiblePendingTxs(_minCount: number): Promise<boolean> {
126
+ throw new Error('DummyP2P does not implement "hasEligiblePendingTxs"');
127
+ }
128
+
88
129
  public start(): Promise<void> {
89
130
  throw new Error('DummyP2P does not implement "start"');
90
131
  }
@@ -109,20 +150,34 @@ export class DummyP2P implements P2P {
109
150
  throw new Error('DummyP2P does not implement "isP2PClient"');
110
151
  }
111
152
 
153
+ public getTxProvider(): ITxProvider {
154
+ throw new Error('DummyP2P does not implement "getTxProvider"');
155
+ }
156
+
112
157
  public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
113
158
  throw new Error('DummyP2P does not implement "getTxsByHash"');
114
159
  }
115
160
 
116
- public getAttestationsForSlot(_slot: bigint, _proposalId?: string): Promise<BlockAttestation[]> {
117
- throw new Error('DummyP2P does not implement "getAttestationForSlot"');
161
+ public getCheckpointAttestationsForSlot(
162
+ _slot: SlotNumber,
163
+ _proposalPayloadHash?: CheckpointProposalHash,
164
+ ): Promise<CheckpointAttestation[]> {
165
+ throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
118
166
  }
119
167
 
120
- public deleteAttestation(_attestation: BlockAttestation): Promise<void> {
121
- return Promise.resolve();
168
+ public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
169
+ throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
170
+ }
171
+
172
+ public getProposalsForSlot(_slot: SlotNumber): Promise<{
173
+ blockProposals: BlockProposal[];
174
+ checkpointProposals: CheckpointProposalCore[];
175
+ }> {
176
+ return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
122
177
  }
123
178
 
124
- public addAttestations(_attestations: BlockAttestation[]): Promise<void> {
125
- throw new Error('DummyP2P does not implement "addAttestations"');
179
+ public hasCheckpointProposalForSlot(_slot: SlotNumber): Promise<boolean> {
180
+ return Promise.resolve(false);
126
181
  }
127
182
 
128
183
  public getL2BlockHash(_number: number): Promise<string | undefined> {
@@ -145,14 +200,6 @@ export class DummyP2P implements P2P {
145
200
  throw new Error('DummyP2P does not implement "sync"');
146
201
  }
147
202
 
148
- public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
149
- throw new Error('DummyP2P does not implement "requestTxsByHash"');
150
- }
151
-
152
- public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
153
- throw new Error('DummyP2P does not implement "getTxs"');
154
- }
155
-
156
203
  public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
157
204
  throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
158
205
  }
@@ -161,10 +208,6 @@ export class DummyP2P implements P2P {
161
208
  throw new Error('DummyP2P does not implement "hasTxsInPool"');
162
209
  }
163
210
 
164
- public addTxsToPool(_txs: Tx[]): Promise<number> {
165
- throw new Error('DummyP2P does not implement "addTxs"');
166
- }
167
-
168
211
  public getSyncedLatestBlockNum(): Promise<number> {
169
212
  throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
170
213
  }
@@ -177,15 +220,15 @@ export class DummyP2P implements P2P {
177
220
  throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
178
221
  }
179
222
 
180
- markTxsAsNonEvictable(_: TxHash[]): Promise<void> {
181
- throw new Error('DummyP2P does not implement "markTxsAsNonEvictable".');
223
+ protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
224
+ throw new Error('DummyP2P does not implement "protectTxs".');
182
225
  }
183
226
 
184
- addReqRespSubProtocol(
185
- _subProtocol: ReqRespSubProtocol,
186
- _handler: ReqRespSubProtocolHandler,
187
- _validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
188
- ): Promise<void> {
227
+ prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
228
+ return Promise.resolve();
229
+ }
230
+
231
+ addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
189
232
  throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
190
233
  }
191
234
  handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
@@ -194,4 +237,24 @@ export class DummyP2P implements P2P {
194
237
 
195
238
  //This is no-op
196
239
  public registerThisValidatorAddresses(_address: EthAddress[]): void {}
240
+
241
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
242
+ throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
243
+ }
244
+
245
+ public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {
246
+ throw new Error('DummyP2P does not implement "registerOversizedProposalCallback"');
247
+ }
248
+
249
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
250
+ throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
251
+ }
252
+
253
+ public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
254
+ throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
255
+ }
256
+
257
+ public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
258
+ throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
259
+ }
197
260
  }
@@ -1,20 +1,39 @@
1
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
2
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
1
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import { GasFees } from '@aztec/stdlib/gas';
6
+ import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
4
7
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
5
- import { type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
8
+ import type { CheckpointGlobalVariables, FeeProvider, GlobalVariableBuilder } from '@aztec/stdlib/tx';
6
9
 
7
- export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
8
- public getCurrentBaseFees(): Promise<GasFees> {
10
+ /** Simple FeeProvider for TXE that returns zero fees. */
11
+ export class TXEFeeProvider implements FeeProvider {
12
+ public getCurrentMinFees(): Promise<GasFees> {
9
13
  return Promise.resolve(new GasFees(0, 0));
10
14
  }
11
15
 
12
- public buildGlobalVariables(
13
- _blockNumber: number,
16
+ public getPredictedMinFees(): Promise<GasFees[]> {
17
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
18
+ }
19
+ }
20
+
21
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
22
+ public buildCheckpointGlobalVariables(
14
23
  _coinbase: EthAddress,
15
24
  _feeRecipient: AztecAddress,
16
- _slotNumber?: bigint,
17
- ): Promise<GlobalVariables> {
18
- return Promise.resolve(makeGlobalVariables());
25
+ _slotNumber: SlotNumber,
26
+ _simulationOverridesPlan?: SimulationOverridesPlan,
27
+ ): Promise<CheckpointGlobalVariables> {
28
+ const vars = makeGlobalVariables();
29
+ return Promise.resolve({
30
+ chainId: vars.chainId,
31
+ version: vars.version,
32
+ slotNumber: vars.slotNumber,
33
+ timestamp: vars.timestamp,
34
+ coinbase: vars.coinbase,
35
+ feeRecipient: vars.feeRecipient,
36
+ gasFees: vars.gasFees,
37
+ });
19
38
  }
20
39
  }