mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(payload): sum cumulative gas used before adding receipt (#2284)
This commit is contained in:
@ -477,10 +477,14 @@ fn build_payload<Pool, Client>(
|
|||||||
// TODO skip invalid transactions
|
// TODO skip invalid transactions
|
||||||
let ResultAndState { result, state } =
|
let ResultAndState { result, state } =
|
||||||
evm.transact().map_err(PayloadBuilderError::EvmExecutionError)?;
|
evm.transact().map_err(PayloadBuilderError::EvmExecutionError)?;
|
||||||
|
let gas_used = result.gas_used();
|
||||||
|
|
||||||
// commit changes
|
// commit changes
|
||||||
commit_state_changes(&mut db, &mut post_state, state, true);
|
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.
|
// Push transaction changeset and calculate header bloom filter for receipt.
|
||||||
post_state.add_receipt(Receipt {
|
post_state.add_receipt(Receipt {
|
||||||
tx_type: tx.tx_type(),
|
tx_type: tx.tx_type(),
|
||||||
@ -489,17 +493,12 @@ fn build_payload<Pool, Client>(
|
|||||||
logs: result.logs().into_iter().map(into_reth_log).collect(),
|
logs: result.logs().into_iter().map(into_reth_log).collect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let gas_used = result.gas_used();
|
|
||||||
|
|
||||||
// update add to total fees
|
// update add to total fees
|
||||||
let miner_fee = tx
|
let miner_fee = tx
|
||||||
.effective_tip_per_gas(base_fee)
|
.effective_tip_per_gas(base_fee)
|
||||||
.expect("fee is always valid; execution succeeded");
|
.expect("fee is always valid; execution succeeded");
|
||||||
total_fees += U256::from(miner_fee) * U256::from(gas_used);
|
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
|
// append transaction to the list of executed transactions
|
||||||
executed_txs.push(tx.into_signed());
|
executed_txs.push(tx.into_signed());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user