alloy_eips/eip1559/constants.rs
1use alloy_primitives::U256;
2
3/// The default Ethereum block gas limit: 30M
4pub const ETHEREUM_BLOCK_GAS_LIMIT_30M: u64 = 30_000_000;
5
6/// The default Ethereum block gas limit: 36M
7pub const ETHEREUM_BLOCK_GAS_LIMIT_36M: u64 = 36_000_000;
8
9/// The bound divisor of the gas limit, used in update calculations.
10pub const GAS_LIMIT_BOUND_DIVISOR: u64 = 1024;
11
12/// The minimum tx fee below which the txpool will reject the transaction.
13///
14/// Configured to `7` WEI which is the lowest possible value of base fee under mainnet EIP-1559
15/// parameters. `BASE_FEE_MAX_CHANGE_DENOMINATOR` <https://eips.ethereum.org/EIPS/eip-1559>
16/// is `8`, or 12.5%. Once the base fee has dropped to `7` WEI it cannot decrease further because
17/// 12.5% of 7 is less than 1.
18///
19/// Note that min base fee under different 1559 parameterizations may differ, but there's no
20/// significant harm in leaving this setting as is.
21pub const MIN_PROTOCOL_BASE_FEE: u64 = 7;
22
23/// Same as [MIN_PROTOCOL_BASE_FEE] but as a U256.
24pub const MIN_PROTOCOL_BASE_FEE_U256: U256 = U256::from_limbs([7u64, 0, 0, 0]);
25
26/// Initial base fee as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
27pub const INITIAL_BASE_FEE: u64 = 1_000_000_000;
28
29/// Base fee max change denominator as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
30pub const DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR: u64 = 8;
31
32/// Elasticity multiplier as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
33pub const DEFAULT_ELASTICITY_MULTIPLIER: u64 = 2;
34
35/// Base fee max change denominator for Optimism Sepolia as defined in the Optimism
36/// [transaction costs](https://docs.optimism.io/stack/differences#transactions) doc.
37pub(crate) const OP_SEPOLIA_EIP1559_DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR: u128 = 50;
38
39/// Base fee max change denominator for Optimism Sepolia as defined in the Optimism Canyon hardfork.
40pub(crate) const OP_SEPOLIA_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_CANYON: u128 = 250;
41
42/// Base fee max change denominator for Optimism Sepolia as defined in the Optimism
43/// [transaction costs](https://docs.optimism.io/stack/differences#transactions) doc.
44pub(crate) const OP_SEPOLIA_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER: u128 = 6;
45
46/// Base fee max change denominator for Optimism Mainnet as defined in the Optimism
47/// [transaction costs](https://docs.optimism.io/stack/differences#transactions) doc.
48pub(crate) const OP_MAINNET_EIP1559_DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR: u128 = 50;
49
50/// Base fee max change denominator for Optimism Mainnet as defined in the Optimism Canyon hardfork.
51pub(crate) const OP_MAINNET_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_CANYON: u128 = 250;
52
53/// Base fee max change denominator for Optimism Mainnet as defined in the Optimism
54/// [transaction costs](https://docs.optimism.io/stack/differences#transactions) doc.
55pub(crate) const OP_MAINNET_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER: u128 = 6;
56
57/// Base fee max change denominator for Base Sepolia as defined in the Optimism
58/// [transaction costs](https://docs.optimism.io/stack/differences#transactions) doc.
59pub(crate) const BASE_SEPOLIA_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER: u128 = 10;
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64
65 #[test]
66 fn min_protocol_sanity() {
67 assert_eq!(MIN_PROTOCOL_BASE_FEE_U256.to::<u64>(), MIN_PROTOCOL_BASE_FEE);
68 }
69}