Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Dec 19, 2023
1 parent bc42b8e commit 103249e
Show file tree
Hide file tree
Showing 45 changed files with 1,868 additions and 493 deletions.
55 changes: 23 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/katana/storage/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
katana-primitives = { path = "../../primitives" }

anyhow.workspace = true
bincode = "1.3.3"
page_size = "0.6.0"
parking_lot.workspace = true
serde.workspace = true
Expand All @@ -23,7 +22,11 @@ cairo-vm.workspace = true
starknet_api.workspace = true

# codecs
postcard = { version = "1.0.8", optional = true, default-features = false, features = [ "use-std" ] }
[dependencies.postcard]
default-features = false
features = [ "use-std" ]
optional = true
version = "1.0.8"

[dependencies.libmdbx]
git = "https://github.com/paradigmxyz/reth.git"
Expand Down
2 changes: 1 addition & 1 deletion crates/katana/storage/db/benches/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use blockifier::execution::contract_class::ContractClassV1;
use cairo_lang_starknet::casm_contract_class::CasmContractClass;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use katana_db::codecs::{Compress, Decompress};
use katana_db::models::contract::StoredContractClass;
use katana_db::models::class::StoredContractClass;
use katana_primitives::contract::CompiledContractClass;

fn compress_contract(contract: CompiledContractClass) -> Vec<u8> {
Expand Down
9 changes: 6 additions & 3 deletions crates/katana/storage/db/src/codecs/postcard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use katana_primitives::block::Header;
use katana_primitives::block::{BlockNumber, Header};
use katana_primitives::contract::{ContractAddress, GenericContractInfo, SierraClass};
use katana_primitives::receipt::Receipt;
use katana_primitives::transaction::Tx;
Expand All @@ -7,7 +7,8 @@ use katana_primitives::FieldElement;
use super::{Compress, Decompress};
use crate::error::CodecError;
use crate::models::block::StoredBlockBodyIndices;
use crate::models::contract::StoredContractClass;
use crate::models::class::StoredContractClass;
use crate::models::contract::ContractInfoChangeList;

macro_rules! impl_compress_and_decompress_for_table_values {
($($name:ty),*) => {
Expand Down Expand Up @@ -36,7 +37,9 @@ impl_compress_and_decompress_for_table_values!(
SierraClass,
FieldElement,
ContractAddress,
Vec<BlockNumber>,
StoredContractClass,
GenericContractInfo,
StoredBlockBodyIndices
StoredBlockBodyIndices,
ContractInfoChangeList
);
7 changes: 3 additions & 4 deletions crates/katana/storage/db/src/mdbx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,17 @@ impl DbEnv {
#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils {
use std::path::Path;
use std::sync::Arc;

use super::{DbEnv, DbEnvKind};

const ERROR_DB_CREATION: &str = "Not able to create the mdbx file.";

/// Create database for testing
pub fn create_test_db(kind: DbEnvKind) -> Arc<DbEnv> {
Arc::new(create_test_db_with_path(
pub fn create_test_db(kind: DbEnvKind) -> DbEnv {
create_test_db_with_path(
kind,
&tempfile::TempDir::new().expect("Failed to create temp dir.").into_path(),
))
)
}

/// Create database for testing with specified path
Expand Down
Loading

0 comments on commit 103249e

Please sign in to comment.