-
Notifications
You must be signed in to change notification settings - Fork 830
Open
Description
I try to insert a new account into the StateDB, like I would for the CacheDB, but I get an error All accounts should be present inside cache.
StateDB has insert_account(...) and CacheDB has insert_account_info(...), but I would like to use both just based on the traits Database + DatabaseCommit. For that reason I am using commit(...) for changing the state. If the error is an intended behavior feel free to close this issue.
Here the error:
revm/crates/database/src/states/cache.rs
Lines 115 to 118 in 3ea028b
| let this_account = self | |
| .accounts | |
| .get_mut(&address) | |
| .expect("All accounts should be present inside cache"); |
Here is a test that fails for me:
#[test]
fn test_state_db_commit_created_account() {
let address = Address::with_last_byte(42);
let db = CacheDB::new(EmptyDB::default());
let mut state = State::builder().with_database(db).build();
let account = Account {
info: AccountInfo::default(),
transaction_id: 0,
storage: Default::default(),
status: state::AccountStatus::Touched.union(state::AccountStatus::Created),
};
state.commit(HashMap::from_iter([(address, account)]));
assert!(state.basic(address).unwrap().is_some());
}For CacheDB it works:
#[test]
fn test_cache_db_commit_created_account() {
let address = Address::with_last_byte(42);
let mut db = CacheDB::new(EmptyDB::default());
let account = Account {
info: AccountInfo::default(),
transaction_id: 0,
storage: Default::default(),
status: state::AccountStatus::Touched.union(state::AccountStatus::Created),
};
db.commit(HashMap::from_iter([(address, account)]));
assert!(db.basic(address).unwrap().is_some());
}Metadata
Metadata
Assignees
Labels
No labels