From c436cef1c3b84ec7cba82622cf2c18a2c889c12a Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Thu, 27 Jun 2024 03:00:04 +0700 Subject: [PATCH] remove err handling --- crates/evm/core/src/backend/cow.rs | 15 +++------------ crates/evm/core/src/backend/mod.rs | 13 +++---------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index a1049db6ac59..9aa3ce0eb304 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -245,22 +245,13 @@ impl<'a> DatabaseExt for CowBackend<'a> { self.backend.has_cheatcode_access(account) } - fn set_blockhash(&mut self, block_number: B256, block_hash: B256) -> Result<(), DatabaseError> { - match self - .backend + fn set_blockhash(&mut self, block_number: B256, block_hash: B256) { + self.backend .to_mut() .mem_db() .to_owned() .block_hashes - .insert(block_number.into(), block_hash) - { - Some(_) => Ok(()), - None => Err(DatabaseError::Other(format!( - " - Cannot set blockhash {:?} for block number {:?}", - block_hash, block_number - ))), - } + .insert(block_number.into(), block_hash); } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 6d94f9228899..00a26d2fe86f 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -332,7 +332,7 @@ pub trait DatabaseExt: Database { } /// set the blockhash for the given block number - fn set_blockhash(&mut self, block_number: B256, block_hash: B256) -> Result<(), DatabaseError>; + fn set_blockhash(&mut self, block_number: B256, block_hash: B256); } struct _ObjectSafe(dyn DatabaseExt); @@ -1374,15 +1374,8 @@ impl DatabaseExt for Backend { self.inner.cheatcode_access_accounts.contains(account) } - fn set_blockhash(&mut self, block_number: B256, block_hash: B256) -> Result<(), DatabaseError> { - match self.mem_db.block_hashes.insert(block_number.into(), block_hash) { - Some(_) => Ok(()), - None => Err(DatabaseError::Other(format!( - " - Cannot set blockhash {:?} for block number {:?}", - block_hash, block_number - ))), - } + fn set_blockhash(&mut self, block_number: B256, block_hash: B256) { + self.mem_db.block_hashes.insert(block_number.into(), block_hash); } }