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

feat(storage): ✨ BonsaiStorage logs are no longer stored in db #82

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ git # Deoxys Changelog

## Next release

- feat(storage): removed the use of `BonsaiStorage` logs
- feat(storage): removed dependance on `StateUpdateWrapper`
- feat(storage): state diff are now stored for each block
- CI: fix toolchain
Expand Down
13 changes: 13 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ url = "2.4.1"
rayon = "1.10.0"
arc-swap = "1.7.1"
crossbeam-skiplist = "0.1"
crossbeam-queue = "0.3"
bincode = "1.3.3"

[patch."https://github.com/w3f/ring-vrf"]
bandersnatch_vrfs = { git = "https://github.com/w3f/ring-vrf?rev=3ddc20", version = "0.0.4", rev = "3ddc20" }
4 changes: 4 additions & 0 deletions crates/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ starknet_api = { workspace = true, default-features = true }
anyhow.workspace = true
arc-swap = { workspace = true }
async-trait = { workspace = true }
bincode = { workspace = true }
bitvec = { workspace = true }
crossbeam-queue = { workspace = true }
crossbeam-skiplist = { workspace = true }
ethers = { workspace = true }
itertools = { workspace = true }
log = { workspace = true, default-features = true }
rayon = { workspace = true }
rocksdb = { version = "0.21", features = [
# "multi-threaded-cf",
] }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
Expand Down
9 changes: 8 additions & 1 deletion crates/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub enum Column {
ContractClassData,
ContractData,
ContractClassHashes,
ContractStorage,

/// This column is used to map starknet block hashes to a list of transaction hashes that are
/// contained in the block.
Expand Down Expand Up @@ -167,6 +168,7 @@ impl Column {
BlockStateDiff,
ContractClassData,
ContractData,
ContractStorage,
ContractClassHashes,
BonsaiContractsTrie,
BonsaiContractsFlat,
Expand Down Expand Up @@ -206,6 +208,7 @@ impl Column {
Column::ContractClassData => "contract_class_data",
Column::ContractData => "contract_data",
Column::ContractClassHashes => "contract_class_hashes",
Column::ContractStorage => "contrac_storage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"contract"

}
}

Expand Down Expand Up @@ -320,7 +323,11 @@ impl DeoxysBackend {
fn new(config: &DatabaseSettings, cache_more_things: bool) -> Result<Self> {
DB_SINGLETON.set(Arc::new(open_database(config)?)).unwrap();
let db = DB_SINGLETON.get().unwrap();
let bonsai_config = BonsaiStorageConfig::from(config);
let bonsai_config = BonsaiStorageConfig {
max_saved_trie_logs: Some(0),
max_saved_snapshots: Some(0),
snapshot_interval: u64::MAX,
};

let mut bonsai_contract = BonsaiStorage::new(
BonsaiDb::new(
Expand Down
3 changes: 2 additions & 1 deletion crates/client/db/src/storage_handler/contract_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ impl StorageViewMut for ContractDataViewMut {
}
}

#[async_trait()]
impl StorageViewRevetible for ContractDataViewMut {
fn revert_to(&self, block_number: u64) -> Result<(), DeoxysStorageError> {
async fn revert_to(&self, block_number: u64) -> Result<(), DeoxysStorageError> {
let db = DeoxysBackend::expose_db();
let column = db.get_column(Column::ContractData);

Expand Down
Loading
Loading