Skip to content

Commit

Permalink
Remove unecessary implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuly14 committed Apr 12, 2024
1 parent 3671cb9 commit 3d6a138
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 40 additions & 40 deletions evm/src/executor/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use revm::{
db::{CacheDB, DatabaseRef},
precompile::Precompiles,
primitives::{
Account, AccountInfo, Bytecode, CreateScheme, Env, Log, ResultAndState,
TransactTo, IcanAddress, B256, SHA3_EMPTY, U256 as rU256, SpecId,
Account, AccountInfo, Bytecode, CreateScheme, Env, IcanAddress, Log, ResultAndState,
SpecId, TransactTo, B256, SHA3_EMPTY, U256 as rU256,
},
Database, DatabaseCommit, Inspector, JournaledState, Evm,
Database, DatabaseCommit, Evm, Inspector, JournaledState,
};
use std::{
collections::{hash_map::RandomState, HashMap, HashSet},
Expand Down Expand Up @@ -413,7 +413,7 @@ impl Backend {
// Note: this will take of registering the `fork`
let inner = BackendInner {
persistent_accounts: get_default_persistent_accounts(network),
cheatcode_access_accounts: HashSet::from([
cheatcode_access_accounts: HashSet::from([
default_cheatcode_address(Some(*network)),
default_test_contract_address(Some(*network)),
Config::default_sender(Some(&network)),
Expand Down Expand Up @@ -732,9 +732,9 @@ impl Backend {
{
self.initialize(env);


let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env;
let context = revm::Context::new(revm::EvmContext::new_with_env(self.mem_db, env), inspector);
let context =
revm::Context::new(revm::EvmContext::new_with_env(self.mem_db, env), inspector);
let mut handler = revm::Handler::new(handler_cfg);
handler.append_handler_register_plain(revm::inspector_handle_register);
revm::Evm::new(context, handler)
Expand Down Expand Up @@ -1297,40 +1297,40 @@ impl DatabaseRef for Backend {
}
}

impl<'a> DatabaseRef for &'a mut Backend {
type Error = DatabaseError;
fn basic_ref(&self, address: IcanAddress) -> Result<Option<AccountInfo>, Self::Error> {
if let Some(db) = self.active_fork_db() {
DatabaseRef::basic(db, address)
} else {
Ok(DatabaseRef::basic(&self.mem_db, address)?)
}
}

fn code_by_hash_ref(&self, code_hash: B256) -> Result<Bytecode, Self::Error> {
if let Some(db) = self.active_fork_db() {
DatabaseRef::code_by_hash(db, code_hash)
} else {
Ok(DatabaseRef::code_by_hash(&self.mem_db, code_hash)?)
}
}

fn storage_ref(&self, address: IcanAddress, index: rU256) -> Result<rU256, Self::Error> {
if let Some(db) = self.active_fork_db() {
DatabaseRef::storage(db, address, index)
} else {
Ok(DatabaseRef::storage(&self.mem_db, address, index)?)
}
}

fn block_hash_ref(&self, number: rU256) -> Result<B256, Self::Error> {
if let Some(db) = self.active_fork_db() {
DatabaseRef::block_hash(db, number)
} else {
Ok(DatabaseRef::block_hash(&self.mem_db, number)?)
}
}
}
// impl<'a> DatabaseRef for &'a mut Backend {
// type Error = DatabaseError;
// fn basic_ref(&self, address: IcanAddress) -> Result<Option<AccountInfo>, Self::Error> {
// if let Some(db) = self.active_fork_db() {
// DatabaseRef::basic(db, address)
// } else {
// Ok(DatabaseRef::basic(&self.mem_db, address)?)
// }
// }

// fn code_by_hash_ref(&self, code_hash: B256) -> Result<Bytecode, Self::Error> {
// if let Some(db) = self.active_fork_db() {
// DatabaseRef::code_by_hash(db, code_hash)
// } else {
// Ok(DatabaseRef::code_by_hash(&self.mem_db, code_hash)?)
// }
// }

// fn storage_ref(&self, address: IcanAddress, index: rU256) -> Result<rU256, Self::Error> {
// if let Some(db) = self.active_fork_db() {
// DatabaseRef::storage(db, address, index)
// } else {
// Ok(DatabaseRef::storage(&self.mem_db, address, index)?)
// }
// }

// fn block_hash_ref(&self, number: rU256) -> Result<B256, Self::Error> {
// if let Some(db) = self.active_fork_db() {
// DatabaseRef::block_hash(db, number)
// } else {
// Ok(DatabaseRef::block_hash(&self.mem_db, number)?)
// }
// }
// }

impl DatabaseCommit for Backend {
fn commit(&mut self, changes: Map<IcanAddress, Account>) {
Expand Down

0 comments on commit 3d6a138

Please sign in to comment.