@aztec/ethereum 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (188) hide show
  1. package/dest/client.d.ts +16 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +27 -7
  4. package/dest/config.d.ts +24 -32
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +63 -62
  7. package/dest/contracts/chain_state_override.d.ts +78 -0
  8. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  9. package/dest/contracts/chain_state_override.js +137 -0
  10. package/dest/contracts/fee_asset_handler.d.ts +6 -5
  11. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_handler.js +11 -9
  13. package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
  14. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  15. package/dest/contracts/fee_asset_price_oracle.js +656 -0
  16. package/dest/contracts/governance.d.ts +110 -33
  17. package/dest/contracts/governance.d.ts.map +1 -1
  18. package/dest/contracts/governance.js +207 -16
  19. package/dest/contracts/governance_proposer.d.ts +33 -1
  20. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  21. package/dest/contracts/governance_proposer.js +438 -10
  22. package/dest/contracts/inbox.d.ts +22 -1
  23. package/dest/contracts/inbox.d.ts.map +1 -1
  24. package/dest/contracts/inbox.js +42 -2
  25. package/dest/contracts/index.d.ts +6 -3
  26. package/dest/contracts/index.d.ts.map +1 -1
  27. package/dest/contracts/index.js +5 -2
  28. package/dest/contracts/log.d.ts +13 -0
  29. package/dest/contracts/log.d.ts.map +1 -0
  30. package/dest/contracts/log.js +1 -0
  31. package/dest/contracts/multicall.d.ts +127 -12
  32. package/dest/contracts/multicall.d.ts.map +1 -1
  33. package/dest/contracts/multicall.js +201 -93
  34. package/dest/contracts/outbox.d.ts +58 -0
  35. package/dest/contracts/outbox.d.ts.map +1 -0
  36. package/dest/contracts/outbox.js +109 -0
  37. package/dest/contracts/registry.d.ts +3 -1
  38. package/dest/contracts/registry.d.ts.map +1 -1
  39. package/dest/contracts/registry.js +30 -1
  40. package/dest/contracts/rollup.d.ts +5409 -115
  41. package/dest/contracts/rollup.d.ts.map +1 -1
  42. package/dest/contracts/rollup.js +1027 -189
  43. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
  44. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  45. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
  46. package/dest/deploy_aztec_l1_contracts.d.ts +20 -9
  47. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  48. package/dest/deploy_aztec_l1_contracts.js +113 -37
  49. package/dest/deploy_l1_contract.js +3 -3
  50. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  51. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  52. package/dest/generated/l1-contracts-defaults.js +30 -0
  53. package/dest/l1_artifacts.d.ts +18360 -16454
  54. package/dest/l1_artifacts.d.ts.map +1 -1
  55. package/dest/l1_artifacts.js +9 -24
  56. package/dest/l1_contract_addresses.d.ts +61 -65
  57. package/dest/l1_contract_addresses.d.ts.map +1 -1
  58. package/dest/l1_contract_addresses.js +101 -82
  59. package/dest/l1_reader.d.ts +5 -5
  60. package/dest/l1_reader.d.ts.map +1 -1
  61. package/dest/l1_reader.js +9 -7
  62. package/dest/l1_tx_utils/config.d.ts +7 -1
  63. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  64. package/dest/l1_tx_utils/config.js +14 -1
  65. package/dest/l1_tx_utils/constants.d.ts +1 -1
  66. package/dest/l1_tx_utils/constants.js +2 -2
  67. package/dest/l1_tx_utils/factory.d.ts +18 -10
  68. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  69. package/dest/l1_tx_utils/factory.js +17 -7
  70. package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
  71. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
  72. package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
  73. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
  74. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
  75. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
  76. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
  77. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
  78. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
  79. package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
  80. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
  81. package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
  82. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
  83. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
  84. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
  85. package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
  86. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
  87. package/dest/l1_tx_utils/index-blobs.js +2 -2
  88. package/dest/l1_tx_utils/index.d.ts +2 -1
  89. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  90. package/dest/l1_tx_utils/index.js +1 -0
  91. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
  92. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
  93. package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
  94. package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
  95. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  96. package/dest/l1_tx_utils/l1_tx_utils.js +101 -66
  97. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
  98. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  99. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +25 -58
  100. package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
  101. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  102. package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
  103. package/dest/publisher_manager.d.ts +21 -6
  104. package/dest/publisher_manager.d.ts.map +1 -1
  105. package/dest/publisher_manager.js +81 -7
  106. package/dest/queries.d.ts +14 -3
  107. package/dest/queries.d.ts.map +1 -1
  108. package/dest/queries.js +74 -7
  109. package/dest/test/chain_monitor.d.ts +23 -3
  110. package/dest/test/chain_monitor.d.ts.map +1 -1
  111. package/dest/test/chain_monitor.js +39 -4
  112. package/dest/test/eth_cheat_codes.d.ts +24 -4
  113. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  114. package/dest/test/eth_cheat_codes.js +17 -4
  115. package/dest/test/index.d.ts +1 -3
  116. package/dest/test/index.d.ts.map +1 -1
  117. package/dest/test/index.js +0 -2
  118. package/dest/test/rollup_cheat_codes.d.ts +34 -3
  119. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  120. package/dest/test/rollup_cheat_codes.js +75 -6
  121. package/dest/test/start_anvil.d.ts +23 -3
  122. package/dest/test/start_anvil.d.ts.map +1 -1
  123. package/dest/test/start_anvil.js +143 -29
  124. package/dest/test/upgrade_utils.js +2 -2
  125. package/dest/utils.d.ts +9 -1
  126. package/dest/utils.d.ts.map +1 -1
  127. package/dest/utils.js +81 -12
  128. package/package.json +9 -10
  129. package/src/client.ts +28 -2
  130. package/src/config.ts +81 -63
  131. package/src/contracts/README.md +157 -0
  132. package/src/contracts/chain_state_override.ts +200 -0
  133. package/src/contracts/fee_asset_handler.ts +10 -7
  134. package/src/contracts/fee_asset_price_oracle.ts +285 -0
  135. package/src/contracts/governance.ts +279 -13
  136. package/src/contracts/governance_proposer.ts +58 -2
  137. package/src/contracts/inbox.ts +62 -2
  138. package/src/contracts/index.ts +5 -2
  139. package/src/contracts/log.ts +13 -0
  140. package/src/contracts/multicall.ts +243 -102
  141. package/src/contracts/outbox.ts +128 -0
  142. package/src/contracts/registry.ts +31 -1
  143. package/src/contracts/rollup.ts +728 -148
  144. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
  145. package/src/deploy_aztec_l1_contracts.ts +137 -47
  146. package/src/deploy_l1_contract.ts +3 -3
  147. package/src/generated/l1-contracts-defaults.ts +32 -0
  148. package/src/l1_artifacts.ts +12 -35
  149. package/src/l1_contract_addresses.ts +120 -94
  150. package/src/l1_reader.ts +17 -10
  151. package/src/l1_tx_utils/config.ts +20 -0
  152. package/src/l1_tx_utils/constants.ts +2 -2
  153. package/src/l1_tx_utils/factory.ts +31 -31
  154. package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
  155. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
  156. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
  157. package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
  158. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
  159. package/src/l1_tx_utils/index-blobs.ts +2 -2
  160. package/src/l1_tx_utils/index.ts +1 -0
  161. package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
  162. package/src/l1_tx_utils/l1_tx_utils.ts +99 -48
  163. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +31 -66
  164. package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
  165. package/src/publisher_manager.ts +107 -10
  166. package/src/queries.ts +81 -7
  167. package/src/test/chain_monitor.ts +66 -4
  168. package/src/test/eth_cheat_codes.ts +16 -4
  169. package/src/test/index.ts +0 -2
  170. package/src/test/rollup_cheat_codes.ts +82 -6
  171. package/src/test/start_anvil.ts +177 -29
  172. package/src/test/upgrade_utils.ts +2 -2
  173. package/src/utils.ts +88 -14
  174. package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
  175. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  176. package/dest/contracts/empire_slashing_proposer.js +0 -209
  177. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  178. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  179. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  180. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  181. package/dest/test/delayed_tx_utils.d.ts +0 -13
  182. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  183. package/dest/test/delayed_tx_utils.js +0 -28
  184. package/dest/test/tx_delayer.d.ts +0 -36
  185. package/dest/test/tx_delayer.d.ts.map +0 -1
  186. package/src/contracts/empire_slashing_proposer.ts +0 -270
  187. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  188. package/src/test/delayed_tx_utils.ts +0 -52
