-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(starknet_gateway): create sync state reader infra with todos
- Loading branch information
1 parent
32e130d
commit 0f4bcbd
Showing
5 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use blockifier::execution::contract_class::RunnableCompiledClass; | ||
use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; | ||
use starknet_api::block::{BlockInfo, BlockNumber}; | ||
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; | ||
use starknet_api::state::StorageKey; | ||
use starknet_state_sync_types::communication::SharedStateSyncClient; | ||
use starknet_types_core::felt::Felt; | ||
|
||
use crate::state_reader::{MempoolStateReader, StateReaderFactory}; | ||
|
||
#[allow(dead_code)] | ||
struct SyncStateReader { | ||
block_number: BlockNumber, | ||
shared_state_sync_client: SharedStateSyncClient, | ||
} | ||
|
||
impl SyncStateReader { | ||
pub fn from_number( | ||
shared_state_sync_client: &SharedStateSyncClient, | ||
block_number: BlockNumber, | ||
) -> Self { | ||
Self { shared_state_sync_client: shared_state_sync_client.clone(), block_number } | ||
} | ||
} | ||
|
||
impl MempoolStateReader for SyncStateReader { | ||
fn get_block_info(&self) -> StateResult<BlockInfo> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl BlockifierStateReader for SyncStateReader { | ||
fn get_storage_at( | ||
&self, | ||
_contract_address: ContractAddress, | ||
_key: StorageKey, | ||
) -> StateResult<Felt> { | ||
todo!() | ||
} | ||
|
||
fn get_nonce_at(&self, _contract_address: ContractAddress) -> StateResult<Nonce> { | ||
todo!() | ||
} | ||
|
||
fn get_compiled_class(&self, _class_hash: ClassHash) -> StateResult<RunnableCompiledClass> { | ||
todo!() | ||
} | ||
|
||
fn get_class_hash_at(&self, _contract_address: ContractAddress) -> StateResult<ClassHash> { | ||
todo!() | ||
} | ||
|
||
fn get_compiled_class_hash(&self, _class_hash: ClassHash) -> StateResult<CompiledClassHash> { | ||
todo!() | ||
} | ||
} | ||
|
||
pub struct SyncStateReaderFactory { | ||
pub shared_state_sync_client: SharedStateSyncClient, | ||
} | ||
|
||
impl StateReaderFactory for SyncStateReaderFactory { | ||
// TODO(noamsp): Decide if we need this | ||
fn get_state_reader_from_latest_block(&self) -> Box<dyn MempoolStateReader> { | ||
todo!() | ||
} | ||
|
||
fn get_state_reader(&self, block_number: BlockNumber) -> Box<dyn MempoolStateReader> { | ||
Box::new(SyncStateReader::from_number(&self.shared_state_sync_client, block_number)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters