fix(payload): sum cumulative gas used before adding receipt (#2284)

This commit is contained in:
Matthias Seitz
2023-04-17 16:31:52 +02:00
committed by GitHub
parent e5d4767c8e
commit 0559d8c2d5

View File

@ -477,10 +477,14 @@ fn build_payload<Pool, Client>(
// TODO skip invalid transactions
let ResultAndState { result, state } =
evm.transact().map_err(PayloadBuilderError::EvmExecutionError)?;
let gas_used = result.gas_used();
// commit changes
commit_state_changes(&mut db, &mut post_state, state, true);
// add gas used by the transaction to cumulative gas used, before creating the receipt
cumulative_gas_used += gas_used;
// Push transaction changeset and calculate header bloom filter for receipt.
post_state.add_receipt(Receipt {
tx_type: tx.tx_type(),
@ -489,17 +493,12 @@ fn build_payload<Pool, Client>(
logs: result.logs().into_iter().map(into_reth_log).collect(),
});
let gas_used = result.gas_used();
// update add to total fees
let miner_fee = tx
.effective_tip_per_gas(base_fee)
.expect("fee is always valid; execution succeeded");
total_fees += U256::from(miner_fee) * U256::from(gas_used);
// append gas used
cumulative_gas_used += gas_used;
// append transaction to the list of executed transactions
executed_txs.push(tx.into_signed());
}