diff --git a/crates/executor/src/blockchain_tree/shareable.rs b/crates/executor/src/blockchain_tree/shareable.rs index e69bd7a012..a46667c9c7 100644 --- a/crates/executor/src/blockchain_tree/shareable.rs +++ b/crates/executor/src/blockchain_tree/shareable.rs @@ -5,6 +5,7 @@ use reth_interfaces::{ blockchain_tree::{BlockStatus, BlockchainTreeEngine, BlockchainTreeViewer}, consensus::Consensus, events::{ChainEventSubscriptions, NewBlockNotifications}, + provider::ProviderError, Error, }; use reth_primitives::{BlockHash, BlockNumHash, BlockNumber, SealedBlockWithSenders}; @@ -80,7 +81,12 @@ impl BlockchainTreePendingState &self, block_hash: BlockHash, ) -> Result, Error> { - let Some(post_state) = self.tree.read().post_state_data(block_hash) else { panic!("")}; + let post_state = self + .tree + .read() + .post_state_data(block_hash) + .ok_or(ProviderError::UnknownBlockHash(block_hash)) + .map(Box::new)?; Ok(Box::new(post_state)) } } diff --git a/crates/executor/src/executor.rs b/crates/executor/src/executor.rs index d0db0a8928..ba502dc831 100644 --- a/crates/executor/src/executor.rs +++ b/crates/executor/src/executor.rs @@ -1015,7 +1015,7 @@ mod tests { let mut executor = Executor::new(chain_spec, db); // touch account executor.commit_changes( - hash_map::HashMap::from([(account, RevmAccount { ..default_acc.clone() })]), + hash_map::HashMap::from([(account, default_acc.clone())]), true, &mut PostState::default(), ); @@ -1039,7 +1039,7 @@ mod tests { ); // touch account executor.commit_changes( - hash_map::HashMap::from([(account, RevmAccount { ..default_acc })]), + hash_map::HashMap::from([(account, default_acc)]), true, &mut PostState::default(), ); diff --git a/crates/interfaces/src/provider.rs b/crates/interfaces/src/provider.rs index 33ace26d1e..b20e7b92a6 100644 --- a/crates/interfaces/src/provider.rs +++ b/crates/interfaces/src/provider.rs @@ -88,4 +88,7 @@ pub enum ProviderError { /// Thrown when the cache service task dropped #[error("cache service task stopped")] CacheServiceUnavailable, + /// Thrown when we failed to lookup a block for the pending state + #[error("Unknown block hash: {0:}")] + UnknownBlockHash(H256), }