@aztec/ethereum 3.0.0-rc.5 → 4.0.0-nightly.20260107

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 (84) hide show
  1. package/dest/client.js +6 -2
  2. package/dest/config.d.ts +4 -1
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +6 -0
  5. package/dest/contracts/empire_base.d.ts +2 -1
  6. package/dest/contracts/empire_base.d.ts.map +1 -1
  7. package/dest/contracts/empire_slashing_proposer.d.ts +2 -1
  8. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
  9. package/dest/contracts/empire_slashing_proposer.js +9 -0
  10. package/dest/contracts/governance_proposer.d.ts +2 -1
  11. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  12. package/dest/contracts/governance_proposer.js +391 -8
  13. package/dest/contracts/inbox.d.ts +5 -1
  14. package/dest/contracts/inbox.d.ts.map +1 -1
  15. package/dest/contracts/inbox.js +4 -0
  16. package/dest/contracts/rollup.d.ts +125 -73
  17. package/dest/contracts/rollup.d.ts.map +1 -1
  18. package/dest/contracts/rollup.js +614 -125
  19. package/dest/deploy_aztec_l1_contracts.d.ts +3 -1
  20. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  21. package/dest/deploy_aztec_l1_contracts.js +7 -2
  22. package/dest/l1_artifacts.d.ts +3370 -104
  23. package/dest/l1_artifacts.d.ts.map +1 -1
  24. package/dest/l1_contract_addresses.d.ts +1 -1
  25. package/dest/l1_contract_addresses.d.ts.map +1 -1
  26. package/dest/l1_contract_addresses.js +3 -3
  27. package/dest/l1_tx_utils/constants.d.ts +7 -1
  28. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  29. package/dest/l1_tx_utils/constants.js +25 -0
  30. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  31. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  32. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  33. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  34. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  35. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  36. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  37. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  38. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  39. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  40. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  41. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  42. package/dest/l1_tx_utils/index.d.ts +3 -1
  43. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  44. package/dest/l1_tx_utils/index.js +2 -0
  45. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  46. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  47. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  48. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
  49. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  50. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +34 -142
  51. package/dest/queries.d.ts +1 -1
  52. package/dest/queries.d.ts.map +1 -1
  53. package/dest/queries.js +8 -3
  54. package/dest/test/chain_monitor.js +1 -2
  55. package/dest/test/eth_cheat_codes.js +3 -1
  56. package/dest/test/rollup_cheat_codes.js +3 -1
  57. package/dest/test/tx_delayer.js +1 -1
  58. package/dest/utils.d.ts +14 -2
  59. package/dest/utils.d.ts.map +1 -1
  60. package/dest/utils.js +18 -0
  61. package/package.json +6 -5
  62. package/src/client.ts +2 -2
  63. package/src/config.ts +8 -0
  64. package/src/contracts/empire_base.ts +1 -1
  65. package/src/contracts/empire_slashing_proposer.ts +6 -1
  66. package/src/contracts/governance_proposer.ts +6 -1
  67. package/src/contracts/inbox.ts +5 -0
  68. package/src/contracts/rollup.ts +252 -84
  69. package/src/deploy_aztec_l1_contracts.ts +12 -2
  70. package/src/l1_contract_addresses.ts +22 -20
  71. package/src/l1_tx_utils/constants.ts +11 -0
  72. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  73. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  74. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  75. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  76. package/src/l1_tx_utils/index.ts +2 -0
  77. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  78. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +46 -184
  79. package/src/queries.ts +8 -2
  80. package/src/test/chain_monitor.ts +1 -1
  81. package/src/test/eth_cheat_codes.ts +1 -1
  82. package/src/test/rollup_cheat_codes.ts +1 -1
  83. package/src/test/tx_delayer.ts +1 -1
  84. package/src/utils.ts +29 -0
@@ -1,4 +1,5 @@
1
- import { getKeys, median, merge, pick, times } from '@aztec/foundation/collection';
1
+ import { getKeys, merge, pick, times } from '@aztec/foundation/collection';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
4
  import { makeBackoff, retry } from '@aztec/foundation/retry';
4
5
  import { DateProvider } from '@aztec/foundation/timer';
