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

Commit

Permalink
test patch - definitely the nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Oct 16, 2023
1 parent a778a50 commit f538c8a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
10 changes: 3 additions & 7 deletions bin/reth/src/args/payload_builder_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ pub struct PayloadBuilderArgs {
/// Maximum number of tasks to spawn for building a payload.
#[arg(long = "builder.max-tasks", help_heading = "Builder", default_value = "3", value_parser = RangedU64ValueParser::<usize>::new().range(1..))]
pub max_payload_tasks: usize,

/// Whether or not to construct the pending block during the payload building job.
#[cfg(feature = "optimism")]
pub compute_pending_block: bool,
}

impl PayloadBuilderConfig for PayloadBuilderArgs {
Expand All @@ -65,15 +61,15 @@ impl PayloadBuilderConfig for PayloadBuilderArgs {

#[cfg(feature = "optimism")]
fn compute_pending_block(&self) -> bool {
self.compute_pending_block
false
}
}

#[cfg(feature = "optimism")]
impl PayloadBuilderArgs {
/// Sets the `compute_pending_block` flag.
pub fn set_compute_pending_block(&mut self, compute_pending_block: bool) {
self.compute_pending_block = compute_pending_block;
pub fn set_compute_pending_block(&mut self, _compute_pending_block: bool) {
// noop - todo
}
}

Expand Down
16 changes: 13 additions & 3 deletions crates/payload/basic/src/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
db.load_cache_account(sequencer_tx.signer())
.map_err(|_| PayloadBuilderError::AccountLoadFailed(sequencer_tx.signer()))?
.clone()
.account
.account_info()
.ok_or(PayloadBuilderError::AccountLoadFailed(sequencer_tx.signer()))
})
.transpose()?;
Expand All @@ -95,16 +95,26 @@ where
Ok(res) => res,
Err(err) => {
if sequencer_tx.is_deposit() {
// Bump nonce on deposit failure, a receipt is included.
let mut sender_account = db
.load_cache_account(sequencer_tx.signer())
.map_err(|_| PayloadBuilderError::AccountLoadFailed(sequencer_tx.signer()))?
.account_info()
.ok_or(PayloadBuilderError::AccountLoadFailed(sequencer_tx.signer()))?;
sender_account.nonce = sender_account.nonce.saturating_add(1);
db.insert_account(sequencer_tx.signer(), sender_account);

if is_regolith || !sequencer_tx.is_system_transaction() {
cumulative_gas_used += sequencer_tx.gas_limit();
}

receipts.push(Some(Receipt {
tx_type: sequencer_tx.tx_type(),
success: false,
cumulative_gas_used,
logs: vec![],
#[cfg(feature = "optimism")]
deposit_nonce: depositor.map(|account| account.info.nonce),
deposit_nonce: depositor.map(|account| account.nonce),
}));
executed_txs.push(sequencer_tx.into_signed());
continue
Expand Down Expand Up @@ -146,7 +156,7 @@ where
cumulative_gas_used,
logs: result.logs().into_iter().map(into_reth_log).collect(),
#[cfg(feature = "optimism")]
deposit_nonce: depositor.map(|account| account.info.nonce),
deposit_nonce: depositor.map(|account| account.nonce),
}));

// append transaction to the list of executed transactions
Expand Down
18 changes: 14 additions & 4 deletions crates/revm/src/optimism/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
self.db_mut()
.load_cache_account(sender)
.map_err(|_| BlockExecutionError::ProviderError)?
.clone()
.account
.account_info()
.ok_or(BlockExecutionError::ProviderError)
})
.transpose()?;
Expand All @@ -103,16 +102,27 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
Ok(res) => res,
Err(err) => {
if transaction.is_deposit() {
// Bump nonce on deposit failure, a receipt is included.
let mut sender_account = self
.db_mut()
.load_cache_account(sender)
.map_err(|_| BlockExecutionError::ProviderError)?
.account_info()
.ok_or(BlockExecutionError::ProviderError)?;
sender_account.nonce = sender_account.nonce.saturating_add(1);
self.db_mut().insert_account(sender, sender_account);

if is_regolith || !transaction.is_system_transaction() {
cumulative_gas_used += transaction.gas_limit();
}

receipts.push(Receipt {
tx_type: transaction.tx_type(),
success: false,
cumulative_gas_used,
logs: vec![],
#[cfg(feature = "optimism")]
deposit_nonce: depositor.map(|account| account.info.nonce),
deposit_nonce: depositor.map(|account| account.nonce),
});
continue
}
Expand Down Expand Up @@ -144,7 +154,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
// convert to reth log
logs: result.into_logs().into_iter().map(into_reth_log).collect(),
#[cfg(feature = "optimism")]
deposit_nonce: depositor.map(|account| account.info.nonce),
deposit_nonce: depositor.map(|account| account.nonce),
});
}

Expand Down

0 comments on commit f538c8a

Please sign in to comment.