Extricate PodAccount and state Account to own crates (#10838)

* WIP move errors, pod_account and state account to own crates

* Sort out dependencies, fix broken code and tests
Remove botched ethcore-error crate

* remove template line

* fix review feedback

* Remove test-only AccountDBMut::new
This commit is contained in:
David 2019-07-04 15:20:44 +02:00 committed by Andronik Ordian
parent bbae075c60
commit 9f96fa0a73
11 changed files with 172 additions and 68 deletions

57
Cargo.lock generated
View File

@ -914,6 +914,7 @@ dependencies = [
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"pod-account 0.1.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -924,6 +925,7 @@ dependencies = [
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
"state-account 0.1.0",
"stats 0.1.0",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"time-utils 0.1.0",
@ -1916,6 +1918,14 @@ dependencies = [
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools-num"
version = "0.1.3"
@ -3219,6 +3229,29 @@ dependencies = [
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pod-account"
version = "0.1.0"
dependencies = [
"common-types 0.1.0",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"macros 0.1.0",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash-ethereum 0.2.0",
]
[[package]]
name = "pretty_assertions"
version = "0.1.2"
@ -3898,6 +3931,29 @@ name = "stable_deref_trait"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "state-account"
version = "0.1.0"
dependencies = [
"common-types 0.1.0",
"ethcore 1.12.0",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"pod-account 0.1.0",
"rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_compress 0.1.0",
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "static_assertions"
version = "0.2.5"
@ -4870,6 +4926,7 @@ dependencies = [
"checksum ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)" = "70783119ac90828aaba91eae39db32c6c1b8838deea3637e5238efa0130801ab"
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
"checksum itertools-num 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a872a22f9e6f7521ca557660adb96dd830e54f0f490fa115bb55dd69d38b27e7"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"

View File

@ -139,5 +139,5 @@ members = [
"util/keccak-hasher",
"util/patricia-trie-ethereum",
"util/fastmap",
"util/time-utils"
"util/time-utils",
]

View File

@ -52,6 +52,7 @@ parity-bytes = "0.1"
parity-crypto = "0.4.0"
parity-snappy = "0.1"
parking_lot = "0.7"
pod-account = { path = "pod-account" }
trie-db = "0.12.4"
patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" }
rand = "0.6"
@ -61,6 +62,7 @@ rlp_derive = { path = "../util/rlp-derive" }
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
state-account = { path = "state-account" }
stats = { path = "../util/stats" }
tempdir = { version = "0.3", optional = true }
time-utils = { path = "../util/time-utils" }

View File

@ -0,0 +1,27 @@
[package]
description = "Account system expressed in Plain Old Data."
name = "pod-account"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
common-types = { path = "../types" }
ethereum-types = "0.6"
ethjson = { path = "../../json" }
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
hash-db = "0.12"
itertools = "0.8"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1"
log = "0.4"
parity-bytes = "0.1.0"
rlp = "0.4"
rustc-hex = "1"
serde = { version = "1.0", features = ["derive"] }
trie-db = "0.12.4"
triehash = { package = "triehash-ethereum", version = "0.2", path = "../../util/triehash-ethereum" }
[dev-dependencies]
macros = { path = "../../util/macros" }

View File

@ -15,23 +15,22 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Account system expressed in Plain Old Data.
use log::warn;
use std::collections::BTreeMap;
use itertools::Itertools;
use hash::{keccak};
use keccak_hash::keccak;
use ethereum_types::{H256, U256, BigEndianHash};
use hash_db::HashDB;
use kvdb::DBValue;
use keccak_hasher::KeccakHasher;
use triehash::sec_trie_root;
use bytes::Bytes;
use trie::TrieFactory;
use parity_bytes::Bytes;
use trie_db::TrieFactory;
use ethtrie::RlpCodec;
use state::Account;
use ethjson;
use types::account_diff::*;
use common_types::account_diff::*;
use rlp::{self, RlpStream};
use serde::Serializer;
use serde::{Serializer, Serialize};
use rustc_hex::ToHex;
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
@ -57,17 +56,6 @@ fn opt_bytes_to_hex<S>(opt_bytes: &Option<Bytes>, serializer: S) -> Result<S::Ok
}
impl PodAccount {
/// Convert Account to a PodAccount.
/// NOTE: This will silently fail unless the account is fully cached.
pub fn from_account(acc: &Account) -> PodAccount {
PodAccount {
balance: *acc.balance(),
nonce: *acc.nonce(),
storage: acc.storage_changes().iter().fold(BTreeMap::new(), |mut m, (k, v)| {m.insert(k.clone(), v.clone()); m}),
code: acc.code().map(|x| x.to_vec()),
}
}
/// Returns the RLP for this account.
pub fn rlp(&self) -> Bytes {
let mut stream = RlpStream::new_list(4);
@ -170,9 +158,10 @@ pub fn diff_pod(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option<A
#[cfg(test)]
mod test {
use std::collections::BTreeMap;
use types::account_diff::*;
use common_types::account_diff::*;
use super::{PodAccount, diff_pod};
use ethereum_types::H256;
use macros::map;
#[test]
fn existence() {

View File

@ -137,21 +137,12 @@ pub struct AccountDBMut<'db> {
}
impl<'db> AccountDBMut<'db> {
/// Create a new AccountDB from an address.
#[cfg(test)]
pub fn new(db: &'db mut dyn HashDB<KeccakHasher, DBValue>, address: &Address) -> Self {
Self::from_hash(db, keccak(address))
}
/// Create a new AcountDB from an address' hash.
/// Create a new `AccountDBMut` from an address' hash.
pub fn from_hash(db: &'db mut dyn HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Self {
AccountDBMut {
db: db,
address_hash: address_hash,
}
AccountDBMut { db, address_hash }
}
#[cfg(test)]
/// Create an `AccountDB` from an `AccountDBMut` (used in tests).
pub fn immutable(&'db self) -> AccountDB<'db> {
AccountDB { db: self.db, address_hash: self.address_hash.clone() }
}

View File

@ -88,6 +88,7 @@ extern crate parity_bytes as bytes;
extern crate parity_crypto;
extern crate parity_snappy as snappy;
extern crate parking_lot;
extern crate pod_account;
extern crate trie_db as trie;
extern crate patricia_trie_ethereum as ethtrie;
extern crate rand;
@ -98,6 +99,7 @@ extern crate parity_util_mem as malloc_size_of;
extern crate rustc_hex;
extern crate serde;
extern crate stats;
extern crate state_account;
extern crate time_utils;
extern crate triehash_ethereum as triehash;
extern crate unexpected;
@ -120,8 +122,6 @@ extern crate blooms_db;
#[cfg(any(test, feature = "env_logger"))]
extern crate env_logger;
#[cfg(test)]
extern crate rlp_compress;
#[cfg(test)]
extern crate serde_json;
#[macro_use]
@ -162,7 +162,6 @@ pub mod executive;
pub mod machine;
pub mod miner;
pub mod pod_state;
pub mod pod_account;
pub mod snapshot;
pub mod spec;
pub mod state;
@ -170,8 +169,8 @@ pub mod state_db;
pub mod trace;
pub mod transaction_ext;
pub mod verification;
pub mod account_db;
mod account_db;
mod externalities;
mod factory;
mod tx_filter;

View File

@ -253,7 +253,7 @@ mod tests {
let p = Progress::default();
let fat_rlps = to_fat_rlps(&keccak(&addr), &account, &AccountDB::new(db.as_hash_db(), &addr), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap();
let fat_rlp = Rlp::new(&fat_rlps[0]).at(1).unwrap();
assert_eq!(from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &addr), fat_rlp, H256::zero()).unwrap().0, account);
assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account);
}
#[test]
@ -262,7 +262,7 @@ mod tests {
let addr = Address::random();
let account = {
let acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr);
let acct_db = AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr));
let mut root = KECCAK_NULL_RLP;
fill_storage(acct_db, &mut root, &mut H256::zero());
BasicAccount {
@ -280,7 +280,7 @@ mod tests {
let fat_rlp = to_fat_rlps(&keccak(&addr), &account, &AccountDB::new(db.as_hash_db(), &addr), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap();
let fat_rlp = Rlp::new(&fat_rlp[0]).at(1).unwrap();
assert_eq!(from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &addr), fat_rlp, H256::zero()).unwrap().0, account);
assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account);
}
#[test]
@ -289,7 +289,7 @@ mod tests {
let addr = Address::random();
let account = {
let acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr);
let acct_db = AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr));
let mut root = KECCAK_NULL_RLP;
fill_storage(acct_db, &mut root, &mut H256::zero());
BasicAccount {
@ -309,7 +309,7 @@ mod tests {
let mut restored_account = None;
for rlp in fat_rlps {
let fat_rlp = Rlp::new(&rlp).at(1).unwrap();
restored_account = Some(from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &addr), fat_rlp, root).unwrap().0);
restored_account = Some(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, root).unwrap().0);
root = restored_account.as_ref().unwrap().storage_root.clone();
}
assert_eq!(restored_account, Some(account));
@ -323,12 +323,12 @@ mod tests {
let addr2 = Address::random();
let code_hash = {
let mut acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr1);
let mut acct_db = AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr1));
acct_db.insert(EMPTY_PREFIX, b"this is definitely code")
};
{
let mut acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr2);
let mut acct_db = AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr2));
acct_db.emplace(code_hash.clone(), EMPTY_PREFIX, DBValue::from_slice(b"this is definitely code"));
}
@ -356,11 +356,11 @@ mod tests {
let fat_rlp1 = Rlp::new(&fat_rlp1[0]).at(1).unwrap();
let fat_rlp2 = Rlp::new(&fat_rlp2[0]).at(1).unwrap();
let (acc, maybe_code) = from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &addr2), fat_rlp2, H256::zero()).unwrap();
let (acc, maybe_code) = from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr2)), fat_rlp2, H256::zero()).unwrap();
assert!(maybe_code.is_none());
assert_eq!(acc, account2);
let (acc, maybe_code) = from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &addr1), fat_rlp1, H256::zero()).unwrap();
let (acc, maybe_code) = from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr1)), fat_rlp1, H256::zero()).unwrap();
assert_eq!(maybe_code, Some(b"this is definitely code".to_vec()));
assert_eq!(acc, account1);
}
@ -368,6 +368,6 @@ mod tests {
#[test]
fn encoding_empty_acc() {
let mut db = get_temp_state_db();
assert_eq!(from_fat_rlp(&mut AccountDBMut::new(db.as_hash_db_mut(), &Address::zero()), Rlp::new(&::rlp::NULL_RLP), H256::zero()).unwrap(), (ACC_EMPTY, None));
assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(Address::zero())), Rlp::new(&::rlp::NULL_RLP), H256::zero()).unwrap(), (ACC_EMPTY, None));
}
}

