diff --git a/crates/primitives-traits/src/account.rs b/crates/primitives-traits/src/account.rs index fe595f9b5..99875ca3e 100644 --- a/crates/primitives-traits/src/account.rs +++ b/crates/primitives-traits/src/account.rs @@ -35,16 +35,6 @@ impl Account { self.bytecode_hash.map_or(true, |hash| hash == KECCAK_EMPTY) } - /// Makes an [Account] from [`GenesisAccount`] type - pub fn from_genesis_account(value: &GenesisAccount) -> Self { - Self { - // nonce must exist, so we default to zero when converting a genesis account - nonce: value.nonce.unwrap_or_default(), - balance: value.balance, - bytecode_hash: value.code.as_ref().map(keccak256), - } - } - /// Returns an account bytecode's hash. /// In case of no bytecode, returns [`KECCAK_EMPTY`]. pub fn get_bytecode_hash(&self) -> B256 { @@ -129,6 +119,16 @@ impl Compact for Bytecode { } } +impl From<&GenesisAccount> for Account { + fn from(value: &GenesisAccount) -> Self { + Self { + nonce: value.nonce.unwrap_or_default(), + balance: value.balance, + bytecode_hash: value.code.as_ref().map(keccak256), + } + } +} + impl From for Account { fn from(revm_acc: AccountInfo) -> Self { let code_hash = revm_acc.code_hash; diff --git a/crates/storage/db-common/src/init.rs b/crates/storage/db-common/src/init.rs index 95324cb68..435aa6d38 100644 --- a/crates/storage/db-common/src/init.rs +++ b/crates/storage/db-common/src/init.rs @@ -225,8 +225,7 @@ pub fn insert_genesis_hashes<'a, 'b, DB: Database>( alloc: impl Iterator + Clone, ) -> ProviderResult<()> { // insert and hash accounts to hashing table - let alloc_accounts = - alloc.clone().map(|(addr, account)| (*addr, Some(Account::from_genesis_account(account)))); + let alloc_accounts = alloc.clone().map(|(addr, account)| (*addr, Some(Account::from(account)))); provider.insert_account_for_hashing(alloc_accounts)?; trace!(target: "reth::cli", "Inserted account hashes"); diff --git a/crates/storage/provider/src/test_utils/mod.rs b/crates/storage/provider/src/test_utils/mod.rs index edbbe4582..8e3146633 100644 --- a/crates/storage/provider/src/test_utils/mod.rs +++ b/crates/storage/provider/src/test_utils/mod.rs @@ -45,10 +45,8 @@ pub fn insert_genesis( // Hash accounts and insert them into hashing table. let genesis = chain_spec.genesis(); - let alloc_accounts = genesis - .alloc - .iter() - .map(|(addr, account)| (*addr, Some(Account::from_genesis_account(account)))); + let alloc_accounts = + genesis.alloc.iter().map(|(addr, account)| (*addr, Some(Account::from(account)))); provider.insert_account_for_hashing(alloc_accounts).unwrap(); let alloc_storage = genesis.alloc.clone().into_iter().filter_map(|(addr, account)| { diff --git a/crates/trie/db/tests/proof.rs b/crates/trie/db/tests/proof.rs index e41ac2739..41d599571 100644 --- a/crates/trie/db/tests/proof.rs +++ b/crates/trie/db/tests/proof.rs @@ -48,10 +48,8 @@ fn insert_genesis( // Hash accounts and insert them into hashing table. let genesis = chain_spec.genesis(); - let alloc_accounts = genesis - .alloc - .iter() - .map(|(addr, account)| (*addr, Some(Account::from_genesis_account(account)))); + let alloc_accounts = + genesis.alloc.iter().map(|(addr, account)| (*addr, Some(Account::from(account)))); provider.insert_account_for_hashing(alloc_accounts).unwrap(); let alloc_storage = genesis.alloc.clone().into_iter().filter_map(|(addr, account)| {