Breaking changes (#5191)

Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
Co-authored-by: joshieDo <ranriver@protonmail.com>
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
Co-authored-by: Thomas Coratger <thomas.coratger@gmail.com>
This commit is contained in:
Alexey Shekhirin
2024-02-29 12:37:28 +00:00
committed by GitHub
parent 025fa5f038
commit 6b5b6f7a40
252 changed files with 10154 additions and 6327 deletions

View File

@ -27,7 +27,7 @@ tracing.workspace = true
# misc
thiserror.workspace = true
derive_more = "0.99"
derive_more.workspace = true
auto_impl = "1"
# test-utils

View File

@ -7,21 +7,21 @@ use reth_db::{
use reth_primitives::{Account, StorageEntry, B256};
impl<'a, TX: DbTx> HashedCursorFactory for &'a TX {
type AccountCursor = <TX as DbTx>::Cursor<tables::HashedAccount>;
type StorageCursor = <TX as DbTx>::DupCursor<tables::HashedStorage>;
type AccountCursor = <TX as DbTx>::Cursor<tables::HashedAccounts>;
type StorageCursor = <TX as DbTx>::DupCursor<tables::HashedStorages>;
fn hashed_account_cursor(&self) -> Result<Self::AccountCursor, reth_db::DatabaseError> {
self.cursor_read::<tables::HashedAccount>()
self.cursor_read::<tables::HashedAccounts>()
}
fn hashed_storage_cursor(&self) -> Result<Self::StorageCursor, reth_db::DatabaseError> {
self.cursor_dup_read::<tables::HashedStorage>()
self.cursor_dup_read::<tables::HashedStorages>()
}
}
impl<C> HashedAccountCursor for C
where
C: DbCursorRO<tables::HashedAccount>,
C: DbCursorRO<tables::HashedAccounts>,
{
fn seek(&mut self, key: B256) -> Result<Option<(B256, Account)>, reth_db::DatabaseError> {
self.seek(key)
@ -34,7 +34,7 @@ where
impl<C> HashedStorageCursor for C
where
C: DbCursorRO<tables::HashedStorage> + DbDupCursorRO<tables::HashedStorage>,
C: DbCursorRO<tables::HashedStorages> + DbDupCursorRO<tables::HashedStorages>,
{
fn is_storage_empty(&mut self, key: B256) -> Result<bool, reth_db::DatabaseError> {
Ok(self.seek_exact(key)?.is_none())

View File

@ -440,7 +440,7 @@ mod tests {
let db = create_test_rw_db();
db.update(|tx| {
for (key, account) in accounts.iter() {
tx.put::<tables::HashedAccount>(*key, *account).unwrap();
tx.put::<tables::HashedAccounts>(*key, *account).unwrap();
}
})
.unwrap();
@ -460,7 +460,7 @@ mod tests {
let db = create_test_rw_db();
db.update(|tx| {
for (key, account) in accounts.iter().filter(|x| x.0[31] % 2 == 0) {
tx.put::<tables::HashedAccount>(*key, *account).unwrap();
tx.put::<tables::HashedAccounts>(*key, *account).unwrap();
}
})
.unwrap();
@ -487,7 +487,7 @@ mod tests {
let db = create_test_rw_db();
db.update(|tx| {
for (key, account) in accounts.iter().filter(|x| x.0[31] % 2 == 0) {
tx.put::<tables::HashedAccount>(*key, *account).unwrap();
tx.put::<tables::HashedAccounts>(*key, *account).unwrap();
}
})
.unwrap();
@ -517,7 +517,7 @@ mod tests {
db.update(|tx| {
for (key, _) in accounts.iter() {
// insert zero value accounts to the database
tx.put::<tables::HashedAccount>(*key, Account::default()).unwrap();
tx.put::<tables::HashedAccounts>(*key, Account::default()).unwrap();
}
})
.unwrap();
@ -539,7 +539,7 @@ mod tests {
let db = create_test_rw_db();
db.update(|tx| {
for (key, account) in db_accounts.iter() {
tx.put::<tables::HashedAccount>(*key, *account).unwrap();
tx.put::<tables::HashedAccounts>(*key, *account).unwrap();
}
})
.unwrap();
@ -586,7 +586,7 @@ mod tests {
db.update(|tx| {
for (slot, value) in db_storage.iter() {
// insert zero value accounts to the database
tx.put::<tables::HashedStorage>(
tx.put::<tables::HashedStorages>(
address,
StorageEntry { key: *slot, value: *value },
)
@ -664,7 +664,7 @@ mod tests {
db.update(|tx| {
for (slot, value) in db_storage.iter() {
// insert zero value accounts to the database
tx.put::<tables::HashedStorage>(
tx.put::<tables::HashedStorages>(
address,
StorageEntry { key: *slot, value: *value },
)
@ -703,7 +703,7 @@ mod tests {
db.update(|tx| {
for (slot, value) in db_storage {
// insert zero value accounts to the database
tx.put::<tables::HashedStorage>(address, StorageEntry { key: slot, value })
tx.put::<tables::HashedStorages>(address, StorageEntry { key: slot, value })
.unwrap();
}
})
@ -741,7 +741,7 @@ mod tests {
db.update(|tx| {
for (slot, value) in db_storage {
// insert zero value accounts to the database
tx.put::<tables::HashedStorage>(address, StorageEntry { key: slot, value })
tx.put::<tables::HashedStorages>(address, StorageEntry { key: slot, value })
.unwrap();
}
})
@ -773,7 +773,7 @@ mod tests {
db.update(|tx| {
for (slot, _) in storage.iter() {
// insert zero value accounts to the database
tx.put::<tables::HashedStorage>(
tx.put::<tables::HashedStorages>(
address,
StorageEntry { key: *slot, value: U256::ZERO },
)
@ -811,7 +811,7 @@ mod tests {
for (address, storage) in db_storages.iter() {
for (slot, value) in storage {
let entry = StorageEntry { key: *slot, value: *value };
tx.put::<tables::HashedStorage>(*address, entry).unwrap();
tx.put::<tables::HashedStorages>(*address, entry).unwrap();
}
}
})

View File

@ -33,7 +33,7 @@ impl<'a, TX: DbTx> PrefixSetLoader<'a, TX> {
let mut destroyed_accounts = HashSet::default();
// Walk account changeset and insert account prefixes.
let mut account_changeset_cursor = self.cursor_read::<tables::AccountChangeSet>()?;
let mut account_changeset_cursor = self.cursor_read::<tables::AccountChangeSets>()?;
let mut account_plain_state_cursor = self.cursor_read::<tables::PlainAccountState>()?;
for account_entry in account_changeset_cursor.walk_range(range.clone())? {
let (_, AccountBeforeTx { address, .. }) = account_entry?;
@ -47,7 +47,7 @@ impl<'a, TX: DbTx> PrefixSetLoader<'a, TX> {
// Walk storage changeset and insert storage prefixes as well as account prefixes if missing
// from the account prefix set.
let mut storage_cursor = self.cursor_dup_read::<tables::StorageChangeSet>()?;
let mut storage_cursor = self.cursor_dup_read::<tables::StorageChangeSets>()?;
let storage_range = BlockNumberAddress::range(range);
for storage_entry in storage_cursor.walk_range(storage_range)? {
let (BlockNumberAddress((_, address)), StorageEntry { key, .. }) = storage_entry?;

View File

@ -65,7 +65,7 @@ impl HashedPostState {
) -> Result<Self, DatabaseError> {
// Iterate over account changesets and record value before first occurring account change.
let mut accounts = HashMap::<Address, Option<Account>>::default();
let mut account_changesets_cursor = tx.cursor_read::<tables::AccountChangeSet>()?;
let mut account_changesets_cursor = tx.cursor_read::<tables::AccountChangeSets>()?;
for entry in account_changesets_cursor.walk_range(range.clone())? {
let (_, AccountBeforeTx { address, info }) = entry?;
if let hash_map::Entry::Vacant(entry) = accounts.entry(address) {
@ -75,7 +75,7 @@ impl HashedPostState {
// Iterate over storage changesets and record value before first occurring storage change.
let mut storages = HashMap::<Address, HashMap<B256, U256>>::default();
let mut storage_changesets_cursor = tx.cursor_read::<tables::StorageChangeSet>()?;
let mut storage_changesets_cursor = tx.cursor_read::<tables::StorageChangeSets>()?;
for entry in storage_changesets_cursor.walk_range(BlockNumberAddress::range(range))? {
let (BlockNumberAddress((_, address)), storage) = entry?;
let account_storage = storages.entry(address).or_default();

View File

@ -498,13 +498,13 @@ mod tests {
storage: &BTreeMap<B256, U256>,
) {
let hashed_address = keccak256(address);
tx.put::<tables::HashedAccount>(hashed_address, account).unwrap();
tx.put::<tables::HashedAccounts>(hashed_address, account).unwrap();
insert_storage(tx, hashed_address, storage);
}
fn insert_storage(tx: &impl DbTxMut, hashed_address: B256, storage: &BTreeMap<B256, U256>) {
for (k, v) in storage {
tx.put::<tables::HashedStorage>(
tx.put::<tables::HashedStorages>(
hashed_address,
StorageEntry { key: keccak256(k), value: *v },
)
@ -518,7 +518,7 @@ mod tests {
let hashed_address = B256::with_last_byte(1);
let mut hashed_storage_cursor =
tx.tx_ref().cursor_dup_write::<tables::HashedStorage>().unwrap();
tx.tx_ref().cursor_dup_write::<tables::HashedStorages>().unwrap();
let data = inputs.iter().map(|x| B256::from_str(x).unwrap());
let value = U256::from(0);
for key in data {
@ -581,7 +581,7 @@ mod tests {
let factory = create_test_provider_factory();
let tx = factory.provider_rw().unwrap();
for (key, value) in &storage {
tx.tx_ref().put::<tables::HashedStorage>(
tx.tx_ref().put::<tables::HashedStorages>(
hashed_address,
StorageEntry { key: keccak256(key), value: *value },
)
@ -777,7 +777,7 @@ mod tests {
);
let mut hashed_storage_cursor =
tx.tx_ref().cursor_dup_write::<tables::HashedStorage>().unwrap();
tx.tx_ref().cursor_dup_write::<tables::HashedStorages>().unwrap();
for (hashed_slot, value) in storage.clone() {
hashed_storage_cursor.upsert(key3, StorageEntry { key: hashed_slot, value }).unwrap();
}
@ -806,9 +806,9 @@ mod tests {
let tx = factory.provider_rw().unwrap();
let mut hashed_account_cursor =
tx.tx_ref().cursor_write::<tables::HashedAccount>().unwrap();
tx.tx_ref().cursor_write::<tables::HashedAccounts>().unwrap();
let mut hashed_storage_cursor =
tx.tx_ref().cursor_dup_write::<tables::HashedStorage>().unwrap();
tx.tx_ref().cursor_dup_write::<tables::HashedStorages>().unwrap();
let mut hash_builder = HashBuilder::default();
@ -1002,7 +1002,7 @@ mod tests {
{
let mut hashed_account_cursor =
tx.tx_ref().cursor_write::<tables::HashedAccount>().unwrap();
tx.tx_ref().cursor_write::<tables::HashedAccounts>().unwrap();
let account = hashed_account_cursor.seek_exact(key2).unwrap().unwrap();
hashed_account_cursor.delete_current().unwrap();
@ -1059,7 +1059,7 @@ mod tests {
let tx = factory.provider_rw().unwrap();
{
let mut hashed_account_cursor =
tx.tx_ref().cursor_write::<tables::HashedAccount>().unwrap();
tx.tx_ref().cursor_write::<tables::HashedAccounts>().unwrap();
let account2 = hashed_account_cursor.seek_exact(key2).unwrap().unwrap();
hashed_account_cursor.delete_current().unwrap();
@ -1172,7 +1172,7 @@ mod tests {
tokio::runtime::Runtime::new().unwrap().block_on(async {
let factory = create_test_provider_factory();
let tx = factory.provider_rw().unwrap();
let mut hashed_account_cursor = tx.tx_ref().cursor_write::<tables::HashedAccount>().unwrap();
let mut hashed_account_cursor = tx.tx_ref().cursor_write::<tables::HashedAccounts>().unwrap();
let mut state = BTreeMap::default();
for accounts in account_changes {
@ -1234,7 +1234,7 @@ mod tests {
) -> (B256, HashMap<Nibbles, BranchNodeCompact>) {
let value = U256::from(1);
let mut hashed_storage = tx.tx_ref().cursor_write::<tables::HashedStorage>().unwrap();
let mut hashed_storage = tx.tx_ref().cursor_write::<tables::HashedStorages>().unwrap();
let mut hb = HashBuilder::default().with_updates(true);
@ -1262,7 +1262,7 @@ mod tests {
Account { nonce: 0, balance: U256::from(1u64), bytecode_hash: Some(B256::random()) };
let val = encode_account(a, None);
let mut hashed_accounts = tx.tx_ref().cursor_write::<tables::HashedAccount>().unwrap();
let mut hashed_accounts = tx.tx_ref().cursor_write::<tables::HashedAccounts>().unwrap();
let mut hb = HashBuilder::default();
for key in [