fix: unwind on execution and senders errors (#2938)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
Dan Cline
2023-06-06 16:17:12 -04:00
committed by GitHub
parent d771a1b378
commit c0fb169da4
9 changed files with 133 additions and 48 deletions

View File

@ -11,7 +11,7 @@ use reth_interfaces::{
BlockStatus, CanonicalOutcome,
},
consensus::{Consensus, ConsensusError},
executor::BlockExecutionError,
executor::{BlockExecutionError, BlockValidationError},
Error,
};
use reth_primitives::{
@ -378,7 +378,7 @@ impl<DB: Database, C: Consensus, EF: ExecutorFactory> BlockchainTree<DB, C, EF>
if !self.externals.chain_spec.fork(Hardfork::Paris).active_at_ttd(parent_td, U256::ZERO)
{
return Err(InsertBlockError::execution_error(
BlockExecutionError::BlockPreMerge { hash: block.hash },
BlockValidationError::BlockPreMerge { hash: block.hash }.into(),
block.block,
))
}
@ -869,14 +869,16 @@ impl<DB: Database, C: Consensus, EF: ExecutorFactory> BlockchainTree<DB, C, EF>
// If block is already canonical don't return error.
if let Some(header) = self.find_canonical_header(block_hash)? {
info!(target: "blockchain_tree", ?block_hash, "Block is already canonical, ignoring.");
let td = self
.externals
.database()
.provider()?
.header_td(block_hash)?
.ok_or(BlockExecutionError::MissingTotalDifficulty { hash: *block_hash })?;
let td = self.externals.database().provider()?.header_td(block_hash)?.ok_or(
BlockExecutionError::from(BlockValidationError::MissingTotalDifficulty {
hash: *block_hash,
}),
)?;
if !self.externals.chain_spec.fork(Hardfork::Paris).active_at_ttd(td, U256::ZERO) {
return Err(BlockExecutionError::BlockPreMerge { hash: *block_hash }.into())
return Err(BlockExecutionError::from(BlockValidationError::BlockPreMerge {
hash: *block_hash,
})
.into())
}
return Ok(CanonicalOutcome::AlreadyCanonical { header })
}