@aztec/ethereum 2.1.9-rc.2 → 2.1.9-rc.4
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.
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +9 -8
- package/dest/l1_tx_utils/constants.d.ts +6 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +25 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/index.d.ts +2 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +2 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +235 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +0 -13
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +30 -143
- package/dest/utils.d.ts +13 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +18 -0
- package/package.json +6 -5
- package/src/deploy_l1_contracts.ts +7 -6
- package/src/l1_tx_utils/constants.ts +11 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/index.ts +2 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +802 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +42 -186
- package/src/utils.ts +29 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_l1_contracts.d.ts","sourceRoot":"","sources":["../src/deploy_l1_contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,EACL,KAAK,KAAK,EACV,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,iBAAiB,EAUvB,MAAM,MAAM,CAAC;AAKd,OAAO,EACL,KAAK,iBAAiB,EAMvB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAmB7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,SA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CAAC;IAoBzC,eAAe,CACb,EAAE,EAAE,WAAW,EACf,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC;QAAE,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;CAOlE;AAGD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,wBAAwB,EACxC,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,SAAS,OAAO,EAAE,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,IAAI,GAAE,SAAS,OAAO,EAAO,EAC7B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CACnB,GACL,OAAO,CAAC;IACT,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC;IACxB,iBAAiB,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAwJD;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,SAAS,OAAO,EAAE,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,IAAI,EAAE,GAAG;;;;EAeV"}
|
|
@@ -123,7 +123,16 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
|
|
|
123
123
|
]);
|
|
124
124
|
feeAssetAddress = deployedFee.address;
|
|
125
125
|
logger.verbose(`Deployed Fee Asset at ${feeAssetAddress}`);
|
|
126
|
+
const deployedStaking = await deployer.deploy(StakingAssetArtifact, [
|
|
127
|
+
'Staking',
|
|
128
|
+
'STK',
|
|
129
|
+
l1Client.account.address
|
|
130
|
+
]);
|
|
131
|
+
stakingAssetAddress = deployedStaking.address;
|
|
132
|
+
logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
|
|
133
|
+
await deployer.waitForDeployments();
|
|
126
134
|
// Mint a tiny bit of tokens to satisfy coin-issuer constraints
|
|
135
|
+
// This must happen AFTER the FeeAsset deployment is mined
|
|
127
136
|
const { txHash } = await deployer.sendTransaction({
|
|
128
137
|
to: feeAssetAddress.toString(),
|
|
129
138
|
data: encodeFunctionData({
|
|
@@ -139,14 +148,6 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
|
|
|
139
148
|
hash: txHash
|
|
140
149
|
});
|
|
141
150
|
logger.verbose(`Minted tiny bit of tokens to satisfy coin-issuer constraints in ${txHash}`);
|
|
142
|
-
const deployedStaking = await deployer.deploy(StakingAssetArtifact, [
|
|
143
|
-
'Staking',
|
|
144
|
-
'STK',
|
|
145
|
-
l1Client.account.address
|
|
146
|
-
]);
|
|
147
|
-
stakingAssetAddress = deployedStaking.address;
|
|
148
|
-
logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
|
|
149
|
-
await deployer.waitForDeployments();
|
|
150
151
|
}
|
|
151
152
|
const gseAddress = (await deployer.deploy(GSEArtifact, [
|
|
152
153
|
l1Client.account.address,
|
|
@@ -3,4 +3,10 @@ export declare const LARGE_GAS_LIMIT = 12000000n;
|
|
|
3
3
|
export declare const MIN_REPLACEMENT_BUMP_PERCENTAGE = 10;
|
|
4
4
|
export declare const MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE = 100;
|
|
5
5
|
export declare const BLOCK_TIME_MS = 12000;
|
|
6
|
+
export declare const GAS_PER_BLOB = 131072n;
|
|
7
|
+
export declare const BLOB_CAPACITY_SCHEDULE: {
|
|
8
|
+
timestamp: number;
|
|
9
|
+
target: number;
|
|
10
|
+
max: number;
|
|
11
|
+
}[];
|
|
6
12
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,cAAiB,CAAC;AAGxC,eAAO,MAAM,eAAe,YAAc,CAAC;AAI3C,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAIlD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAGxD,eAAO,MAAM,aAAa,QAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,cAAiB,CAAC;AAGxC,eAAO,MAAM,eAAe,YAAc,CAAC;AAI3C,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAIlD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAGxD,eAAO,MAAM,aAAa,QAAS,CAAC;AAGpC,eAAO,MAAM,YAAY,UAAU,CAAC;AAGpC,eAAO,MAAM,sBAAsB;;;;GAKlC,CAAC"}
|
|
@@ -12,3 +12,28 @@ export const MIN_REPLACEMENT_BUMP_PERCENTAGE = 10;
|
|
|
12
12
|
export const MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE = 100;
|
|
13
13
|
// Avg ethereum block time is ~12s
|
|
14
14
|
export const BLOCK_TIME_MS = 12_000;
|
|
15
|
+
// Gas per blob (EIP-4844)
|
|
16
|
+
export const GAS_PER_BLOB = 131072n;
|
|
17
|
+
// Blob capacity schedule based on Ethereum upgrades
|
|
18
|
+
export const BLOB_CAPACITY_SCHEDULE = [
|
|
19
|
+
{
|
|
20
|
+
timestamp: 1734357600,
|
|
21
|
+
target: 14,
|
|
22
|
+
max: 21
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
timestamp: 1733752800,
|
|
26
|
+
target: 10,
|
|
27
|
+
max: 15
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
timestamp: 1733234400,
|
|
31
|
+
target: 6,
|
|
32
|
+
max: 9
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
timestamp: 0,
|
|
36
|
+
target: 6,
|
|
37
|
+
max: 9
|
|
38
|
+
}
|
|
39
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PriorityFeeStrategy } from './types.js';
|
|
2
|
+
export { HISTORICAL_BLOCK_COUNT, type PriorityFeeStrategy, type PriorityFeeStrategyContext, type PriorityFeeStrategyResult, } from './types.js';
|
|
3
|
+
export { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
4
|
+
export { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default list of priority fee strategies to analyze.
|
|
7
|
+
* Add more strategies here for comparison.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_PRIORITY_FEE_STRATEGIES: PriorityFeeStrategy[];
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/l1_tx_utils/fee-strategies/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EACL,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,mBAAmB,EAGhE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
2
|
+
import { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
3
|
+
export { HISTORICAL_BLOCK_COUNT } from './types.js';
|
|
4
|
+
export { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
5
|
+
export { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
6
|
+
/**
|
|
7
|
+
* Default list of priority fee strategies to analyze.
|
|
8
|
+
* Add more strategies here for comparison.
|
|
9
|
+
*/ export const DEFAULT_PRIORITY_FEE_STRATEGIES = [
|
|
10
|
+
P75AllTxsPriorityFeeStrategy,
|
|
11
|
+
P75BlobTxsOnlyPriorityFeeStrategy
|
|
12
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PriorityFeeStrategy } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Our current competitive priority fee strategy.
|
|
4
|
+
* Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
|
|
5
|
+
* Falls back to network estimate if data is unavailable.
|
|
6
|
+
*/
|
|
7
|
+
export declare const P75AllTxsPriorityFeeStrategy: PriorityFeeStrategy;
|
|
8
|
+
//# sourceMappingURL=p75_competitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p75_competitive.d.ts","sourceRoot":"","sources":["../../../src/l1_tx_utils/fee-strategies/p75_competitive.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,mBA+I1C,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { median } from '@aztec/foundation/collection';
|
|
2
|
+
import { formatGwei } from 'viem';
|
|
3
|
+
import { calculatePercentile } from '../../utils.js';
|
|
4
|
+
import { WEI_CONST } from '../constants.js';
|
|
5
|
+
import { HISTORICAL_BLOCK_COUNT } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Our current competitive priority fee strategy.
|
|
8
|
+
* Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
|
|
9
|
+
* Falls back to network estimate if data is unavailable.
|
|
10
|
+
*/ export const P75AllTxsPriorityFeeStrategy = {
|
|
11
|
+
name: 'Competitive (P75 + History) - CURRENT',
|
|
12
|
+
id: 'p75_pending_txs_and_history_all_txs',
|
|
13
|
+
async execute (client, context) {
|
|
14
|
+
const { isBlobTx, logger } = context;
|
|
15
|
+
// Fire all RPC calls in parallel
|
|
16
|
+
const [latestBlockResult, blobBaseFeeResult, networkEstimateResult, pendingBlockResult, feeHistoryResult] = await Promise.allSettled([
|
|
17
|
+
client.getBlock({
|
|
18
|
+
blockTag: 'latest'
|
|
19
|
+
}),
|
|
20
|
+
isBlobTx ? client.getBlobBaseFee() : Promise.resolve(undefined),
|
|
21
|
+
client.estimateMaxPriorityFeePerGas().catch(()=>0n),
|
|
22
|
+
client.getBlock({
|
|
23
|
+
blockTag: 'pending',
|
|
24
|
+
includeTransactions: true
|
|
25
|
+
}).catch(()=>null),
|
|
26
|
+
client.getFeeHistory({
|
|
27
|
+
blockCount: HISTORICAL_BLOCK_COUNT,
|
|
28
|
+
rewardPercentiles: [
|
|
29
|
+
75
|
|
30
|
+
],
|
|
31
|
+
blockTag: 'latest'
|
|
32
|
+
}).catch(()=>null)
|
|
33
|
+
]);
|
|
34
|
+
// Extract latest block
|
|
35
|
+
if (latestBlockResult.status === 'rejected') {
|
|
36
|
+
throw new Error(`Failed to get latest block: ${latestBlockResult.reason}`);
|
|
37
|
+
}
|
|
38
|
+
const latestBlock = latestBlockResult.value;
|
|
39
|
+
// Extract blob base fee (only for blob txs)
|
|
40
|
+
let blobBaseFee;
|
|
41
|
+
if (isBlobTx) {
|
|
42
|
+
if (blobBaseFeeResult.status === 'fulfilled' && typeof blobBaseFeeResult.value === 'bigint') {
|
|
43
|
+
blobBaseFee = blobBaseFeeResult.value;
|
|
44
|
+
} else {
|
|
45
|
+
logger?.warn('Failed to get L1 blob base fee');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Extract network estimate
|
|
49
|
+
const networkEstimate = networkEstimateResult.status === 'fulfilled' && typeof networkEstimateResult.value === 'bigint' ? networkEstimateResult.value : 0n;
|
|
50
|
+
let competitiveFee = networkEstimate;
|
|
51
|
+
const debugInfo = {
|
|
52
|
+
networkEstimateGwei: formatGwei(networkEstimate)
|
|
53
|
+
};
|
|
54
|
+
// Extract pending block
|
|
55
|
+
const pendingBlock = pendingBlockResult.status === 'fulfilled' ? pendingBlockResult.value : null;
|
|
56
|
+
// Analyze pending block transactions
|
|
57
|
+
if (pendingBlock?.transactions && pendingBlock.transactions.length > 0) {
|
|
58
|
+
const pendingFees = pendingBlock.transactions.map((tx)=>{
|
|
59
|
+
if (typeof tx === 'string') {
|
|
60
|
+
return 0n;
|
|
61
|
+
}
|
|
62
|
+
return tx.maxPriorityFeePerGas || 0n;
|
|
63
|
+
}).filter((fee)=>fee > 0n);
|
|
64
|
+
if (pendingFees.length > 0) {
|
|
65
|
+
// Use 75th percentile of pending fees to be competitive
|
|
66
|
+
const pendingCompetitiveFee = calculatePercentile(pendingFees, 75);
|
|
67
|
+
if (pendingCompetitiveFee > competitiveFee) {
|
|
68
|
+
competitiveFee = pendingCompetitiveFee;
|
|
69
|
+
}
|
|
70
|
+
debugInfo.pendingTxCount = pendingFees.length;
|
|
71
|
+
debugInfo.pendingP75Gwei = formatGwei(pendingCompetitiveFee);
|
|
72
|
+
logger?.debug('Analyzed pending transactions for competitive pricing', {
|
|
73
|
+
pendingTxCount: pendingFees.length,
|
|
74
|
+
pendingP75: formatGwei(pendingCompetitiveFee)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Extract fee history
|
|
79
|
+
const feeHistory = feeHistoryResult.status === 'fulfilled' ? feeHistoryResult.value : null;
|
|
80
|
+
// Analyze fee history
|
|
81
|
+
if (feeHistory?.reward && feeHistory.reward.length > 0) {
|
|
82
|
+
// Extract 75th percentile fees from each block
|
|
83
|
+
const percentile75Fees = feeHistory.reward.map((rewards)=>rewards[0] || 0n).filter((fee)=>fee > 0n);
|
|
84
|
+
if (percentile75Fees.length > 0) {
|
|
85
|
+
// Calculate median of the 75th percentile fees across blocks
|
|
86
|
+
const medianHistoricalFee = median(percentile75Fees) ?? 0n;
|
|
87
|
+
// Debug: Log suspicious fees from history
|
|
88
|
+
if (medianHistoricalFee > 100n * WEI_CONST) {
|
|
89
|
+
logger?.warn('Suspicious high fee in history', {
|
|
90
|
+
historicalMedian: formatGwei(medianHistoricalFee),
|
|
91
|
+
allP75Fees: percentile75Fees.map((f)=>formatGwei(f))
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (medianHistoricalFee > competitiveFee) {
|
|
95
|
+
competitiveFee = medianHistoricalFee;
|
|
96
|
+
}
|
|
97
|
+
debugInfo.historicalMedianGwei = formatGwei(medianHistoricalFee);
|
|
98
|
+
logger?.debug('Analyzed fee history for competitive pricing', {
|
|
99
|
+
historicalMedian: formatGwei(medianHistoricalFee)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Sanity check: cap competitive fee at 100x network estimate to avoid using unrealistic fees
|
|
104
|
+
const maxReasonableFee = networkEstimate * 100n;
|
|
105
|
+
if (competitiveFee > maxReasonableFee && networkEstimate > 0n) {
|
|
106
|
+
logger?.warn('Competitive fee exceeds sanity cap, using capped value', {
|
|
107
|
+
competitiveFee: formatGwei(competitiveFee),
|
|
108
|
+
networkEstimate: formatGwei(networkEstimate),
|
|
109
|
+
cappedTo: formatGwei(maxReasonableFee)
|
|
110
|
+
});
|
|
111
|
+
competitiveFee = maxReasonableFee;
|
|
112
|
+
debugInfo.cappedToGwei = formatGwei(maxReasonableFee);
|
|
113
|
+
}
|
|
114
|
+
// Log final decision
|
|
115
|
+
if (competitiveFee > networkEstimate) {
|
|
116
|
+
logger?.debug('Using competitive fee from market analysis', {
|
|
117
|
+
networkEstimate: formatGwei(networkEstimate),
|
|
118
|
+
competitive: formatGwei(competitiveFee)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
debugInfo.finalFeeGwei = formatGwei(competitiveFee);
|
|
122
|
+
return {
|
|
123
|
+
priorityFee: competitiveFee,
|
|
124
|
+
latestBlock,
|
|
125
|
+
blobBaseFee,
|
|
126
|
+
debugInfo
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type GetFeeHistoryReturnType } from 'viem';
|
|
2
|
+
import type { ViemClient } from '../../types.js';
|
|
3
|
+
import { type PriorityFeeStrategy } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Fetches historical blocks and calculates reward percentiles for blob transactions only.
|
|
6
|
+
* Returns data in the same format as getFeeHistory for easy drop-in replacement.
|
|
7
|
+
*
|
|
8
|
+
* @param client - Viem client to use for RPC calls
|
|
9
|
+
* @param blockCount - Number of historical blocks to fetch
|
|
10
|
+
* @param rewardPercentiles - Array of percentiles to calculate (e.g., [75] for 75th percentile)
|
|
11
|
+
* @returns Object with reward field containing percentile fees for each block, similar to getFeeHistory
|
|
12
|
+
* @throws Error if fetching blocks fails
|
|
13
|
+
*/
|
|
14
|
+
export declare function getBlobPriorityFeeHistory(client: ViemClient, blockCount: number, rewardPercentiles: number[]): Promise<GetFeeHistoryReturnType>;
|
|
15
|
+
/**
|
|
16
|
+
* Similar to our current competitive priority fee strategy, but only considers blob transactions
|
|
17
|
+
* when calculating competitive priority fee for blob transactions.
|
|
18
|
+
* This strategy also has NO cap on the competitive fee if it's much higher than the network estimate.
|
|
19
|
+
* Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
|
|
20
|
+
* Falls back to network estimate if data is unavailable.
|
|
21
|
+
*/
|
|
22
|
+
export declare const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy;
|
|
23
|
+
//# sourceMappingURL=p75_competitive_blob_txs_only.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p75_competitive_blob_txs_only.d.ts","sourceRoot":"","sources":["../../../src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAc,MAAM,MAAM,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CAsElC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,mBAyI/C,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { median } from '@aztec/foundation/collection';
|
|
2
|
+
import { formatGwei } from 'viem';
|
|
3
|
+
import { calculatePercentile, isBlobTransaction } from '../../utils.js';
|
|
4
|
+
import { WEI_CONST } from '../constants.js';
|
|
5
|
+
import { HISTORICAL_BLOCK_COUNT } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Fetches historical blocks and calculates reward percentiles for blob transactions only.
|
|
8
|
+
* Returns data in the same format as getFeeHistory for easy drop-in replacement.
|
|
9
|
+
*
|
|
10
|
+
* @param client - Viem client to use for RPC calls
|
|
11
|
+
* @param blockCount - Number of historical blocks to fetch
|
|
12
|
+
* @param rewardPercentiles - Array of percentiles to calculate (e.g., [75] for 75th percentile)
|
|
13
|
+
* @returns Object with reward field containing percentile fees for each block, similar to getFeeHistory
|
|
14
|
+
* @throws Error if fetching blocks fails
|
|
15
|
+
*/ export async function getBlobPriorityFeeHistory(client, blockCount, rewardPercentiles) {
|
|
16
|
+
const latestBlockNumber = await client.getBlockNumber();
|
|
17
|
+
// Fetch multiple blocks in parallel
|
|
18
|
+
const blockPromises = Array.from({
|
|
19
|
+
length: blockCount
|
|
20
|
+
}, (_, i)=>client.getBlock({
|
|
21
|
+
blockNumber: latestBlockNumber - BigInt(i),
|
|
22
|
+
includeTransactions: true
|
|
23
|
+
}));
|
|
24
|
+
const blocks = await Promise.all(blockPromises);
|
|
25
|
+
// Process each block to extract blob transaction fees and other data
|
|
26
|
+
const baseFeePerGas = [];
|
|
27
|
+
const gasUsedRatio = [];
|
|
28
|
+
const reward = [];
|
|
29
|
+
for (const block of blocks){
|
|
30
|
+
// Collect base fee per gas
|
|
31
|
+
baseFeePerGas.push(block.baseFeePerGas || 0n);
|
|
32
|
+
// Calculate gas used ratio
|
|
33
|
+
const gasUsed = block.gasUsed || 0n;
|
|
34
|
+
const gasLimit = block.gasLimit || 1n; // Avoid division by zero
|
|
35
|
+
gasUsedRatio.push(Number(gasUsed) / Number(gasLimit));
|
|
36
|
+
if (!block.transactions || block.transactions.length === 0) {
|
|
37
|
+
// No transactions in this block - return zeros for each percentile
|
|
38
|
+
reward.push(rewardPercentiles.map(()=>0n));
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
// Extract priority fees from blob transactions only
|
|
42
|
+
const blobFees = block.transactions.map((tx)=>{
|
|
43
|
+
// Transaction can be just a hash string
|
|
44
|
+
if (typeof tx === 'string') {
|
|
45
|
+
return 0n;
|
|
46
|
+
}
|
|
47
|
+
if (!isBlobTransaction(tx)) {
|
|
48
|
+
return 0n;
|
|
49
|
+
}
|
|
50
|
+
return tx.maxPriorityFeePerGas || 0n;
|
|
51
|
+
}).filter((fee)=>fee > 0n);
|
|
52
|
+
if (blobFees.length === 0) {
|
|
53
|
+
// No blob transactions in this block - return zeros for each percentile
|
|
54
|
+
reward.push(rewardPercentiles.map(()=>0n));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// Calculate requested percentiles
|
|
58
|
+
const percentiles = rewardPercentiles.map((percentile)=>calculatePercentile(blobFees, percentile));
|
|
59
|
+
reward.push(percentiles);
|
|
60
|
+
}
|
|
61
|
+
// Calculate oldest block number (the last block in our array)
|
|
62
|
+
const oldestBlock = latestBlockNumber - BigInt(blockCount - 1);
|
|
63
|
+
// Reverse arrays to match getFeeHistory behavior (oldest first)
|
|
64
|
+
return {
|
|
65
|
+
baseFeePerGas: baseFeePerGas.reverse(),
|
|
66
|
+
gasUsedRatio: gasUsedRatio.reverse(),
|
|
67
|
+
oldestBlock,
|
|
68
|
+
reward: reward.reverse()
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Similar to our current competitive priority fee strategy, but only considers blob transactions
|
|
73
|
+
* when calculating competitive priority fee for blob transactions.
|
|
74
|
+
* This strategy also has NO cap on the competitive fee if it's much higher than the network estimate.
|
|
75
|
+
* Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
|
|
76
|
+
* Falls back to network estimate if data is unavailable.
|
|
77
|
+
*/ export const P75BlobTxsOnlyPriorityFeeStrategy = {
|
|
78
|
+
name: 'Competitive (P75 + History) - Blob Txs Only',
|
|
79
|
+
id: 'p75_pending_txs_and_history_blob_txs_only',
|
|
80
|
+
async execute (client, context) {
|
|
81
|
+
const { isBlobTx, logger } = context;
|
|
82
|
+
// Fire all RPC calls in parallel
|
|
83
|
+
const [latestBlockResult, blobBaseFeeResult, networkEstimateResult, pendingBlockResult, feeHistoryResult] = await Promise.allSettled([
|
|
84
|
+
client.getBlock({
|
|
85
|
+
blockTag: 'latest'
|
|
86
|
+
}),
|
|
87
|
+
isBlobTx ? client.getBlobBaseFee() : Promise.resolve(undefined),
|
|
88
|
+
client.estimateMaxPriorityFeePerGas().catch(()=>0n),
|
|
89
|
+
client.getBlock({
|
|
90
|
+
blockTag: 'pending',
|
|
91
|
+
includeTransactions: true
|
|
92
|
+
}).catch(()=>null),
|
|
93
|
+
isBlobTx ? getBlobPriorityFeeHistory(client, HISTORICAL_BLOCK_COUNT, [
|
|
94
|
+
75
|
|
95
|
+
]) : client.getFeeHistory({
|
|
96
|
+
blockCount: HISTORICAL_BLOCK_COUNT,
|
|
97
|
+
rewardPercentiles: [
|
|
98
|
+
75
|
|
99
|
+
],
|
|
100
|
+
blockTag: 'latest'
|
|
101
|
+
}).catch(()=>null)
|
|
102
|
+
]);
|
|
103
|
+
// Extract latest block (required)
|
|
104
|
+
if (latestBlockResult.status === 'rejected') {
|
|
105
|
+
throw new Error(`Failed to get latest block: ${latestBlockResult.reason}`);
|
|
106
|
+
}
|
|
107
|
+
const latestBlock = latestBlockResult.value;
|
|
108
|
+
// Extract blob base fee (only for blob txs)
|
|
109
|
+
let blobBaseFee;
|
|
110
|
+
if (isBlobTx) {
|
|
111
|
+
if (blobBaseFeeResult.status === 'fulfilled' && typeof blobBaseFeeResult.value === 'bigint') {
|
|
112
|
+
blobBaseFee = blobBaseFeeResult.value;
|
|
113
|
+
} else {
|
|
114
|
+
logger?.warn('Failed to get L1 blob base fee');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Extract network estimate
|
|
118
|
+
const networkEstimate = networkEstimateResult.status === 'fulfilled' && typeof networkEstimateResult.value === 'bigint' ? networkEstimateResult.value : 0n;
|
|
119
|
+
let competitiveFee = networkEstimate;
|
|
120
|
+
const debugInfo = {
|
|
121
|
+
networkEstimateGwei: formatGwei(networkEstimate)
|
|
122
|
+
};
|
|
123
|
+
// Extract pending block
|
|
124
|
+
const pendingBlock = pendingBlockResult.status === 'fulfilled' ? pendingBlockResult.value : null;
|
|
125
|
+
// Analyze pending block transactions
|
|
126
|
+
if (pendingBlock?.transactions && pendingBlock.transactions.length > 0) {
|
|
127
|
+
const pendingFees = pendingBlock.transactions.map((tx)=>{
|
|
128
|
+
if (typeof tx === 'string') {
|
|
129
|
+
return 0n;
|
|
130
|
+
}
|
|
131
|
+
if (isBlobTx) {
|
|
132
|
+
if (!isBlobTransaction(tx)) {
|
|
133
|
+
return 0n;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return tx.maxPriorityFeePerGas || 0n;
|
|
137
|
+
}).filter((fee)=>fee > 0n);
|
|
138
|
+
if (pendingFees.length > 0) {
|
|
139
|
+
const pendingCompetitiveFee = calculatePercentile(pendingFees, 75);
|
|
140
|
+
if (pendingCompetitiveFee > competitiveFee) {
|
|
141
|
+
competitiveFee = pendingCompetitiveFee;
|
|
142
|
+
}
|
|
143
|
+
debugInfo.pendingTxCount = pendingFees.length;
|
|
144
|
+
debugInfo.pendingP75Gwei = formatGwei(pendingCompetitiveFee);
|
|
145
|
+
logger?.debug('Analyzed pending transactions for competitive pricing', {
|
|
146
|
+
pendingTxCount: pendingFees.length,
|
|
147
|
+
pendingP75: formatGwei(pendingCompetitiveFee)
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Extract fee history
|
|
152
|
+
const feeHistory = feeHistoryResult.status === 'fulfilled' ? feeHistoryResult.value : null;
|
|
153
|
+
// Analyze fee history
|
|
154
|
+
if (feeHistory?.reward && feeHistory.reward.length > 0) {
|
|
155
|
+
// Extract 75th percentile fees from each block
|
|
156
|
+
const percentile75Fees = feeHistory.reward.map((rewards)=>rewards[0] || 0n).filter((fee)=>fee > 0n);
|
|
157
|
+
if (percentile75Fees.length > 0) {
|
|
158
|
+
// Calculate median of the 75th percentile fees across blocks
|
|
159
|
+
const medianHistoricalFee = median(percentile75Fees) ?? 0n;
|
|
160
|
+
// Debug: Log suspicious fees from history
|
|
161
|
+
if (medianHistoricalFee > 100n * WEI_CONST) {
|
|
162
|
+
logger?.warn('Suspicious high fee in history', {
|
|
163
|
+
historicalMedian: formatGwei(medianHistoricalFee),
|
|
164
|
+
allP75Fees: percentile75Fees.map((f)=>formatGwei(f))
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (medianHistoricalFee > competitiveFee) {
|
|
168
|
+
competitiveFee = medianHistoricalFee;
|
|
169
|
+
}
|
|
170
|
+
debugInfo.historicalMedianGwei = formatGwei(medianHistoricalFee);
|
|
171
|
+
logger?.debug('Analyzed fee history for competitive pricing', {
|
|
172
|
+
historicalMedian: formatGwei(medianHistoricalFee)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Log final decision
|
|
177
|
+
if (competitiveFee > networkEstimate) {
|
|
178
|
+
logger?.debug('Using competitive fee from market analysis', {
|
|
179
|
+
networkEstimate: formatGwei(networkEstimate),
|
|
180
|
+
competitive: formatGwei(competitiveFee)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
debugInfo.finalFeeGwei = formatGwei(competitiveFee);
|
|
184
|
+
return {
|
|
185
|
+
priorityFee: competitiveFee,
|
|
186
|
+
latestBlock,
|
|
187
|
+
blobBaseFee,
|
|
188
|
+
debugInfo
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { Block } from 'viem';
|
|
3
|
+
import type { ViemClient } from '../../types.js';
|
|
4
|
+
import type { L1TxUtilsConfig } from '../config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Historical block count for fee history queries
|
|
7
|
+
*/
|
|
8
|
+
export declare const HISTORICAL_BLOCK_COUNT = 5;
|
|
9
|
+
/**
|
|
10
|
+
* Result from a priority fee strategy calculation
|
|
11
|
+
*/
|
|
12
|
+
export interface PriorityFeeStrategyResult {
|
|
13
|
+
/** The calculated priority fee in wei */
|
|
14
|
+
priorityFee: bigint;
|
|
15
|
+
/** The latest block (fetched as part of the strategy) */
|
|
16
|
+
latestBlock: Block;
|
|
17
|
+
/** The blob base fee (only present for blob transactions) */
|
|
18
|
+
blobBaseFee?: bigint;
|
|
19
|
+
/** Optional debug info about how the fee was calculated */
|
|
20
|
+
debugInfo?: Record<string, string | number>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Context passed to the strategy function
|
|
24
|
+
*/
|
|
25
|
+
export interface PriorityFeeStrategyContext {
|
|
26
|
+
/** Gas configuration */
|
|
27
|
+
gasConfig: L1TxUtilsConfig;
|
|
28
|
+
/** Whether this is for a blob transaction */
|
|
29
|
+
isBlobTx: boolean;
|
|
30
|
+
/** Logger for debugging */
|
|
31
|
+
logger?: Logger;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A strategy for calculating the priority fee for L1 transactions.
|
|
35
|
+
* The function handles all RPC calls and returns
|
|
36
|
+
* the priority fee, along with any block data needed by the caller.
|
|
37
|
+
*/
|
|
38
|
+
export type PriorityFeeStrategy = {
|
|
39
|
+
/** Human-readable name for logging */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Unique identifier for metrics */
|
|
42
|
+
id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Calculate the priority fee.
|
|
45
|
+
* @param client - The viem client to use for RPC calls
|
|
46
|
+
* @param context - Contains gas config, whether it's a blob tx, and logger
|
|
47
|
+
* @returns The calculated priority fee result including block data
|
|
48
|
+
*/
|
|
49
|
+
execute: (client: ViemClient, context: PriorityFeeStrategyContext) => Promise<PriorityFeeStrategyResult>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/l1_tx_utils/fee-strategies/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,WAAW,EAAE,KAAK,CAAC;IACnB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,wBAAwB;IACxB,SAAS,EAAE,eAAe,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,CAAC;IAClB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC1G,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './config.js';
|
|
2
2
|
export * from './constants.js';
|
|
3
3
|
export * from './factory.js';
|
|
4
|
+
export * from './fee-strategies/index.js';
|
|
4
5
|
export * from './interfaces.js';
|
|
6
|
+
export * from './l1_fee_analyzer.js';
|
|
5
7
|
export * from './l1_tx_utils.js';
|
|
6
8
|
export * from './readonly_l1_tx_utils.js';
|
|
7
9
|
export * from './signer.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './config.js';
|
|
2
2
|
export * from './constants.js';
|
|
3
3
|
export * from './factory.js';
|
|
4
|
+
export * from './fee-strategies/index.js';
|
|
4
5
|
export * from './interfaces.js';
|
|
6
|
+
export * from './l1_fee_analyzer.js';
|
|
5
7
|
export * from './l1_tx_utils.js';
|
|
6
8
|
export * from './readonly_l1_tx_utils.js';
|
|
7
9
|
export * from './signer.js';
|