diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index b803e9a351..a2baad0410 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -211,6 +211,8 @@ where let is_osaka = chain_spec.is_osaka_active_at_timestamp(attributes.timestamp); + let withdrawals_rlp_length = attributes.withdrawals().length(); + while let Some(pool_tx) = best_txs.next() { // ensure we still have capacity for this transaction if cumulative_gas_used + pool_tx.gas_limit() > block_gas_limit { @@ -232,10 +234,10 @@ where // convert tx to a signed transaction let tx = pool_tx.to_consensus(); - let estimated_block_size_with_tx = block_transactions_rlp_length + - tx.inner().length() + - attributes.withdrawals().length() + - 1024; // 1Kb of overhead for the block header + let tx_rlp_len = tx.inner().length(); + + let estimated_block_size_with_tx = + block_transactions_rlp_length + tx_rlp_len + withdrawals_rlp_length + 1024; // 1Kb of overhead for the block header if is_osaka && estimated_block_size_with_tx > MAX_RLP_BLOCK_SIZE { best_txs.mark_invalid( @@ -336,7 +338,7 @@ where } } - block_transactions_rlp_length += tx.inner().length(); + block_transactions_rlp_length += tx_rlp_len; // update and add to total fees let miner_fee =