@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.03f7ef2

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 (272) hide show
  1. package/dest/account.d.ts +2 -0
  2. package/dest/account.d.ts.map +1 -0
  3. package/dest/account.js +4 -0
  4. package/dest/chain.d.ts +1 -1
  5. package/dest/client.d.ts +6 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +21 -3
  8. package/dest/config.d.ts +71 -16
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +138 -22
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +25 -8
  13. package/dest/contracts/empire_base.d.ts.map +1 -1
  14. package/dest/contracts/empire_base.js +75 -2
  15. package/dest/contracts/empire_slashing_proposer.d.ts +67 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +209 -0
  18. package/dest/contracts/errors.d.ts +7 -0
  19. package/dest/contracts/errors.d.ts.map +1 -0
  20. package/dest/contracts/errors.js +12 -0
  21. package/dest/contracts/fee_asset_handler.d.ts +19 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +57 -0
  24. package/dest/contracts/fee_juice.d.ts +6 -7
  25. package/dest/contracts/fee_juice.d.ts.map +1 -1
  26. package/dest/contracts/fee_juice.js +27 -20
  27. package/dest/contracts/governance.d.ts +43 -32
  28. package/dest/contracts/governance.d.ts.map +1 -1
  29. package/dest/contracts/governance.js +87 -84
  30. package/dest/contracts/governance_proposer.d.ts +17 -13
  31. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  32. package/dest/contracts/governance_proposer.js +46 -17
  33. package/dest/contracts/gse.d.ts +32 -0
  34. package/dest/contracts/gse.d.ts.map +1 -0
  35. package/dest/contracts/gse.js +72 -0
  36. package/dest/contracts/inbox.d.ts +26 -0
  37. package/dest/contracts/inbox.d.ts.map +1 -0
  38. package/dest/contracts/inbox.js +45 -0
  39. package/dest/contracts/index.d.ts +9 -3
  40. package/dest/contracts/index.d.ts.map +1 -1
  41. package/dest/contracts/index.js +8 -2
  42. package/dest/contracts/multicall.d.ts +21 -0
  43. package/dest/contracts/multicall.d.ts.map +1 -0
  44. package/dest/contracts/multicall.js +156 -0
  45. package/dest/contracts/registry.d.ts +10 -5
  46. package/dest/contracts/registry.d.ts.map +1 -1
  47. package/dest/contracts/registry.js +44 -16
  48. package/dest/contracts/rollup.d.ts +221 -41
  49. package/dest/contracts/rollup.d.ts.map +1 -1
  50. package/dest/contracts/rollup.js +549 -81
  51. package/dest/contracts/slasher_contract.d.ts +44 -0
  52. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  53. package/dest/contracts/slasher_contract.js +75 -0
  54. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  55. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  56. package/dest/contracts/tally_slashing_proposer.js +313 -0
  57. package/dest/contracts/utils.d.ts +3 -0
  58. package/dest/contracts/utils.d.ts.map +1 -0
  59. package/dest/contracts/utils.js +11 -0
  60. package/dest/deploy_aztec_l1_contracts.d.ts +245 -0
  61. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  62. package/dest/deploy_aztec_l1_contracts.js +335 -0
  63. package/dest/deploy_l1_contract.d.ts +68 -0
  64. package/dest/deploy_l1_contract.d.ts.map +1 -0
  65. package/dest/deploy_l1_contract.js +312 -0
  66. package/dest/eth-signer/eth-signer.d.ts +21 -0
  67. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  68. package/dest/eth-signer/eth-signer.js +5 -0
  69. package/dest/eth-signer/index.d.ts +2 -0
  70. package/dest/eth-signer/index.d.ts.map +1 -0
  71. package/dest/eth-signer/index.js +1 -0
  72. package/dest/forwarder_proxy.d.ts +32 -0
  73. package/dest/forwarder_proxy.d.ts.map +1 -0
  74. package/dest/forwarder_proxy.js +93 -0
  75. package/dest/l1_artifacts.d.ts +77364 -0
  76. package/dest/l1_artifacts.d.ts.map +1 -0
  77. package/dest/l1_artifacts.js +166 -0
  78. package/dest/l1_contract_addresses.d.ts +24 -4
  79. package/dest/l1_contract_addresses.d.ts.map +1 -1
  80. package/dest/l1_contract_addresses.js +25 -21
  81. package/dest/l1_reader.d.ts +4 -2
  82. package/dest/l1_reader.d.ts.map +1 -1
  83. package/dest/l1_reader.js +14 -8
  84. package/dest/l1_tx_utils/config.d.ts +59 -0
  85. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  86. package/dest/l1_tx_utils/config.js +96 -0
  87. package/dest/l1_tx_utils/constants.d.ts +12 -0
  88. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  89. package/dest/l1_tx_utils/constants.js +39 -0
  90. package/dest/l1_tx_utils/factory.d.ts +24 -0
  91. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  92. package/dest/l1_tx_utils/factory.js +12 -0
  93. package/dest/l1_tx_utils/fee-strategies/index.d.ts +9 -0
  94. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/fee-strategies/index.js +11 -0
  96. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +18 -0
  97. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +111 -0
  99. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +32 -0
  100. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +173 -0
  102. package/dest/l1_tx_utils/fee-strategies/types.d.ts +64 -0
  103. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/fee-strategies/types.js +24 -0
  105. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  106. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  108. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  109. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/index-blobs.js +2 -0
  111. package/dest/l1_tx_utils/index.d.ts +12 -0
  112. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/index.js +12 -0
  114. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  115. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/interfaces.js +4 -0
  117. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  118. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  120. package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
  121. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
  123. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  124. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  126. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +87 -0
  127. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +360 -0
  129. package/dest/l1_tx_utils/signer.d.ts +4 -0
  130. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/signer.js +16 -0
  132. package/dest/l1_tx_utils/types.d.ts +67 -0
  133. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/types.js +26 -0
  135. package/dest/l1_tx_utils/utils.d.ts +4 -0
  136. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  137. package/dest/l1_tx_utils/utils.js +14 -0
  138. package/dest/l1_types.d.ts +6 -0
  139. package/dest/l1_types.d.ts.map +1 -0
  140. package/dest/l1_types.js +1 -0
  141. package/dest/publisher_manager.d.ts +15 -0
  142. package/dest/publisher_manager.d.ts.map +1 -0
  143. package/dest/publisher_manager.js +88 -0
  144. package/dest/queries.d.ts +4 -2
  145. package/dest/queries.d.ts.map +1 -1
  146. package/dest/queries.js +53 -12
  147. package/dest/test/chain_monitor.d.ts +75 -0
  148. package/dest/test/chain_monitor.d.ts.map +1 -0
  149. package/dest/test/chain_monitor.js +214 -0
  150. package/dest/test/delayed_tx_utils.d.ts +8 -3
  151. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  152. package/dest/test/delayed_tx_utils.js +13 -6
  153. package/dest/test/eth_cheat_codes.d.ts +217 -0
  154. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  155. package/dest/test/eth_cheat_codes.js +560 -0
  156. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  157. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  158. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  159. package/dest/test/index.d.ts +4 -1
  160. package/dest/test/index.d.ts.map +1 -1
  161. package/dest/test/index.js +3 -0
  162. package/dest/test/rollup_cheat_codes.d.ts +87 -0
  163. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  164. package/dest/test/rollup_cheat_codes.js +275 -0
  165. package/dest/test/start_anvil.d.ts +9 -1
  166. package/dest/test/start_anvil.d.ts.map +1 -1
  167. package/dest/test/start_anvil.js +16 -7
  168. package/dest/test/tx_delayer.d.ts +18 -7
  169. package/dest/test/tx_delayer.d.ts.map +1 -1
  170. package/dest/test/tx_delayer.js +97 -20
  171. package/dest/test/upgrade_utils.d.ts +6 -5
  172. package/dest/test/upgrade_utils.d.ts.map +1 -1
  173. package/dest/test/upgrade_utils.js +23 -16
  174. package/dest/types.d.ts +62 -8
  175. package/dest/types.d.ts.map +1 -1
  176. package/dest/types.js +3 -1
  177. package/dest/utils.d.ts +16 -3
  178. package/dest/utils.d.ts.map +1 -1
  179. package/dest/utils.js +61 -88
  180. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  181. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  182. package/dest/zkPassportVerifierAddress.js +11 -0
  183. package/package.json +50 -23
  184. package/src/account.ts +5 -0
  185. package/src/client.ts +43 -5
  186. package/src/config.ts +188 -31
  187. package/src/contracts/empire_base.ts +77 -7
  188. package/src/contracts/empire_slashing_proposer.ts +270 -0
  189. package/src/contracts/errors.ts +13 -0
  190. package/src/contracts/fee_asset_handler.ts +63 -0
  191. package/src/contracts/fee_juice.ts +29 -15
  192. package/src/contracts/governance.ts +80 -77
  193. package/src/contracts/governance_proposer.ts +71 -24
  194. package/src/contracts/gse.ts +88 -0
  195. package/src/contracts/inbox.ts +63 -0
  196. package/src/contracts/index.ts +8 -2
  197. package/src/contracts/multicall.ts +155 -0
  198. package/src/contracts/registry.ts +51 -26
  199. package/src/contracts/rollup.ts +624 -78
  200. package/src/contracts/slasher_contract.ts +89 -0
  201. package/src/contracts/tally_slashing_proposer.ts +318 -0
  202. package/src/contracts/utils.ts +14 -0
  203. package/src/deploy_aztec_l1_contracts.ts +556 -0
  204. package/src/deploy_l1_contract.ts +362 -0
  205. package/src/eth-signer/eth-signer.ts +25 -0
  206. package/src/eth-signer/index.ts +1 -0
  207. package/src/forwarder_proxy.ts +108 -0
  208. package/src/l1_artifacts.ts +254 -0
  209. package/src/l1_contract_addresses.ts +49 -34
  210. package/src/l1_reader.ts +17 -9
  211. package/src/l1_tx_utils/README.md +177 -0
  212. package/src/l1_tx_utils/config.ts +161 -0
  213. package/src/l1_tx_utils/constants.ts +29 -0
  214. package/src/l1_tx_utils/factory.ts +64 -0
  215. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  216. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +159 -0
  217. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +241 -0
  218. package/src/l1_tx_utils/fee-strategies/types.ts +88 -0
  219. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  220. package/src/l1_tx_utils/index-blobs.ts +2 -0
  221. package/src/l1_tx_utils/index.ts +14 -0
  222. package/src/l1_tx_utils/interfaces.ts +86 -0
  223. package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
  224. package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
  225. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  226. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +458 -0
  227. package/src/l1_tx_utils/signer.ts +28 -0
  228. package/src/l1_tx_utils/types.ts +85 -0
  229. package/src/l1_tx_utils/utils.ts +16 -0
  230. package/src/l1_types.ts +6 -0
  231. package/src/publisher_manager.ts +106 -0
  232. package/src/queries.ts +73 -15
  233. package/src/test/chain_monitor.ts +245 -0
  234. package/src/test/delayed_tx_utils.ts +34 -6
  235. package/src/test/eth_cheat_codes.ts +588 -0
  236. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  237. package/src/test/index.ts +3 -0
  238. package/src/test/rollup_cheat_codes.ts +312 -0
  239. package/src/test/start_anvil.ts +24 -5
  240. package/src/test/tx_delayer.ts +130 -27
  241. package/src/test/upgrade_utils.ts +30 -21
  242. package/src/types.ts +71 -7
  243. package/src/utils.ts +79 -91
  244. package/src/zkPassportVerifierAddress.ts +15 -0
  245. package/dest/contracts/forwarder.d.ts +0 -24
  246. package/dest/contracts/forwarder.d.ts.map +0 -1
  247. package/dest/contracts/forwarder.js +0 -101
  248. package/dest/contracts/slashing_proposer.d.ts +0 -21
  249. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  250. package/dest/contracts/slashing_proposer.js +0 -47
  251. package/dest/deploy_l1_contracts.d.ts +0 -21210
  252. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  253. package/dest/deploy_l1_contracts.js +0 -687
  254. package/dest/eth_cheat_codes.d.ts +0 -147
  255. package/dest/eth_cheat_codes.d.ts.map +0 -1
  256. package/dest/eth_cheat_codes.js +0 -303
  257. package/dest/index.d.ts +0 -14
  258. package/dest/index.d.ts.map +0 -1
  259. package/dest/index.js +0 -13
  260. package/dest/l1_tx_utils.d.ts +0 -192
  261. package/dest/l1_tx_utils.d.ts.map +0 -1
  262. package/dest/l1_tx_utils.js +0 -641
  263. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  264. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  265. package/dest/l1_tx_utils_with_blobs.js +0 -64
  266. package/src/contracts/forwarder.ts +0 -132
  267. package/src/contracts/slashing_proposer.ts +0 -51
  268. package/src/deploy_l1_contracts.ts +0 -948
  269. package/src/eth_cheat_codes.ts +0 -314
  270. package/src/index.ts +0 -13
  271. package/src/l1_tx_utils.ts +0 -847
  272. package/src/l1_tx_utils_with_blobs.ts +0 -86
