Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(katana): skip legacy class when fetching compiled class hash #2998

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions crates/katana/storage/provider/src/providers/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
fn dup_entries<Db, Tb, V, T>(
db_tx: &<Db as Database>::Tx,
key: <Tb as Table>::Key,
f: impl FnMut(Result<KeyValue<Tb>, DatabaseError>) -> ProviderResult<T>,
mut f: impl FnMut(Result<KeyValue<Tb>, DatabaseError>) -> ProviderResult<Option<T>>,
) -> ProviderResult<V>
where
Db: Database,
Expand All @@ -270,7 +270,7 @@
Ok(db_tx
.cursor_dup::<Tb>()?
.walk_dup(Some(key), None)?
.map(|walker| walker.map(f).collect::<ProviderResult<V>>())
.map(|walker| walker.filter_map(|i| f(i).transpose()).collect::<ProviderResult<V>>())
.transpose()?
.unwrap_or_default())
}
Expand All @@ -288,7 +288,7 @@
_,
>(&db_tx, block_num, |entry| {
let (_, ContractNonceChange { contract_address, nonce }) = entry?;
Ok((contract_address, nonce))
Ok(Some((contract_address, nonce)))
})?;

let deployed_contracts = dup_entries::<
Expand All @@ -298,7 +298,7 @@
_,
>(&db_tx, block_num, |entry| {
let (_, ContractClassChange { contract_address, class_hash }) = entry?;
Ok((contract_address, class_hash))
Ok(Some((contract_address, class_hash)))
})?;

let mut declared_classes = BTreeMap::new();
Expand Down Expand Up @@ -328,7 +328,7 @@
_,
>(&db_tx, block_num, |entry| {
let (_, ContractStorageEntry { key, value }) = entry?;
Ok((key.contract_address, (key.key, value)))
Ok(Some((key.contract_address, (key.key, value))))
})?;

let mut map: BTreeMap<_, BTreeMap<StorageKey, StorageValue>> = BTreeMap::new();
Expand Down Expand Up @@ -371,11 +371,11 @@
>(&db_tx, block_num, |entry| {
let (_, class_hash) = entry?;

let compiled_hash = db_tx
.get::<tables::CompiledClassHashes>(class_hash)?
.ok_or(ProviderError::MissingCompiledClassHash(class_hash))?;

Ok((class_hash, compiled_hash))
if let Some(compiled_hash) = db_tx.get::<tables::CompiledClassHashes>(class_hash)? {
Ok(Some((class_hash, compiled_hash)))

Check warning on line 375 in crates/katana/storage/provider/src/providers/db/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/storage/provider/src/providers/db/mod.rs#L374-L375

Added lines #L374 - L375 were not covered by tests
} else {
Ok(None)

Check warning on line 377 in crates/katana/storage/provider/src/providers/db/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/storage/provider/src/providers/db/mod.rs#L377

Added line #L377 was not covered by tests
}
})?;

db_tx.commit()?;
Expand All @@ -400,7 +400,7 @@
_,
>(&db_tx, block_num, |entry| {
let (_, ContractClassChange { contract_address, class_hash }) = entry?;
Ok((contract_address, class_hash))
Ok(Some((contract_address, class_hash)))

Check warning on line 403 in crates/katana/storage/provider/src/providers/db/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/storage/provider/src/providers/db/mod.rs#L403

Added line #L403 was not covered by tests
})?;

db_tx.commit()?;
Expand Down
Loading