Skip to content

Commit

Permalink
Feat/sync (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron authored May 31, 2024
1 parent c6e33e5 commit a914cd4
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 498 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next release

- refactor: l2-sync
- refactor: remove crate mp-mapping-sync
- fix(rpc): get_nonce
- fix(rpc): get_class
- refactor: mapping db
Expand Down
29 changes: 1 addition & 28 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ members = [
"crates/client/db",
"crates/client/sync",
"crates/client/genesis-data-provider",
"crates/client/mapping-sync",
"crates/client/rpc",
"crates/node",
"crates/pallets/starknet",
Expand All @@ -27,7 +26,6 @@ resolver = "2"
default-members = [
"crates/client/db",
"crates/client/genesis-data-provider",
"crates/client/mapping-sync",
"crates/client/rpc",
"crates/node",
"crates/pallets/starknet",
Expand Down Expand Up @@ -234,7 +232,6 @@ mp-types = { path = "crates/primitives/types", default-features = false }
# Deoxys client
mc-db = { path = "crates/client/db" }
mc-genesis-data-provider = { path = "crates/client/genesis-data-provider" }
mc-mapping-sync = { path = "crates/client/mapping-sync" }
mc-rpc = { path = "crates/client/rpc" }
mc-sync = { path = "crates/client/sync", default-features = false }

Expand Down
19 changes: 19 additions & 0 deletions crates/client/db/src/storage_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;

use mp_convert::field_element::FromFieldElement;
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use sp_core::H256;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey};
use starknet_api::hash::StarkFelt;
use starknet_api::state::StorageKey;
Expand All @@ -13,7 +14,9 @@ use storage_handler::primitives::contract_class::{
ClassUpdateWrapper, ContractClassData, ContractClassWrapper, StorageContractClassData,
};

use crate::mapping_db::MappingCommitment;
use crate::storage_handler::{self, DeoxysStorageError, StorageViewMut};
use crate::{DbError, DeoxysBackend};

pub async fn store_state_update(block_number: u64, state_update: StateUpdate) -> Result<(), DeoxysStorageError> {
let state_diff = state_update.state_diff.clone();
Expand Down Expand Up @@ -142,3 +145,19 @@ pub async fn store_key_update(

Ok(())
}

pub async fn store_mapping(
block_number: u64,
starknet_block_hash: StarkFelt,
substrate_block_hash: H256,
starknet_transaction_hashes: Vec<StarkFelt>,
) -> Result<(), DbError> {
let mapping_commitment = MappingCommitment {
block_number,
block_hash: substrate_block_hash,
starknet_block_hash,
starknet_transaction_hashes,
};

DeoxysBackend::mapping().write_hashes(mapping_commitment)
}
37 changes: 0 additions & 37 deletions crates/client/mapping-sync/Cargo.toml

This file was deleted.

135 changes: 0 additions & 135 deletions crates/client/mapping-sync/src/lib.rs

This file was deleted.

Loading

0 comments on commit a914cd4

Please sign in to comment.