@@ -0,0 +1,161 @@
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ floatConfigHelper,
5
+ getConfigFromMappings,
6
+ getDefaultConfig,
7
+ numberConfigHelper,
8
+ } from '@aztec/foundation/config';
9
+
10
+ export interface L1TxUtilsConfig {
11
+ /**
12
+ * How much to increase calculated gas limit.
13
+ */
14
+ gasLimitBufferPercentage?: number;
15
+ /**
16
+ * Maximum gas price in gwei
17
+ */
18
+ maxGwei?: number;
19
+ /**
20
+ * Maximum blob fee per gas in gwei
21
+ */
22
+ maxBlobGwei?: number;
23
+ /**
24
+ * Priority fee bump percentage
25
+ */
26
+ priorityFeeBumpPercentage?: number;
27
+ /**
28
+ * How much to increase priority fee by each attempt (percentage)
29
+ */
30
+ priorityFeeRetryBumpPercentage?: number;
31
+ /**
32
+ * Minimum priority fee per gas in Gwei. Acts as a floor for the computed priority fee.
33
+ */
34
+ minimumPriorityFeePerGas?: number;
35
+ /**
36
+ * Maximum number of speed-up attempts
37
+ */
38
+ maxSpeedUpAttempts?: number;
39
+ /**
40
+ * How often to check tx status
41
+ */
42
+ checkIntervalMs?: number;
43
+ /**
44
+ * How long before considering tx stalled
45
+ */
46
+ stallTimeMs?: number;
47
+ /**
48
+ * How long to wait for a tx to be mined before giving up
49
+ */
50
+ txTimeoutMs?: number;
51
+ /**
52
+ * Whether to attempt to cancel a tx if it's not mined after txTimeoutMs
53
+ */
54
+ cancelTxOnTimeout?: boolean;
55
+ /**
56
+ * How long to wait for a cancellation tx to be mined after its last attempt before giving up
57
+ */
58
+ txCancellationFinalTimeoutMs?: number;
59
+ /**
60
+ * How long a tx nonce can be unseen in the mempool before considering it dropped
61
+ */
62
+ txUnseenConsideredDroppedMs?: number;
63
+ }
64
+
65
+ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
66
+ gasLimitBufferPercentage: {
67
+ description: 'How much to increase calculated gas limit by (percentage)',
68
+ env: 'L1_GAS_LIMIT_BUFFER_PERCENTAGE',
69
+ ...numberConfigHelper(20),
70
+ },
71
+ maxGwei: {
72
+ description: 'Maximum gas price in gwei to be used for transactions.',
73
+ env: 'L1_GAS_PRICE_MAX',
74
+ fallback: ['L1_FEE_PER_GAS_GWEI_MAX'],
75
+ ...floatConfigHelper(2000),
76
+ },
77
+ maxBlobGwei: {
78
+ description: 'Maximum blob fee per gas in gwei',
79
+ env: 'L1_BLOB_FEE_PER_GAS_MAX',
80
+ fallback: ['L1_BLOB_FEE_PER_GAS_GWEI_MAX'],
81
+ ...floatConfigHelper(3000),
82
+ },
83
+ priorityFeeBumpPercentage: {
84
+ description: 'How much to increase priority fee by each attempt (percentage)',
85
+ env: 'L1_PRIORITY_FEE_BUMP_PERCENTAGE',
86
+ ...numberConfigHelper(20),
87
+ },
88
+ priorityFeeRetryBumpPercentage: {
89
+ description: 'How much to increase priority fee by each retry attempt (percentage)',
90
+ env: 'L1_PRIORITY_FEE_RETRY_BUMP_PERCENTAGE',
91
+ ...numberConfigHelper(50),
92
+ },
93
+ minimumPriorityFeePerGas: {
94
+ description:
95
+ 'Minimum priority fee per gas in Gwei. Acts as a floor for the computed priority fee. If network conditions require a higher fee, the higher fee will be used.',
96
+ env: 'L1_MINIMUM_PRIORITY_FEE_PER_GAS_GWEI',
97
+ fallback: ['L1_FIXED_PRIORITY_FEE_PER_GAS', 'L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI'],
98
+ deprecatedFallback: [
99
+ {
100
+ env: 'L1_FIXED_PRIORITY_FEE_PER_GAS',
101
+ message: deprecatedFixedFeeMessage('L1_FIXED_PRIORITY_FEE_PER_GAS'),
102
+ },
103
+ {
104
+ env: 'L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI',
105
+ message: deprecatedFixedFeeMessage('L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI'),
106
+ },
107
+ ],
108
+ ...floatConfigHelper(0),
109
+ },
110
+ maxSpeedUpAttempts: {
111
+ description: 'Maximum number of speed-up attempts',
112
+ env: 'L1_TX_MONITOR_MAX_ATTEMPTS',
113
+ ...numberConfigHelper(3),
114
+ },
115
+ checkIntervalMs: {
116
+ description: 'How often to check tx status',
117
+ env: 'L1_TX_MONITOR_CHECK_INTERVAL_MS',
118
+ ...numberConfigHelper(1_000),
119
+ },
120
+ stallTimeMs: {
121
+ description: 'How long before considering tx stalled',
122
+ env: 'L1_TX_MONITOR_STALL_TIME_MS',
123
+ ...numberConfigHelper(12_000), // 12s, 1 ethereum slot
124
+ },
125
+ txTimeoutMs: {
126
+ description: 'How long to wait for a tx to be mined before giving up. Set to 0 to disable.',
127
+ env: 'L1_TX_MONITOR_TX_TIMEOUT_MS',
128
+ ...numberConfigHelper(120_000), // 2 mins
129
+ },
130
+ cancelTxOnTimeout: {
131
+ description: "Whether to attempt to cancel a tx if it's not mined after txTimeoutMs",
132
+ env: 'L1_TX_MONITOR_CANCEL_TX_ON_TIMEOUT',
133
+ ...booleanConfigHelper(true),
134
+ },
135
+ txCancellationFinalTimeoutMs: {
136
+ description: 'How long to wait for a cancellation tx after its last attempt before giving up',
137
+ env: 'L1_TX_MONITOR_TX_CANCELLATION_TIMEOUT_MS',
138
+ ...numberConfigHelper(24 * 12 * 1000), // 24 L1 blocks
139
+ },
140
+ txUnseenConsideredDroppedMs: {
141
+ description: 'How long a tx nonce can be unseen in the mempool before considering it dropped',
142
+ env: 'L1_TX_MONITOR_TX_UNSEEN_CONSIDERED_DROPPED_MS',
143
+ ...numberConfigHelper(6 * 12 * 1000), // 6 L1 blocks
144
+ },
145
+ };
146
+
147
+ // We abuse the fact that all mappings above have a non null default value and force-type this to Required
148
+ export const defaultL1TxUtilsConfig = getDefaultConfig<L1TxUtilsConfig>(
149
+ l1TxUtilsConfigMappings,
150
+ ) as Required<L1TxUtilsConfig>;
151
+
152
+ export function getL1TxUtilsConfigEnvVars(): L1TxUtilsConfig {
153
+ return getConfigFromMappings(l1TxUtilsConfigMappings);
154
+ }
155
+
156
+ function deprecatedFixedFeeMessage(envVar: string): string {
157
+ return (
158
+ `Environment variable ${envVar} is deprecated. It is now used as a MINIMUM priority fee rather than a fixed value. ` +
159
+ 'Please use L1_MINIMUM_PRIORITY_FEE_PER_GAS_GWEI instead. If network conditions require a higher fee, the higher fee will be used.'
160
+ );
161
+ }
@@ -0,0 +1,29 @@
1
+ // 1_000_000_000 Gwei = 1 ETH
2
+ // 1_000_000_000 Wei = 1 Gwei
3
+ // 1_000_000_000_000_000_000 Wei = 1 ETH
4
+ export const WEI_CONST = 1_000_000_000n;
5
+
6
+ // @note using this large gas limit to avoid the issue of `gas limit too low` when estimating gas in reth
7
+ export const LARGE_GAS_LIMIT = 12_000_000n;
8
+
9
+ // setting a minimum bump percentage to 10% due to geth's implementation
10
+ // https://github.com/ethereum/go-ethereum/blob/e3d61e6db028c412f74bc4d4c7e117a9e29d0de0/core/txpool/legacypool/list.go#L298
11
+ export const MIN_REPLACEMENT_BUMP_PERCENTAGE = 10;
12
+
13
+ // setting a minimum bump percentage to 100% due to geth's implementation
14
+ // https://github.com/ethereum/go-ethereum/blob/e3d61e6db028c412f74bc4d4c7e117a9e29d0de0/core/txpool/blobpool/config.go#L34
15
+ export const MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE = 100;
16
+
17
+ // Avg ethereum block time is ~12s
18
+ export const BLOCK_TIME_MS = 12_000;
19
+
20
+ // Gas per blob (EIP-4844)
21
+ export const GAS_PER_BLOB = 131072n;
22
+
23
+ // Blob capacity schedule based on Ethereum upgrades
24
+ export const BLOB_CAPACITY_SCHEDULE = [
25
+ { timestamp: 1734357600, target: 14, max: 21 }, // BPO2: Dec 17, 2025
26
+ { timestamp: 1733752800, target: 10, max: 15 }, // BPO1: Dec 9, 2025
27
+ { timestamp: 1733234400, target: 6, max: 9 }, // Fusaka: Dec 3, 2025
28
+ { timestamp: 0, target: 6, max: 9 }, // Pectra/earlier
29
+ ];
@@ -0,0 +1,64 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+ import { DateProvider } from '@aztec/foundation/timer';
4
+
5
+ import type { TransactionSerializable } from 'viem';
6
+
7
+ import type { EthSigner } from '../eth-signer/eth-signer.js';
8
+ import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
9
+ import type { L1TxUtilsConfig } from './config.js';
10
+ import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
11
+ import { L1TxUtils } from './l1_tx_utils.js';
12
+ import { createViemSigner } from './signer.js';
13
+ import type { SigningCallback } from './types.js';
14
+
15
+ export function createL1TxUtilsFromViemWallet(
16
+ client: ExtendedViemWalletClient,
17
+ deps?: {
18
+ logger?: Logger;
19
+ dateProvider?: DateProvider;
20
+ store?: IL1TxStore;
21
+ metrics?: IL1TxMetrics;
22
+ },
23
+ config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
24
+ ): L1TxUtils {
25
+ return new L1TxUtils(
26
+ client,
27
+ EthAddress.fromString(client.account.address),
28
+ createViemSigner(client),
29
+ deps?.logger,
30
+ deps?.dateProvider,
31
+ config,
32
+ config?.debugMaxGasLimit ?? false,
33
+ deps?.store,
34
+ deps?.metrics,
35
+ );
36
+ }
37
+
38
+ export function createL1TxUtilsFromEthSigner(
39
+ client: ViemClient,
40
+ signer: EthSigner,
41
+ deps?: {
42
+ logger?: Logger;
43
+ dateProvider?: DateProvider;
44
+ store?: IL1TxStore;
45
+ metrics?: IL1TxMetrics;
46
+ },
47
+ config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
48
+ ): L1TxUtils {
49
+ const callback: SigningCallback = async (transaction: TransactionSerializable, _signingAddress) => {
50
+ return (await signer.signTransaction(transaction)).toViemTransactionSignature();
51
+ };
52
+
53
+ return new L1TxUtils(
54
+ client,
55
+ signer.address,
56
+ callback,
57
+ deps?.logger,
58
+ deps?.dateProvider,
59
+ config,
60
+ config?.debugMaxGasLimit ?? false,
61
+ deps?.store,
62
+ deps?.metrics,
63
+ );
64
+ }
@@ -0,0 +1,22 @@
1
+ import { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
2
+ import { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
3
+ import type { PriorityFeeStrategy } from './types.js';
4
+
5
+ export {
6
+ HISTORICAL_BLOCK_COUNT,
7
+ executeStrategy,
8
+ type PriorityFeeStrategy,
9
+ type PriorityFeeStrategyContext,
10
+ type PriorityFeeStrategyResult,
11
+ } from './types.js';
12
+
13
+ export { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
14
+
15
+ /**
16
+ * Default list of priority fee strategies to analyze.
17
+ * Add more strategies here for comparison.
18
+ */
19
+ export const DEFAULT_PRIORITY_FEE_STRATEGIES: PriorityFeeStrategy[] = [
20
+ P75AllTxsPriorityFeeStrategy,
21
+ P75BlobTxsOnlyPriorityFeeStrategy,
22
+ ];
@@ -0,0 +1,159 @@
1
+ import { median } from '@aztec/foundation/collection';
2
+
3
+ import { formatGwei } from 'viem';
4
+
5
+ import type { ViemClient } from '../../types.js';
6
+ import { calculatePercentile } from '../../utils.js';
7
+ import { WEI_CONST } from '../constants.js';
8
+ import {
9
+ HISTORICAL_BLOCK_COUNT,
10
+ type PriorityFeeStrategy,
11
+ type PriorityFeeStrategyContext,
12
+ type PriorityFeeStrategyResult,
13
+ } from './types.js';
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
+ /**
25
+ * Our current competitive priority fee strategy.
26
+ * Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
27
+ * Falls back to network estimate if data is unavailable.
28
+ */
29
+ export const P75AllTxsPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStrategyPromises> = {
30
+ name: 'Competitive (P75 + History) - CURRENT',
31
+ id: 'p75_pending_txs_and_history_all_txs',
32
+
33
+ getRequiredPromises(client: ViemClient): P75AllTxsStrategyPromises {
34
+ return {
35
+ networkEstimate: client.estimateMaxPriorityFeePerGas().catch(() => 0n),
36
+ pendingBlock: client.getBlock({ blockTag: 'pending', includeTransactions: true }).catch(() => null),
37
+ feeHistory: client
38
+ .getFeeHistory({
39
+ blockCount: HISTORICAL_BLOCK_COUNT,
40
+ rewardPercentiles: [75],
41
+ blockTag: 'latest',
42
+ })
43
+ .catch(() => null),
44
+ };
45
+ },
46
+
47
+ calculate(
48
+ results: {
49
+ [K in keyof P75AllTxsStrategyPromises]: PromiseSettledResult<Awaited<P75AllTxsStrategyPromises[K]>>;
50
+ },
51
+ context: PriorityFeeStrategyContext,
52
+ ): PriorityFeeStrategyResult {
53
+ const { logger } = context;
54
+
55
+ // Extract network estimate from settled result
56
+ const networkEstimate =
57
+ results.networkEstimate.status === 'fulfilled' && typeof results.networkEstimate.value === 'bigint'
58
+ ? results.networkEstimate.value
59
+ : 0n;
60
+
61
+ let competitiveFee = networkEstimate;
62
+ const debugInfo: Record<string, string | number> = {
63
+ networkEstimateGwei: formatGwei(networkEstimate),
64
+ };
65
+
66
+ // Extract pending block from settled result
67
+ const pendingBlock = results.pendingBlock.status === 'fulfilled' ? results.pendingBlock.value : null;
68
+
69
+ // Analyze pending block transactions
70
+ if (pendingBlock?.transactions && pendingBlock.transactions.length > 0) {
71
+ const pendingFees = pendingBlock.transactions
72
+ .map(tx => {
73
+ if (typeof tx === 'string') {
74
+ return 0n;
75
+ }
76
+ const fee = tx.maxPriorityFeePerGas || 0n;
77
+
78
+ return fee;
79
+ })
80
+ .filter((fee: bigint) => fee > 0n);
81
+
82
+ if (pendingFees.length > 0) {
83
+ // Use 75th percentile of pending fees to be competitive
84
+ const pendingCompetitiveFee = calculatePercentile(pendingFees, 75);
85
+
86
+ if (pendingCompetitiveFee > competitiveFee) {
87
+ competitiveFee = pendingCompetitiveFee;
88
+ }
89
+
90
+ debugInfo.pendingTxCount = pendingFees.length;
91
+ debugInfo.pendingP75Gwei = formatGwei(pendingCompetitiveFee);
92
+
93
+ logger?.debug('Analyzed pending transactions for competitive pricing', {
94
+ pendingTxCount: pendingFees.length,
95
+ pendingP75: formatGwei(pendingCompetitiveFee),
96
+ });
97
+ }
98
+ }
99
+
100
+ // Extract fee history from settled result
101
+ const feeHistory = results.feeHistory.status === 'fulfilled' ? results.feeHistory.value : null;
102
+
103
+ // Analyze fee history
104
+ if (feeHistory?.reward && feeHistory.reward.length > 0) {
105
+ // Extract 75th percentile fees from each block
106
+ const percentile75Fees = feeHistory.reward.map(rewards => rewards[0] || 0n).filter(fee => fee > 0n);
107
+
108
+ if (percentile75Fees.length > 0) {
109
+ // Calculate median of the 75th percentile fees across blocks
110
+ const medianHistoricalFee = median(percentile75Fees) ?? 0n;
111
+
112
+ // Debug: Log suspicious fees from history
113
+ if (medianHistoricalFee > 100n * WEI_CONST) {
114
+ logger?.warn('Suspicious high fee in history', {
115
+ historicalMedian: formatGwei(medianHistoricalFee),
116
+ allP75Fees: percentile75Fees.map(f => formatGwei(f)),
117
+ });
118
+ }
119
+
120
+ if (medianHistoricalFee > competitiveFee) {
121
+ competitiveFee = medianHistoricalFee;
122
+ }
123
+
124
+ debugInfo.historicalMedianGwei = formatGwei(medianHistoricalFee);
125
+
126
+ logger?.debug('Analyzed fee history for competitive pricing', {
127
+ historicalMedian: formatGwei(medianHistoricalFee),
128
+ });
129
+ }
130
+ }
131
+
132
+ // Sanity check: cap competitive fee at 100x network estimate to avoid using unrealistic fees
133
+ const maxReasonableFee = networkEstimate * 100n;
134
+ if (competitiveFee > maxReasonableFee && networkEstimate > 0n) {
135
+ logger?.warn('Competitive fee exceeds sanity cap, using capped value', {
136
+ competitiveFee: formatGwei(competitiveFee),
137
+ networkEstimate: formatGwei(networkEstimate),
138
+ cappedTo: formatGwei(maxReasonableFee),
139
+ });
140
+ competitiveFee = maxReasonableFee;
141
+ debugInfo.cappedToGwei = formatGwei(maxReasonableFee);
142
+ }
143
+
144
+ // Log final decision
145
+ if (competitiveFee > networkEstimate) {
146
+ logger?.debug('Using competitive fee from market analysis', {
147
+ networkEstimate: formatGwei(networkEstimate),
148
+ competitive: formatGwei(competitiveFee),
149
+ });
150
+ }
151
+
152
+ debugInfo.finalFeeGwei = formatGwei(competitiveFee);
153
+
154
+ return {
155
+ priorityFee: competitiveFee,
156
+ debugInfo,
157
+ };
158
+ },
159
+ };
@@ -0,0 +1,241 @@
1
+ import { median } from '@aztec/foundation/collection';
2
+
3
+ import { type GetFeeHistoryReturnType, formatGwei } from 'viem';
4
+
5
+ import type { ViemClient } from '../../types.js';
6
+ import { calculatePercentile, isBlobTransaction } from '../../utils.js';
7
+ import { WEI_CONST } from '../constants.js';
8
+ import {
9
+ HISTORICAL_BLOCK_COUNT,
10
+ type PriorityFeeStrategy,
11
+ type PriorityFeeStrategyContext,
12
+ type PriorityFeeStrategyResult,
13
+ } from './types.js';
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
+ /**
25
+ * Fetches historical blocks and calculates reward percentiles for blob transactions only.
26
+ * Returns data in the same format as getFeeHistory for easy drop-in replacement.
27
+ *
28
+ * @param client - Viem client to use for RPC calls
29
+ * @param blockCount - Number of historical blocks to fetch
30
+ * @param rewardPercentiles - Array of percentiles to calculate (e.g., [75] for 75th percentile)
31
+ * @returns Object with reward field containing percentile fees for each block, similar to getFeeHistory
32
+ * @throws Error if fetching blocks fails
33
+ */
34
+ export async function getBlobPriorityFeeHistory(
35
+ client: ViemClient,
36
+ blockCount: number,
37
+ rewardPercentiles: number[],
38
+ ): Promise<GetFeeHistoryReturnType> {
39
+ const latestBlockNumber = await client.getBlockNumber();
40
+
41
+ // Fetch multiple blocks in parallel
42
+ const blockPromises = Array.from({ length: blockCount }, (_, i) =>
43
+ client.getBlock({
44
+ blockNumber: latestBlockNumber - BigInt(i),
45
+ includeTransactions: true,
46
+ }),
47
+ );
48
+
49
+ const blocks = await Promise.all(blockPromises);
50
+
51
+ // Process each block to extract blob transaction fees and other data
52
+ const baseFeePerGas: bigint[] = [];
53
+ const gasUsedRatio: number[] = [];
54
+ const reward: bigint[][] = [];
55
+
56
+ for (const block of blocks) {
57
+ // Collect base fee per gas
58
+ baseFeePerGas.push(block.baseFeePerGas || 0n);
59
+
60
+ // Calculate gas used ratio
61
+ const gasUsed = block.gasUsed || 0n;
62
+ const gasLimit = block.gasLimit || 1n; // Avoid division by zero
63
+ gasUsedRatio.push(Number(gasUsed) / Number(gasLimit));
64
+
65
+ if (!block.transactions || block.transactions.length === 0) {
66
+ // No transactions in this block - return zeros for each percentile
67
+ reward.push(rewardPercentiles.map(() => 0n));
68
+ continue;
69
+ }
70
+
71
+ // Extract priority fees from blob transactions only
72
+ const blobFees = block.transactions
73
+ .map(tx => {
74
+ // Transaction can be just a hash string
75
+ if (typeof tx === 'string') {
76
+ return 0n;
77
+ }
78
+
79
+ if (!isBlobTransaction(tx)) {
80
+ return 0n;
81
+ }
82
+ return tx.maxPriorityFeePerGas || 0n;
83
+ })
84
+ .filter((fee: bigint) => fee > 0n);
85
+
86
+ if (blobFees.length === 0) {
87
+ // No blob transactions in this block - return zeros for each percentile
88
+ reward.push(rewardPercentiles.map(() => 0n));
89
+ continue;
90
+ }
91
+
92
+ // Calculate requested percentiles
93
+ const percentiles = rewardPercentiles.map(percentile => calculatePercentile(blobFees, percentile));
94
+
95
+ reward.push(percentiles);
96
+ }
97
+
98
+ // Calculate oldest block number (the last block in our array)
99
+ const oldestBlock = latestBlockNumber - BigInt(blockCount - 1);
100
+
101
+ // Reverse arrays to match getFeeHistory behavior (oldest first)
102
+ return {
103
+ baseFeePerGas: baseFeePerGas.reverse(),
104
+ gasUsedRatio: gasUsedRatio.reverse(),
105
+ oldestBlock,
106
+ reward: reward.reverse(),
107
+ };
108
+ }
109
+
110
+ /**
111
+ * Similar to our current competitive priority fee strategy, but only considers blob transactions
112
+ * when calculating competitive priority fee for blob transactions.
113
+ * This strategy also has NO cap on the competitive fee if it's much higher than the network estimate.
114
+ * Analyzes p75 of pending transactions and 5-block fee history to determine a competitive priority fee.
115
+ * Falls back to network estimate if data is unavailable.
116
+ */
117
+ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy<P75AllTxsStrategyPromises> = {
118
+ name: 'Competitive (P75 + History) - Blob Txs Only',
119
+ id: 'p75_pending_txs_and_history_blob_txs_only',
120
+
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;
144
+
145
+ // Extract network estimate from settled result
146
+ const networkEstimate =
147
+ results.networkEstimate.status === 'fulfilled' && typeof results.networkEstimate.value === 'bigint'
148
+ ? results.networkEstimate.value
149
+ : 0n;
150
+
151
+ let competitiveFee = networkEstimate;
152
+ const debugInfo: Record<string, string | number> = {
153
+ networkEstimateGwei: formatGwei(networkEstimate),
154
+ };
155
+
156
+ // Extract pending block from settled result
157
+ const pendingBlock = results.pendingBlock.status === 'fulfilled' ? results.pendingBlock.value : null;
158
+
159
+ // Analyze pending block transactions
160
+ if (pendingBlock?.transactions && pendingBlock.transactions.length > 0) {
161
+ const pendingFees = pendingBlock.transactions
162
+ .map(tx => {
163
+ if (typeof tx === 'string') {
164
+ return 0n;
165
+ }
166
+ if (context.isBlobTx) {
167
+ if (!isBlobTransaction(tx)) {
168
+ return 0n;
169
+ }
170
+ }
171
+ const fee = tx.maxPriorityFeePerGas || 0n;
172
+
173
+ return fee;
174
+ })
175
+ .filter((fee: bigint) => fee > 0n);
176
+
177
+ if (pendingFees.length > 0) {
178
+ const pendingCompetitiveFee = calculatePercentile(pendingFees, 75);
179
+
180
+ if (pendingCompetitiveFee > competitiveFee) {
181
+ competitiveFee = pendingCompetitiveFee;
182
+ }
183
+
184
+ debugInfo.pendingTxCount = pendingFees.length;
185
+ debugInfo.pendingP75Gwei = formatGwei(pendingCompetitiveFee);
186
+
187
+ logger?.debug('Analyzed pending transactions for competitive pricing', {
188
+ pendingTxCount: pendingFees.length,
189
+ pendingP75: formatGwei(pendingCompetitiveFee),
190
+ });
191
+ }
192
+ }
193
+
194
+ // Extract fee history from settled result
195
+ const feeHistory = results.feeHistory.status === 'fulfilled' ? results.feeHistory.value : null;
196
+
197
+ // Analyze fee history
198
+ if (feeHistory?.reward && feeHistory.reward.length > 0) {
199
+ // Extract 75th percentile fees from each block
200
+ const percentile75Fees = feeHistory.reward.map(rewards => rewards[0] || 0n).filter(fee => fee > 0n);
201
+
202
+ if (percentile75Fees.length > 0) {
203
+ // Calculate median of the 75th percentile fees across blocks
204
+ const medianHistoricalFee = median(percentile75Fees) ?? 0n;
205
+
206
+ // Debug: Log suspicious fees from history
207
+ if (medianHistoricalFee > 100n * WEI_CONST) {
208
+ logger?.warn('Suspicious high fee in history', {
209
+ historicalMedian: formatGwei(medianHistoricalFee),
210
+ allP75Fees: percentile75Fees.map(f => formatGwei(f)),
211
+ });
212
+ }
213
+
214
+ if (medianHistoricalFee > competitiveFee) {
215
+ competitiveFee = medianHistoricalFee;
216
+ }
217
+
218
+ debugInfo.historicalMedianGwei = formatGwei(medianHistoricalFee);
219
+
220
+ logger?.debug('Analyzed fee history for competitive pricing', {
221
+ historicalMedian: formatGwei(medianHistoricalFee),
222
+ });
223
+ }
224
+ }
225
+
226
+ // Log final decision
227
+ if (competitiveFee > networkEstimate) {
228
+ logger?.debug('Using competitive fee from market analysis', {
229
+ networkEstimate: formatGwei(networkEstimate),
230
+ competitive: formatGwei(competitiveFee),
231
+ });
232
+ }
233
+
234
+ debugInfo.finalFeeGwei = formatGwei(competitiveFee);
235
+
236
+ return {
237
+ priorityFee: competitiveFee,
238
+ debugInfo,
239
+ };
240
+ },
241
+ };