@@ -12,15 +12,6 @@ import {
12
12
  type PriorityFeeStrategyResult,
13
13
  } from './types.js';
14
14
 
15
- /**
16
- * Type for the promises required by the competitive strategy
17
- */
18
- type P75AllTxsStrategyPromises = {
19
- networkEstimate: Promise<bigint>;
20
- pendingBlock: Promise<Awaited<ReturnType<ViemClient['getBlock']>> | null>;
21
- feeHistory: Promise<Awaited<ReturnType<ViemClient['getFeeHistory']>> | null>;
22
- };
23
-
24
15
  /**
25
16
  * Fetches historical blocks and calculates reward percentiles for blob transactions only.
26
17
  * Returns data in the same format as getFeeHistory for easy drop-in replacement.
@@ -114,38 +105,51 @@ export async function getBlobPriorityFeeHistory(
114
105
  * Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
115
106
  * Falls back to network estimate if data is unavailable.
116
107
  */
117
- export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStrategyPromises> = {
108
+ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy = {
118
109
  name: 'Competitive (P75 + History) - Blob Txs Only',
119
110
  id: 'p75_pending_txs_and_history_blob_txs_only',
120
111
 
121
- getRequiredPromises(client: ViemClient, opts: PriorityFeeStrategyContext): P75AllTxsStrategyPromises {
122
- return {
123
- networkEstimate: client.estimateMaxPriorityFeePerGas().catch(() => 0n),
124
- pendingBlock: client.getBlock({ blockTag: 'pending', includeTransactions: true }).catch(() => null),
125
- feeHistory: opts.isBlobTx
126
- ? getBlobPriorityFeeHistory(client, HISTORICAL_BLOCK_COUNT, [75])
127
- : client
128
- .getFeeHistory({
129
- blockCount: HISTORICAL_BLOCK_COUNT,
130
- rewardPercentiles: [75],
131
- blockTag: 'latest',
132
- })
133
- .catch(() => null),
134
- };
135
- },
136
-
137
- calculate(
138
- results: {
139
- [K in keyof P75AllTxsStrategyPromises]: PromiseSettledResult<Awaited<P75AllTxsStrategyPromises[K]>>;
140
- },
141
- context: PriorityFeeStrategyContext,
142
- ): PriorityFeeStrategyResult {
143
- const { logger } = context;
112
+ async execute(client: ViemClient, context: PriorityFeeStrategyContext): Promise<PriorityFeeStrategyResult> {
113
+ const { isBlobTx, logger } = context;
114
+
115
+ // Fire all RPC calls in parallel
116
+ const [latestBlockResult, blobBaseFeeResult, networkEstimateResult, pendingBlockResult, feeHistoryResult] =
117
+ await Promise.allSettled([
118
+ client.getBlock({ blockTag: 'latest' }),
119
+ isBlobTx ? client.getBlobBaseFee() : Promise.resolve(undefined),
120
+ client.estimateMaxPriorityFeePerGas().catch(() => 0n),
121
+ client.getBlock({ blockTag: 'pending', includeTransactions: true }).catch(() => null),
122
+ isBlobTx
123
+ ? getBlobPriorityFeeHistory(client, HISTORICAL_BLOCK_COUNT, [75])
124
+ : client
125
+ .getFeeHistory({
126
+ blockCount: HISTORICAL_BLOCK_COUNT,
127
+ rewardPercentiles: [75],
128
+ blockTag: 'latest',
129
+ })
130
+ .catch(() => null),
131
+ ]);
132
+
133
+ // Extract latest block (required)
134
+ if (latestBlockResult.status === 'rejected') {
135
+ throw new Error(`Failed to get latest block: ${latestBlockResult.reason}`);
136
+ }
137
+ const latestBlock = latestBlockResult.value;
138
+
139
+ // Extract blob base fee (only for blob txs)
140
+ let blobBaseFee: bigint | undefined;
141
+ if (isBlobTx) {
142
+ if (blobBaseFeeResult.status === 'fulfilled' && typeof blobBaseFeeResult.value === 'bigint') {
143
+ blobBaseFee = blobBaseFeeResult.value;
144
+ } else {
145
+ logger?.warn('Failed to get L1 blob base fee');
146
+ }
147
+ }
144
148
 
145
- // Extract network estimate from settled result
149
+ // Extract network estimate
146
150
  const networkEstimate =
147
- results.networkEstimate.status === 'fulfilled' && typeof results.networkEstimate.value === 'bigint'
148
- ? results.networkEstimate.value
151
+ networkEstimateResult.status === 'fulfilled' && typeof networkEstimateResult.value === 'bigint'
152
+ ? networkEstimateResult.value
149
153
  : 0n;
150
154
 
151
155
  let competitiveFee = networkEstimate;
@@ -153,8 +157,8 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStr
153
157
  networkEstimateGwei: formatGwei(networkEstimate),
154
158
  };
155
159
 
156
- // Extract pending block from settled result
157
- const pendingBlock = results.pendingBlock.status === 'fulfilled' ? results.pendingBlock.value : null;
160
+ // Extract pending block
161
+ const pendingBlock = pendingBlockResult.status === 'fulfilled' ? pendingBlockResult.value : null;
158
162
 
159
163
  // Analyze pending block transactions
160
164
  if (pendingBlock?.transactions && pendingBlock.transactions.length > 0) {
@@ -163,14 +167,12 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStr
163
167
  if (typeof tx === 'string') {
164
168
  return 0n;
165
169
  }
166
- if (context.isBlobTx) {
170
+ if (isBlobTx) {
167
171
  if (!isBlobTransaction(tx)) {
168
172
  return 0n;
169
173
  }
170
174
  }
171
- const fee = tx.maxPriorityFeePerGas || 0n;
172
-
173
- return fee;
175
+ return tx.maxPriorityFeePerGas || 0n;
174
176
  })
175
177
  .filter((fee: bigint) => fee > 0n);
176
178
 
@@ -191,8 +193,8 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStr
191
193
  }
192
194
  }
193
195
 
194
- // Extract fee history from settled result
195
- const feeHistory = results.feeHistory.status === 'fulfilled' ? results.feeHistory.value : null;
196
+ // Extract fee history
197
+ const feeHistory = feeHistoryResult.status === 'fulfilled' ? feeHistoryResult.value : null;
196
198
 
197
199
  // Analyze fee history
198
200
  if (feeHistory?.reward && feeHistory.reward.length > 0) {
@@ -205,7 +207,7 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStr
205
207
 
206
208
  // Debug: Log suspicious fees from history
207
209
  if (medianHistoricalFee > 100n * WEI_CONST) {
208
- logger?.warn('Suspicious high fee in history', {
210
+ logger?.debug('Suspicious high fee in history', {
209
211
  historicalMedian: formatGwei(medianHistoricalFee),
210
212
  allP75Fees: percentile75Fees.map(f => formatGwei(f)),
211
213
  });
@@ -235,6 +237,8 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStr
235
237
 
236
238
  return {
237
239
  priorityFee: competitiveFee,
240
+ latestBlock,
241
+ blobBaseFee,
238
242
  debugInfo,
239
243
  };
240
244
  },
@@ -1,5 +1,7 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
 
3
+ import type { Block } from 'viem';
4
+
3
5
  import type { ViemClient } from '../../types.js';
4
6
  import type { L1TxUtilsConfig } from '../config.js';
5
7
 
@@ -14,12 +16,16 @@ export const HISTORICAL_BLOCK_COUNT = 5;
14
16
  export interface PriorityFeeStrategyResult {
15
17
  /** The calculated priority fee in wei */
16
18
  priorityFee: bigint;
19
+ /** The latest block (fetched as part of the strategy) */
20
+ latestBlock: Block;
21
+ /** The blob base fee (only present for blob transactions) */
22
+ blobBaseFee?: bigint;
17
23
  /** Optional debug info about how the fee was calculated */
18
24
  debugInfo?: Record<string, string | number>;
19
25
  }
20
26
 
21
27
  /**
22
- * Context passed to the strategy calculation function (excluding promise results)
28
+ * Context passed to the strategy function
23
29
  */
24
30
  export interface PriorityFeeStrategyContext {
25
31
  /** Gas configuration */
@@ -32,57 +38,19 @@ export interface PriorityFeeStrategyContext {
32
38
 
33
39
  /**
34
40
  * A strategy for calculating the priority fee for L1 transactions.
35
- * Each strategy defines what promises it needs and how to calculate the fee from their results.
36
- * This design allows strategies to be plugged into both L1FeeAnalyzer and ReadOnlyL1TxUtils.
41
+ * The function handles all RPC calls and returns
42
+ * the priority fee, along with any block data needed by the caller.
37
43
  */
38
- export interface PriorityFeeStrategy<TPromises extends Record<string, Promise<any>> = Record<string, Promise<any>>> {
44
+ export type PriorityFeeStrategy = {
39
45
  /** Human-readable name for logging */
40
46
  name: string;
41
47
  /** Unique identifier for metrics */
42
48
  id: string;
43
49
  /**
44
- * Returns the promises that need to be executed for this strategy.
45
- * These will be run in parallel with Promise.allSettled.
50
+ * Calculate the priority fee.
46
51
  * @param client - The viem client to use for RPC calls
47
- * @returns An object of promises keyed by name
48
- */
49
- getRequiredPromises(client: ViemClient, opts: Partial<PriorityFeeStrategyContext>): TPromises;
50
- /**
51
- * Calculate the priority fee based on the settled promise results.
52
- * @param results - The settled results of the promises from getRequiredPromises
53
52
  * @param context - Contains gas config, whether it's a blob tx, and logger
54
- * @returns The calculated priority fee result
53
+ * @returns The calculated priority fee result including block data
55
54
  */
56
- calculate(
57
- results: { [K in keyof TPromises]: PromiseSettledResult<Awaited<TPromises[K]>> },
58
- context: PriorityFeeStrategyContext,
59
- ): PriorityFeeStrategyResult;
60
- }
61
-
62
- /**
63
- * Helper function to execute a strategy's promises and calculate the result.
64
- * This can be used by both L1FeeAnalyzer and ReadOnlyL1TxUtils.
65
- * @param strategy - The strategy to execute
66
- * @param client - The viem client to use for RPC calls
67
- * @param context - The context for calculation
68
- * @returns The strategy result
69
- */
70
- export async function executeStrategy<TPromises extends Record<string, Promise<any>>>(
71
- strategy: PriorityFeeStrategy<TPromises>,
72
- client: ViemClient,
73
- context: PriorityFeeStrategyContext,
74
- ): Promise<PriorityFeeStrategyResult> {
75
- const promises = strategy.getRequiredPromises(client, { isBlobTx: context.isBlobTx });
76
- const keys = Object.keys(promises) as Array<keyof TPromises>;
77
- const promiseArray = keys.map(k => promises[k]);
78
-
79
- const settledResults = await Promise.allSettled(promiseArray);
80
-
81
- // Reconstruct the results object with the same keys, preserving the type mapping
82
- const results = {} as { [K in keyof TPromises]: PromiseSettledResult<Awaited<TPromises[K]>> };
83
- keys.forEach((key, index) => {
84
- results[key] = settledResults[index] as PromiseSettledResult<Awaited<TPromises[typeof key]>>;
85
- });
86
-
87
- return strategy.calculate(results, context);
88
- }
55
+ execute: (client: ViemClient, context: PriorityFeeStrategyContext) => Promise<PriorityFeeStrategyResult>;
56
+ };
@@ -1,25 +1,27 @@
1
+ import type { BlobKzgInstance } from '@aztec/blob-lib/types';
1
2
  import { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { Logger } from '@aztec/foundation/log';
3
4
  import type { DateProvider } from '@aztec/foundation/timer';
4
5
 
5
6
  import { type Hex, encodeFunctionData } from 'viem';
6
7
 
7
- import type { EthSigner } from '../eth-signer/eth-signer.js';
8
8
  import { FORWARDER_ABI } from '../forwarder_proxy.js';
9
- import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
9
+ import type { ViemClient } from '../types.js';
10
10
  import type { L1TxUtilsConfig } from './config.js';
11
+ import type { L1SignerSource } from './factory.js';
12
+ import { resolveSignerSource } from './factory.js';
11
13
  import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
12
- import { L1TxUtilsWithBlobs } from './l1_tx_utils_with_blobs.js';
13
- import { createViemSigner } from './signer.js';
14
+ import { L1TxUtils } from './l1_tx_utils.js';
15
+ import { Delayer } from './tx_delayer.js';
14
16
  import type { L1BlobInputs, L1TxConfig, L1TxRequest, SigningCallback } from './types.js';
15
17
 
16
18
  /**
17
- * Extends L1TxUtilsWithBlobs to wrap all transactions through a forwarder contract.
19
+ * Extends L1TxUtils to wrap all transactions through a forwarder contract.
18
20
  * This is mainly used for testing the archiver's ability to decode transactions that go through proxies.
19
21
  */
20
- export class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
22
+ export class ForwarderL1TxUtils extends L1TxUtils {
21
23
  constructor(
22
- client: ViemClient | ExtendedViemWalletClient,
24
+ client: ViemClient,
23
25
  senderAddress: EthAddress,
24
26
  signingCallback: SigningCallback,
25
27
  logger: Logger | undefined,
@@ -28,9 +30,23 @@ export class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
28
30
  debugMaxGasLimit: boolean,
29
31
  store: IL1TxStore | undefined,
30
32
  metrics: IL1TxMetrics | undefined,
33
+ kzg: BlobKzgInstance | undefined,
34
+ delayer: Delayer | undefined,
31
35
  private readonly forwarderAddress: EthAddress,
32
36
  ) {
33
- super(client, senderAddress, signingCallback, logger, dateProvider, config, debugMaxGasLimit, store, metrics);
37
+ super(
38
+ client,
39
+ senderAddress,
40
+ signingCallback,
41
+ logger,
42
+ dateProvider,
43
+ config,
44
+ debugMaxGasLimit,
45
+ store,
46
+ metrics,
47
+ kzg,
48
+ delayer,
49
+ );
34
50
  }
35
51
 
36
52
  /**
@@ -61,59 +77,32 @@ export class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
61
77
  }
62
78
  }
63
79
 
64
- export function createForwarderL1TxUtilsFromViemWallet(
65
- client: ExtendedViemWalletClient,
80
+ export function createForwarderL1TxUtils(
81
+ source: L1SignerSource,
66
82
  forwarderAddress: EthAddress,
67
- deps: {
83
+ deps?: {
68
84
  logger?: Logger;
69
85
  dateProvider?: DateProvider;
70
86
  store?: IL1TxStore;
71
87
  metrics?: IL1TxMetrics;
72
- } = {},
73
- config: Partial<L1TxUtilsConfig> = {},
74
- debugMaxGasLimit: boolean = false,
75
- ) {
88
+ kzg?: BlobKzgInstance;
89
+ delayer?: Delayer;
90
+ },
91
+ config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
92
+ ): ForwarderL1TxUtils {
93
+ const { client, address, signingCallback } = resolveSignerSource(source);
76
94
  return new ForwarderL1TxUtils(
77
95
  client,
78
- EthAddress.fromString(client.account.address),
79
- createViemSigner(client),
80
- deps.logger,
81
- deps.dateProvider,
82
- config,
83
- debugMaxGasLimit,
84
- deps.store,
85
- deps.metrics,
86
- forwarderAddress,
87
- );
88
- }
89
-
90
- export function createForwarderL1TxUtilsFromEthSigner(
91
- client: ViemClient,
92
- signer: EthSigner,
93
- forwarderAddress: EthAddress,
94
- deps: {
95
- logger?: Logger;
96
- dateProvider?: DateProvider;
97
- store?: IL1TxStore;
98
- metrics?: IL1TxMetrics;
99
- } = {},
100
- config: Partial<L1TxUtilsConfig> = {},
101
- debugMaxGasLimit: boolean = false,
102
- ) {
103
- const callback: SigningCallback = async (transaction, _signingAddress) => {
104
- return (await signer.signTransaction(transaction)).toViemTransactionSignature();
105
- };
106
-
107
- return new ForwarderL1TxUtils(
108
- client,
109
- signer.address,
110
- callback,
111
- deps.logger,
112
- deps.dateProvider,
113
- config,
114
- debugMaxGasLimit,
115
- deps.store,
116
- deps.metrics,
96
+ address,
97
+ signingCallback,
98
+ deps?.logger,
99
+ deps?.dateProvider,
100
+ config ?? {},
101
+ config?.debugMaxGasLimit ?? false,
102
+ deps?.store,
103
+ deps?.metrics,
104
+ deps?.kzg,
105
+ deps?.delayer,
117
106
  forwarderAddress,
118
107
  );
119
108
  }
@@ -1,2 +1,2 @@
1
- export * from './forwarder_l1_tx_utils.js';
2
- export * from './l1_tx_utils_with_blobs.js';
1
+ export { createForwarderL1TxUtils, ForwarderL1TxUtils } from './forwarder_l1_tx_utils.js';
2
+ export { createL1TxUtils, type L1SignerSource, resolveSignerSource } from './factory.js';
@@ -8,6 +8,7 @@ export * from './l1_tx_utils.js';
8
8
  export * from './readonly_l1_tx_utils.js';
9
9
  export * from './signer.js';
10
10
  export * from './types.js';
11
+ export * from './tx_delayer.js';
11
12
  export * from './utils.js';
12
13
 
13
14
  // Note: We intentionally do not export l1_tx_utils_with_blobs.js
@@ -13,7 +13,6 @@ import {
13
13
  DEFAULT_PRIORITY_FEE_STRATEGIES,
14
14
  type PriorityFeeStrategy,
15
15
  type PriorityFeeStrategyContext,
16
- executeStrategy,
17
16
  } from './fee-strategies/index.js';
18
17
  import type { L1BlobInputs, L1TxRequest } from './types.js';
19
18
 
@@ -262,7 +261,7 @@ export class L1FeeAnalyzer {
262
261
 
263
262
  /**
264
263
  * Executes all configured strategies and returns their results.
265
- * Each strategy defines its own promises which are executed and passed to calculate.
264
+ * Each strategy handles its own RPC calls internally.
266
265
  * @param isBlobTx - Whether this is a blob transaction
267
266
  * @returns Array of strategy results
268
267
  */
@@ -276,7 +275,7 @@ export class L1FeeAnalyzer {
276
275
 
277
276
  for (const strategy of this.strategies) {
278
277
  try {
279
- const result = await executeStrategy(strategy, this.client, context);
278
+ const result = await strategy.execute(this.client, context);
280
279
 
281
280
  results.push({
282
281
  strategyId: strategy.id,