|
1 | 1 | //! Helpers to build the ev-reth executor with EV-specific hooks applied. |
2 | 2 |
|
3 | 3 | use alloy_consensus::{BlockHeader, Header}; |
4 | | -use alloy_eips::Decodable2718; |
| 4 | +use alloy_eips::{eip1559::INITIAL_BASE_FEE, Decodable2718}; |
5 | 5 | use alloy_evm::{eth::spec::EthExecutorSpec, FromRecoveredTx, FromTxWithEncoded}; |
6 | 6 | use alloy_primitives::U256; |
7 | 7 | use alloy_rpc_types_engine::ExecutionData; |
@@ -212,22 +212,27 @@ where |
212 | 212 | } |
213 | 213 | }); |
214 | 214 |
|
215 | | - let (gas_limit, basefee) = if self |
216 | | - .chain_spec() |
| 215 | + // Calculate base fee for the next block |
| 216 | + let mut basefee = chain_spec.next_block_base_fee(parent, attributes.timestamp); |
| 217 | + |
| 218 | + let mut gas_limit = attributes.gas_limit; |
| 219 | + |
| 220 | + // If we are on the London fork boundary, we need to multiply the parent's gas limit by the |
| 221 | + // elasticity multiplier to get the new gas limit. |
| 222 | + if chain_spec |
217 | 223 | .fork(reth_ethereum_forks::EthereumHardfork::London) |
218 | 224 | .transitions_at_block(parent.number + 1) |
219 | 225 | { |
220 | | - let elasticity_multiplier = self |
221 | | - .chain_spec() |
| 226 | + let elasticity_multiplier = chain_spec |
222 | 227 | .base_fee_params_at_timestamp(attributes.timestamp) |
223 | 228 | .elasticity_multiplier; |
224 | | - ( |
225 | | - parent.gas_limit * elasticity_multiplier as u64, |
226 | | - Some(alloy_eips::eip1559::INITIAL_BASE_FEE), |
227 | | - ) |
228 | | - } else { |
229 | | - (parent.gas_limit, None) |
230 | | - }; |
| 229 | + |
| 230 | + // multiply the gas limit by the elasticity multiplier |
| 231 | + gas_limit *= elasticity_multiplier as u64; |
| 232 | + |
| 233 | + // set the base fee to the initial base fee from the EIP-1559 spec |
| 234 | + basefee = Some(INITIAL_BASE_FEE); |
| 235 | + } |
231 | 236 |
|
232 | 237 | let block_env = BlockEnv { |
233 | 238 | number: U256::from(parent.number + 1), |
|
0 commit comments