View File

@ -51,12 +51,11 @@ use bytes::Bytes;
use trie::{Trie, TrieError, Recorder};
use ethtrie::{TrieDB, Result as TrieResult};
mod account;
mod substate;
pub mod backend;
pub use self::account::Account;
pub use state_account::Account;
pub use self::backend::Backend;
pub use self::substate::Substate;
@ -964,7 +963,7 @@ impl<B: Backend> State<B> {
assert!(self.checkpoints.borrow().is_empty());
PodState::from(self.cache.borrow().iter().fold(BTreeMap::new(), |mut m, (add, opt)| {
if let Some(ref acc) = opt.account {
m.insert(*add, PodAccount::from_account(acc));
m.insert(*add, acc.to_pod());
}
m
}))
@ -1031,7 +1030,7 @@ impl<B: Backend> State<B> {
}
}
let mut pod_account = PodAccount::from_account(&account);
let mut pod_account = account.to_pod();
// cached one first
pod_storage.append(&mut pod_account.storage);
pod_account.storage = pod_storage;

View File

@ -0,0 +1,28 @@
[package]
description = "Ethereum accounts, keeps track of changes to the code and storage."
name = "state-account"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
common-types = { path = "../types"}
ethereum-types = "0.6.0"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
hash-db = "0.12.4"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1.0"
log = "0.4"
lru-cache = "0.1.2"
parity-bytes = "0.1.0"
pod-account = { path = "../pod-account" }
rlp = "0.4.0"
serde = { version = "1.0", features = ["derive"] }
trie-db = "0.12.4"
[dev-dependencies]
ethcore = { path = ".." }
rlp_compress = { path = "../../util/rlp-compress" }
journaldb = { path = "../../util/journaldb" }
parity-bytes = "0.1.0"

