mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-09 07:17:56 -05:00
refactor(ethereum): cache RLP lengths in ethereum payload builder (#20758)
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user