@@ -11,6 +12,7 @@ import {
11
12
  type BaseError,
12
13
  type BlockOverrides,
13
14
  type ContractFunctionExecutionError,
15
+ type GetCodeReturnType,
14
16
  type Hex,
15
17
  MethodNotFoundRpcError,
16
18
  MethodNotSupportedRpcError,
@@ -30,10 +32,12 @@ import {
30
32
  MIN_REPLACEMENT_BUMP_PERCENTAGE,
31
33
  WEI_CONST,
32
34
  } from './constants.js';
35
+ import { P75AllTxsPriorityFeeStrategy, type PriorityFeeStrategy } from './fee-strategies/index.js';
33
36
  import type { GasPrice, L1BlobInputs, L1TxRequest, TransactionStats } from './types.js';
34
37
  import { getCalldataGasUsage, tryGetCustomErrorNameContractFunction } from './utils.js';
35
38
 
36
- const HISTORICAL_BLOCK_COUNT = 5;
39
+ // Change this to the current strategy we want to use
40
+ const CurrentStrategy: PriorityFeeStrategy = P75AllTxsPriorityFeeStrategy;
37
41
 
38
42
  export class ReadOnlyL1TxUtils {
39
43
  public config: Required<L1TxUtilsConfig>;
@@ -65,122 +69,8 @@ export class ReadOnlyL1TxUtils {
65
69
  return this.client.getBlockNumber();
66
70
  }
67
71
 
68
- /**
69
- * Analyzes pending transactions and recent fee history to determine a competitive priority fee.
70
- * Falls back to network estimate if data is unavailable or fails.
71
- * @param networkEstimateResult - Result from estimateMaxPriorityFeePerGas RPC call
72
- * @param pendingBlockResult - Result from getBlock with pending tag RPC call
73
- * @param feeHistoryResult - Result from getFeeHistory RPC call
74
- * @returns A competitive priority fee based on pending txs and recent block history
75
- */
76
- protected getCompetitivePriorityFee(
77
- networkEstimateResult: PromiseSettledResult<bigint | null>,
78
- pendingBlockResult: PromiseSettledResult<Awaited<ReturnType<ViemClient['getBlock']>> | null>,
79
- feeHistoryResult: PromiseSettledResult<Awaited<ReturnType<ViemClient['getFeeHistory']>> | null>,
80
- ): bigint {
81
- const networkEstimate =
82
- networkEstimateResult.status === 'fulfilled' && typeof networkEstimateResult.value === 'bigint'
83
- ? networkEstimateResult.value
84
- : 0n;
85
- let competitiveFee = networkEstimate;
86
-
87
- if (
88
- pendingBlockResult.status === 'fulfilled' &&
89
- pendingBlockResult.value !== null &&
90
- pendingBlockResult.value.transactions &&
91
- pendingBlockResult.value.transactions.length > 0
92
- ) {
93
- const pendingBlock = pendingBlockResult.value;
94
- // Extract priority fees from pending transactions
95
- const pendingFees = pendingBlock.transactions
96
- .map(tx => {
97
- // Transaction can be just a hash string, so we need to check if it's an object
98
- if (typeof tx === 'string') {
99
- return 0n;
100
- }
101
- const fee = tx.maxPriorityFeePerGas || 0n;
102
- // Debug: Log suspicious fees
103
- if (fee > 100n * WEI_CONST) {
104
- this.logger?.warn('Suspicious high priority fee in pending tx', {
105
- txHash: tx.hash,
106
- maxPriorityFeePerGas: formatGwei(fee),
107
- maxFeePerGas: formatGwei(tx.maxFeePerGas || 0n),
108
- maxFeePerBlobGas: tx.maxFeePerBlobGas ? formatGwei(tx.maxFeePerBlobGas) : 'N/A',
109
- });
110
- }
111
- return fee;
112
- })
113
- .filter((fee: bigint) => fee > 0n);
114
-
115
- if (pendingFees.length > 0) {
116
- // Use 75th percentile of pending fees to be competitive
117
- const sortedPendingFees = [...pendingFees].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
118
- const percentile75Index = Math.floor((sortedPendingFees.length - 1) * 0.75);
119
- const pendingCompetitiveFee = sortedPendingFees[percentile75Index];
120
-
121
- if (pendingCompetitiveFee > competitiveFee) {
122
- competitiveFee = pendingCompetitiveFee;
123
- }
124
-
125
- this.logger?.debug('Analyzed pending transactions for competitive pricing', {
126
- pendingTxCount: pendingFees.length,
127
- pendingP75: formatGwei(pendingCompetitiveFee),
128
- });
129
- }
130
- }
131
- if (
132
- feeHistoryResult.status === 'fulfilled' &&
133
- feeHistoryResult.value !== null &&
134
- feeHistoryResult.value.reward &&
135
- feeHistoryResult.value.reward.length > 0
136
- ) {
137
- const feeHistory = feeHistoryResult.value;
138
- // Extract 75th percentile fees from each block
139
- const percentile75Fees = feeHistory.reward!.map(rewards => rewards[0] || 0n).filter(fee => fee > 0n);
140
-
141
- if (percentile75Fees.length > 0) {
142
- // Calculate median of the 75th percentile fees across blocks
143
- const medianHistoricalFee = median(percentile75Fees) ?? 0n;
144
-
145
- // Debug: Log suspicious fees from history
146
- if (medianHistoricalFee > 100n * WEI_CONST) {
147
- this.logger?.warn('Suspicious high fee in history', {
148
- historicalMedian: formatGwei(medianHistoricalFee),
149
- allP75Fees: percentile75Fees.map(f => formatGwei(f)),
150
- });
151
- }
152
-
153
- if (medianHistoricalFee > competitiveFee) {
154
- competitiveFee = medianHistoricalFee;
155
- }
156
-
157
- this.logger?.debug('Analyzed fee history for competitive pricing', {
158
- historicalMedian: formatGwei(medianHistoricalFee),
159
- });
160
- }
161
- }
162
-
163
- // Sanity check: cap competitive fee at 100x network estimate to avoid using unrealistic fees
164
- // (e.g., Anvil returns inflated historical fees that don't reflect actual network conditions)
165
- const maxReasonableFee = networkEstimate * 100n;
166
- if (competitiveFee > maxReasonableFee) {
167
- this.logger?.warn('Competitive fee exceeds sanity cap, using capped value', {
168
- competitiveFee: formatGwei(competitiveFee),
169
- networkEstimate: formatGwei(networkEstimate),
170
- cappedTo: formatGwei(maxReasonableFee),
171
- });
172
- competitiveFee = maxReasonableFee;
173
- }
174
-
175
- // Log final decision
176
- if (competitiveFee > networkEstimate) {
177
- this.logger?.debug('Using competitive fee from market analysis', {
178
- networkEstimate: formatGwei(networkEstimate),
179
- competitive: formatGwei(competitiveFee),
180
- });
181
- }
182
-
183
- return competitiveFee;
72
+ public getCode(address: EthAddress): Promise<GetCodeReturnType> {
73
+ return this.client.getCode({ address: address.toString() });
184
74
  }
185
75
 
186
76
  /**
@@ -194,74 +84,47 @@ export class ReadOnlyL1TxUtils {
194
84
  ): Promise<GasPrice> {
195
85
  const gasConfig = merge(this.config, gasConfigOverrides);
196
86
 
197
- // Make all RPC calls in parallel upfront with retry logic
198
- const latestBlockPromise = this.tryTwice(
199
- () => this.client.getBlock({ blockTag: 'latest' }),
200
- 'Getting latest block',
201
- );
202
- const networkEstimatePromise = this.tryTwice(
203
- () => this.client.estimateMaxPriorityFeePerGas(),
204
- 'Estimating max priority fee per gas',
87
+ // Execute strategy - it handles all RPC calls internally and returns everything we need
88
+ const strategyResult = await retry(
89
+ () =>
90
+ CurrentStrategy.execute(this.client, {
91
+ gasConfig,
92
+ isBlobTx,
93
+ logger: this.logger,
94
+ }),
95
+ 'Executing priority fee strategy',
96
+ makeBackoff(times(2, () => 0)),
97
+ this.logger,
98
+ true,
205
99
  );
206
- const pendingBlockPromise = this.tryTwice(
207
- () => this.client.getBlock({ blockTag: 'pending', includeTransactions: true }),
208
- 'Getting pending block',
209
- );
210
- const feeHistoryPromise = this.tryTwice(
211
- () => this.client.getFeeHistory({ blockCount: HISTORICAL_BLOCK_COUNT, rewardPercentiles: [75] }),
212
- 'Getting fee history',
213
- );
214
- const blobBaseFeePromise = isBlobTx
215
- ? this.tryTwice(() => this.client.getBlobBaseFee(), 'Getting blob base fee')
216
- : null;
217
-
218
- const [latestBlockResult, networkEstimateResult, pendingBlockResult, feeHistoryResult, blobBaseFeeResult] =
219
- await Promise.allSettled([
220
- latestBlockPromise,
221
- networkEstimatePromise,
222
- pendingBlockPromise,
223
- feeHistoryPromise,
224
- blobBaseFeePromise ?? Promise.resolve(0n),
225
- ]);
226
-
227
- // Extract results
228
- const baseFee =
229
- latestBlockResult.status === 'fulfilled' &&
230
- typeof latestBlockResult.value === 'object' &&
231
- latestBlockResult.value.baseFeePerGas
232
- ? latestBlockResult.value.baseFeePerGas
233
- : 0n;
234
-
235
- // Get blob base fee if available
236
- let blobBaseFee = 0n;
237
- if (isBlobTx && blobBaseFeeResult.status === 'fulfilled' && typeof blobBaseFeeResult.value === 'bigint') {
238
- blobBaseFee = blobBaseFeeResult.value;
239
- } else if (isBlobTx) {
100
+
101
+ const { latestBlock, blobBaseFee, priorityFee: strategyPriorityFee } = strategyResult;
102
+
103
+ // Extract base fee from latest block
104
+ const baseFee = latestBlock.baseFeePerGas ?? 0n;
105
+
106
+ // Handle blob base fee
107
+ if (isBlobTx && blobBaseFee === undefined) {
240
108
  this.logger?.warn('Failed to get L1 blob base fee', attempt);
241
109
  }
242
110
 
243
- // Get competitive priority fee
244
- let priorityFee = this.getCompetitivePriorityFee(networkEstimateResult, pendingBlockResult, feeHistoryResult);
111
+ let priorityFee = strategyPriorityFee;
245
112
 
246
- // Apply minimum priority fee as a floor if configured
113
+ // Apply minimum priority fee floor if configured
247
114
  if (gasConfig.minimumPriorityFeePerGas) {
248
- const minimumFee = BigInt(Math.trunc(gasConfig.minimumPriorityFeePerGas * Number(WEI_CONST)));
249
- if (minimumFee > priorityFee) {
250
- this.logger?.debug('Using minimum priority fee as floor', {
251
- minimumPriorityFeePerGas: formatGwei(minimumFee),
252
- competitiveFee: formatGwei(priorityFee),
253
- });
254
- priorityFee = minimumFee;
255
- } else {
256
- this.logger?.debug('Competitive fee exceeds minimum, using competitive fee', {
257
- minimumPriorityFeePerGas: formatGwei(minimumFee),
258
- competitiveFee: formatGwei(priorityFee),
115
+ const minimumPriorityFee = BigInt(Math.trunc(gasConfig.minimumPriorityFeePerGas * Number(WEI_CONST)));
116
+ if (priorityFee < minimumPriorityFee) {
117
+ this.logger?.debug('Applying minimum priority fee floor', {
118
+ calculatedPriorityFee: formatGwei(priorityFee),
119
+ minimumPriorityFeePerGas: gasConfig.minimumPriorityFeePerGas,
120
+ appliedFee: formatGwei(minimumPriorityFee),
259
121
  });
122
+ priorityFee = minimumPriorityFee;
260
123
  }
261
124
  }
262
125
  let maxFeePerGas = baseFee;
263
126
 
264
- let maxFeePerBlobGas = blobBaseFee;
127
+ let maxFeePerBlobGas = blobBaseFee ?? 0n;
265
128
 
266
129
  // Bump base fee so it's valid for next blocks if it stalls
267
130
  const numBlocks = Math.ceil(gasConfig.stallTimeMs! / BLOCK_TIME_MS);
@@ -355,7 +218,7 @@ export class ReadOnlyL1TxUtils {
355
218
  baseFee: formatGwei(baseFee),
356
219
  maxFeePerGas: formatGwei(maxFeePerGas),
357
220
  maxPriorityFeePerGas: formatGwei(maxPriorityFeePerGas),
358
- blobBaseFee: formatGwei(blobBaseFee),
221
+ blobBaseFee: formatGwei(blobBaseFee ?? 0n),
359
222
  maxFeePerBlobGas: formatGwei(maxFeePerBlobGas),
360
223
  },
361
224
  );
@@ -387,11 +250,17 @@ export class ReadOnlyL1TxUtils {
387
250
  ..._blobInputs,
388
251
  maxFeePerBlobGas: gasPrice.maxFeePerBlobGas!,
389
252
  gas: LARGE_GAS_LIMIT,
253
+ blockTag: 'latest',
390
254
  });
391
255
 
392
256
  this.logger?.trace(`Estimated gas for blob tx: ${initialEstimate}`);
393
257
  } else {
394
- initialEstimate = await this.client.estimateGas({ account, ...request, gas: LARGE_GAS_LIMIT });
258
+ initialEstimate = await this.client.estimateGas({
259
+ account,
260
+ ...request,
261
+ gas: LARGE_GAS_LIMIT,
262
+ blockTag: 'latest',
263
+ });
395
264
  this.logger?.trace(`Estimated gas for non-blob tx: ${initialEstimate}`);
396
265
  }
397
266
 
@@ -547,11 +416,4 @@ export class ReadOnlyL1TxUtils {
547
416
  });
548
417
  return bumpedGasLimit;
549
418
  }
550
-
551
- /**
552
- * Helper function to retry RPC calls twice
553
- */
554
- private tryTwice<T>(fn: () => Promise<T>, description: string): Promise<T> {
555
- return retry<T>(fn, description, makeBackoff(times(2, () => 0)), this.logger, true);
556
- }
557
419
  }
package/src/queries.ts CHANGED
@@ -3,6 +3,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import type { L1ContractsConfig } from './config.js';
4
4
  import { ReadOnlyGovernanceContract } from './contracts/governance.js';
5
5
  import { GovernanceProposerContract } from './contracts/governance_proposer.js';
6
+ import { InboxContract } from './contracts/inbox.js';
6
7
  import { RollupContract } from './contracts/rollup.js';
7
8
  import type { ViemPublicClient } from './types.js';
8
9
 
@@ -25,6 +26,8 @@ export async function getL1ContractsConfig(
25
26
  const rollup = new RollupContract(publicClient, rollupAddress.toString());
26
27
  const slasherProposer = await rollup.getSlashingProposer();
27
28
  const slasher = await rollup.getSlasherContract();
29
+ const rollupAddresses = await rollup.getRollupAddresses();
30
+ const inboxContract = new InboxContract(publicClient, rollupAddresses.inboxAddress.toString());
28
31
 
29
32
  const [
30
33
  l1StartBlock,
@@ -35,6 +38,7 @@ export async function getL1ContractsConfig(
35
38
  aztecTargetCommitteeSize,
36
39
  lagInEpochsForValidatorSet,
37
40
  lagInEpochsForRandao,
41
+ inboxLag,
38
42
  activationThreshold,
39
43
  ejectionThreshold,
40
44
  localEjectionThreshold,
@@ -62,6 +66,7 @@ export async function getL1ContractsConfig(
62
66
  rollup.getTargetCommitteeSize(),
63
67
  rollup.getLagInEpochsForValidatorSet(),
64
68
  rollup.getLagInEpochsForRandao(),
69
+ inboxContract.getLag(),
65
70
  rollup.getActivationThreshold(),
66
71
  rollup.getEjectionThreshold(),
67
72
  rollup.getLocalEjectionThreshold(),
@@ -91,13 +96,14 @@ export async function getL1ContractsConfig(
91
96
  aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
92
97
  lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
93
98
  lagInEpochsForRandao: Number(lagInEpochsForRandao),
99
+ inboxLag: Number(inboxLag),
94
100
  governanceProposerQuorum: Number(governanceProposerQuorum),
95
101
  governanceProposerRoundSize: Number(governanceProposerRoundSize),
96
102
  activationThreshold,
97
103
  ejectionThreshold,
98
104
  localEjectionThreshold,
99
105
  slashingQuorum: Number(slashingQuorum),
100
- slashingRoundSizeInEpochs: Number(slashingRoundSize / aztecEpochDuration),
106
+ slashingRoundSizeInEpochs: Number(Number(slashingRoundSize) / aztecEpochDuration),
101
107
  slashingLifetimeInRounds: Number(slashingLifetimeInRounds),
102
108
  slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
103
109
  slashingVetoer,
@@ -105,7 +111,7 @@ export async function getL1ContractsConfig(
105
111
  manaTarget,
106
112
  provingCostPerMana: provingCostPerMana,
107
113
  rollupVersion: Number(rollupVersion),
108
- genesisArchiveTreeRoot,
114
+ genesisArchiveTreeRoot: genesisArchiveTreeRoot.toString(),
109
115
  exitDelaySeconds: Number(exitDelay),
110
116
  slasherFlavor: slasherProposer?.type ?? 'tally',
111
117
  slashingOffsetInRounds: Number(slashingOffsetInRounds),
@@ -156,7 +156,7 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
156
156
  let committee: EthAddress[] | undefined;
157
157
  if (l2Epoch !== this.l2EpochNumber) {
158
158
  this.l2EpochNumber = l2Epoch;
159
- committee = (await this.rollup.getCurrentEpochCommittee())?.map(addr => EthAddress.fromString(addr));
159
+ committee = await this.rollup.getCurrentEpochCommittee();
160
160
  this.emit('l2-epoch', { l2EpochNumber: l2Epoch, timestamp, committee });
161
161
  msg += ` starting new epoch ${this.l2EpochNumber} `;
162
162
  }
@@ -35,7 +35,7 @@ export class EthCheatCodes {
35
35
  public chain: Chain = foundry,
36
36
  ) {
37
37
  this.publicClient = createPublicClient({
38
- transport: fallback(this.rpcUrls.map(url => http(url))),
38
+ transport: fallback(this.rpcUrls.map(url => http(url, { batch: false }))),
39
39
  chain: chain,
40
40
  });
41
41
  }
@@ -32,7 +32,7 @@ export class RollupCheatCodes {
32
32
  ) {
33
33
  this.client = createPublicClient({
34
34
  chain: ethCheatCodes.chain,
35
- transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url))),
35
+ transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url, { batch: false }))),
36
36
  });
37
37
  this.rollup = getContract({
38
38
  abi: RollupAbi,
@@ -232,7 +232,7 @@ export function withDelayer<T extends ViemClient>(
232
232
  return Promise.resolve(txHash!);
233
233
  } else {
234
234
  const txHash = await client.sendRawTransaction(...args);
235
- logger.verbose(`Sent tx immediately ${txHash}`);
235
+ logger.debug(`Sent tx immediately ${txHash}`);
236
236
  delayer.sentTxHashes.push(txHash);
237
237
  return txHash;
238
238
  }
package/src/utils.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  type ContractEventName,
9
9
  ContractFunctionRevertedError,
10
10
  type DecodeEventLogReturnType,
11
+ type FormattedTransaction,
11
12
  type Hex,
12
13
  type Log,
13
14
  decodeErrorResult,
@@ -233,3 +234,31 @@ export function tryGetCustomErrorName(err: any) {
233
234
  return undefined;
234
235
  }
235
236
  }
237
+
238
+ /**
239
+ * Type guard to check if a transaction is a blob transaction (EIP-4844).
240
+ * Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
241
+ */
242
+ export function isBlobTransaction(tx: FormattedTransaction): tx is FormattedTransaction & {
243
+ maxFeePerBlobGas: bigint;
244
+ blobVersionedHashes: readonly Hex[];
245
+ } {
246
+ return (
247
+ 'maxFeePerBlobGas' in tx &&
248
+ tx.maxFeePerBlobGas !== undefined &&
249
+ 'blobVersionedHashes' in tx &&
250
+ tx.blobVersionedHashes !== undefined
251
+ );
252
+ }
253
+
254
+ /**
255
+ * Calculates a percentile from an array of bigints
256
+ */
257
+ export function calculatePercentile(values: bigint[], percentile: number): bigint {
258
+ if (values.length === 0) {
259
+ return 0n;
260
+ }
261
+ const sorted = [...values].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
262
+ const index = Math.ceil((sorted.length - 1) * (percentile / 100));
263
+ return sorted[index];
264
+ }