From f538c8a7df253ae11d302a1bbec71ab57ed6c302 Mon Sep 17 00:00:00 2001 From: clabby Date: Sun, 15 Oct 2023 20:56:07 -0400 Subject: [PATCH] test patch - definitely the nonce --- bin/reth/src/args/payload_builder_args.rs | 10 +++------- crates/payload/basic/src/optimism.rs | 16 +++++++++++++--- crates/revm/src/optimism/processor.rs | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/bin/reth/src/args/payload_builder_args.rs b/bin/reth/src/args/payload_builder_args.rs index 49f695b251ff2..55c211c9e9fbf 100644 --- a/bin/reth/src/args/payload_builder_args.rs +++ b/bin/reth/src/args/payload_builder_args.rs @@ -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::::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 { @@ -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 } } diff --git a/crates/payload/basic/src/optimism.rs b/crates/payload/basic/src/optimism.rs index a5ffaed5e54a5..a965512968b1e 100644 --- a/crates/payload/basic/src/optimism.rs +++ b/crates/payload/basic/src/optimism.rs @@ -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()?; @@ -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 @@ -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 diff --git a/crates/revm/src/optimism/processor.rs b/crates/revm/src/optimism/processor.rs index daf205accbfda..bfed3a9ff4cbb 100644 --- a/crates/revm/src/optimism/processor.rs +++ b/crates/revm/src/optimism/processor.rs @@ -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()?; @@ -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 } @@ -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), }); }