Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Payload builder update
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Aug 19, 2023
1 parent 02c8135 commit b5fe0f3
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions crates/payload/basic/src/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use super::*;
use reth_primitives::Hardfork;
use reth_revm::{executor, to_reth_acc};

Check failure on line 5 in crates/payload/basic/src/optimism.rs

View workflow job for this annotation

GitHub Actions / code lint

unused import: `to_reth_acc`

/// Constructs an Ethereum transaction payload from the transactions sent through the
/// Payload attributes by the sequencer. If the `no_tx_pool` argument is passed in
Expand Down Expand Up @@ -50,6 +51,9 @@ where

let block_number = initialized_block_env.number.to::<u64>();

let is_regolith =
chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, attributes.timestamp);

// Transactions sent via the payload attributes are force included at the top of the block, in
// the order that they were sent in.
for sequencer_tx in attributes.transactions {
Expand All @@ -72,14 +76,23 @@ where
if sequencer_tx.is_deposit() {
cfg.disable_base_fee = true;
cfg.disable_balance_check = true;
cfg.disable_gas_refund = true;

// If the Regolith hardfork is active, we do not need to disable the block gas limit.
// Otherwise, we allow for the block gas limit to be exceeded by deposit transactions.
if !chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, attributes.timestamp) &&
sequencer_tx.is_deposit()
{
if !is_regolith && sequencer_tx.is_deposit() {
cfg.disable_block_gas_limit = true;
};

if let Some(m) = sequencer_tx.mint() {
executor::increment_account_balance(
&mut db,
&mut post_state,
parent_block.number + 1,
sequencer_tx.signer(),
U256::from(m),
)?;
}
}

// Configure the environment for the block.
Expand Down Expand Up @@ -130,6 +143,12 @@ where
// commit changes
commit_state_changes(&mut db, &mut post_state, block_number, state, true);

if is_regolith || !sequencer_tx.is_deposit() {
cumulative_gas_used += result.gas_used()
} else if sequencer_tx.is_deposit() && !sequencer_tx.is_system_transaction() {
cumulative_gas_used += sequencer_tx.gas_limit();
}

// Push transaction changeset and calculate header bloom filter for receipt.
post_state.add_receipt(
block_number,
Expand All @@ -138,10 +157,7 @@ where
success: result.is_success(),
cumulative_gas_used,
logs: result.logs().into_iter().map(into_reth_log).collect(),
deposit_nonce: if chain_spec
.is_fork_active_at_timestamp(Hardfork::Regolith, attributes.timestamp) &&
sequencer_tx.is_deposit()
{
deposit_nonce: if is_regolith && sequencer_tx.is_deposit() {
// Recovering the signer from the deposit transaction is only fetching
// the `from` address. Deposit transactions have no signature.
let from = sequencer_tx.signer();
Expand Down

0 comments on commit b5fe0f3

Please sign in to comment.