alloy_eips/eip1559/
constants.rs

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