View File

@ -15,23 +15,22 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Single account in the system.
use log::{warn, trace};
use std::fmt;
use std::sync::Arc;
use std::collections::{HashMap, BTreeMap};
use hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak};
use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak};
use ethereum_types::{H256, U256, Address, BigEndianHash};
use error::Error;
use hash_db::HashDB;
use keccak_hasher::KeccakHasher;
use kvdb::DBValue;
use bytes::{Bytes, ToPretty};
use trie::{Trie, Recorder};
use parity_bytes::{Bytes, ToPretty};
use trie_db::{Trie, Recorder};
use ethtrie::{TrieFactory, TrieDB, SecTrieDB, Result as TrieResult};
use pod_account::*;
use rlp::{RlpStream, encode};
use pod_account::PodAccount;
use rlp::{RlpStream, DecoderError, encode};
use lru_cache::LruCache;
use types::basic_account::BasicAccount;
use common_types::basic_account::BasicAccount;
use std::cell::{RefCell, Cell};
@ -136,6 +135,20 @@ impl Account {
}
}
/// Convert Account to a PodAccount.
/// NOTE: This will silently fail unless the account is fully cached.
pub fn to_pod(&self) -> PodAccount {
PodAccount {
balance: self.balance,
nonce: self.nonce,
storage: self.storage_changes.iter().fold(BTreeMap::new(), |mut m, (k, v)| {
m.insert(k.clone(), v.clone());
m
}),
code: self.code().map(|x| x.to_vec()),
}
}
/// Create a new account with the given balance.
pub fn new_basic(balance: U256, nonce: U256) -> Account {
Account {
@ -154,10 +167,9 @@ impl Account {
}
/// Create a new account from RLP.
pub fn from_rlp(rlp: &[u8]) -> Result<Account, Error> {
pub fn from_rlp(rlp: &[u8]) -> Result<Account, DecoderError> {
::rlp::decode::<BasicAccount>(rlp)
.map(|ba| ba.into())
.map_err(|e| e.into())
}
/// Create a new contract account.
@ -618,9 +630,9 @@ mod tests {
use rlp_compress::{compress, decompress, snapshot_swapper};
use ethereum_types::{H256, Address};
use journaldb::new_memory_db;
use bytes::Bytes;
use parity_bytes::Bytes;
use super::*;
use account_db::*;
use ethcore::account_db::*;
use std::str::FromStr;
#[test]
@ -635,7 +647,7 @@ mod tests {
#[test]
fn storage_at() {
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
let rlp = {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
a.set_storage(H256::zero(), H256::from_low_u64_be(0x1234));
@ -654,7 +666,7 @@ mod tests {
#[test]
fn note_code() {
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
let rlp = {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
@ -674,7 +686,7 @@ mod tests {
fn commit_storage() {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
a.set_storage(H256::from_low_u64_be(0), H256::from_low_u64_be(0x1234));
assert_eq!(a.storage_root(), None);
a.commit_storage(&Default::default(), &mut db).unwrap();
@ -685,7 +697,7 @@ mod tests {
fn commit_remove_commit_storage() {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
a.set_storage(H256::from_low_u64_be(0), H256::from_low_u64_be(0x1234));
a.commit_storage(&Default::default(), &mut db).unwrap();
a.set_storage(H256::from_low_u64_be(1), H256::from_low_u64_be(0x1234));
@ -699,7 +711,7 @@ mod tests {
fn commit_code() {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
a.init_code(vec![0x55, 0x44, 0xffu8]);
assert_eq!(a.code_filth, Filth::Dirty);
assert_eq!(a.code_size(), Some(3));
@ -711,7 +723,7 @@ mod tests {
fn reset_code() {
let mut a = Account::new_contract(69.into(), 0.into(), KECCAK_NULL_RLP);
let mut db = new_memory_db();
let mut db = AccountDBMut::new(&mut db, &Address::zero());
let mut db = AccountDBMut::from_hash(&mut db, keccak(&Address::zero()));
a.init_code(vec![0x55, 0x44, 0xffu8]);
assert_eq!(a.code_filth, Filth::Dirty);
a.commit_code(&mut db);