-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(starknet_os): added PanickingStateReader and stateless OS runner…
… function (#3947)
- Loading branch information
1 parent
c9b798b
commit 1819f6e
Showing
5 changed files
with
50 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod execution_helper; | ||
pub mod panicking_state_reader; |
35 changes: 35 additions & 0 deletions
35
crates/starknet_os/src/hint_processor/panicking_state_reader.rs
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,35 @@ | ||
use blockifier::execution::contract_class::RunnableCompiledClass; | ||
use blockifier::state::state_api::{StateReader, StateResult}; | ||
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; | ||
use starknet_api::state::StorageKey; | ||
use starknet_types_core::felt::Felt; | ||
|
||
/// State reader that always panics. | ||
/// Use this as the `OsExecutionHelper`'s state reader to ensure the OS execution is "stateless". | ||
pub struct PanickingStateReader; | ||
|
||
impl StateReader for PanickingStateReader { | ||
fn get_storage_at( | ||
&self, | ||
contract_address: ContractAddress, | ||
key: StorageKey, | ||
) -> StateResult<Felt> { | ||
panic!("Called get_storage_at with address {contract_address} and key {key:?}."); | ||
} | ||
|
||
fn get_nonce_at(&self, contract_address: ContractAddress) -> StateResult<Nonce> { | ||
panic!("Called get_nonce_at with address {contract_address}."); | ||
} | ||
|
||
fn get_class_hash_at(&self, contract_address: ContractAddress) -> StateResult<ClassHash> { | ||
panic!("Called get_class_hash_at with address {contract_address}."); | ||
} | ||
|
||
fn get_compiled_class(&self, class_hash: ClassHash) -> StateResult<RunnableCompiledClass> { | ||
panic!("Called get_compiled_class with class hash {class_hash}."); | ||
} | ||
|
||
fn get_compiled_class_hash(&self, class_hash: ClassHash) -> StateResult<CompiledClassHash> { | ||
panic!("Called get_compiled_class_hash with class hash {class_hash}."); | ||
} | ||
} |
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