-
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): initial API definition, execution helper (#3946)
- Loading branch information
1 parent
b0e1ed9
commit 88380d6
Showing
10 changed files
with
62 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum StarknetOsError {} |
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 @@ | ||
pub mod execution_helper; |
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,20 @@ | ||
use blockifier::state::cached_state::CachedState; | ||
use blockifier::state::state_api::StateReader; | ||
|
||
use crate::io::os_input::StarknetOsInput; | ||
|
||
/// A helper struct that provides access to the OS state and commitments. | ||
pub struct OsExecutionHelper<S: StateReader> { | ||
_cached_state: CachedState<S>, | ||
} | ||
|
||
impl<S: StateReader> OsExecutionHelper<S> { | ||
pub fn new(os_input: &StarknetOsInput) -> Self { | ||
Self { _cached_state: Self::initialize_cached_state(os_input) } | ||
} | ||
|
||
// TODO(Dori): Create a cached state with all initial read values from the OS input. | ||
fn initialize_cached_state(_os_input: &StarknetOsInput) -> CachedState<S> { | ||
todo!() | ||
} | ||
} |
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,2 @@ | ||
pub mod os_input; | ||
pub mod os_output; |
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,4 @@ | ||
/// All input needed to initialize the execution helper. | ||
// TODO(Dori): Add all fields needed to compute commitments, initialize a CachedState and other data | ||
// required by the execution helper. | ||
pub struct StarknetOsInput {} |
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,9 @@ | ||
use cairo_vm::vm::runners::cairo_pie::CairoPie; | ||
|
||
// TODO(Dori): Add fields. | ||
pub struct StarknetOsOutput {} | ||
|
||
pub struct StarknetOsRunnerOutput { | ||
pub os_output: StarknetOsOutput, | ||
pub cairo_pie: CairoPie, | ||
} |
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,5 @@ | ||
pub mod errors; | ||
pub mod hint_processor; | ||
pub mod hints; | ||
pub mod io; | ||
pub mod runner; |
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,18 @@ | ||
use blockifier::context::BlockContext; | ||
use blockifier::state::state_api::StateReader; | ||
use cairo_vm::types::layout_name::LayoutName; | ||
|
||
use crate::errors::StarknetOsError; | ||
use crate::hint_processor::execution_helper::OsExecutionHelper; | ||
use crate::io::os_input::StarknetOsInput; | ||
use crate::io::os_output::StarknetOsRunnerOutput; | ||
|
||
pub fn run_os<S: StateReader>( | ||
_compiled_os: &[u8], | ||
_layout: LayoutName, | ||
_block_context: BlockContext, | ||
os_input: &StarknetOsInput, | ||
) -> Result<StarknetOsRunnerOutput, StarknetOsError> { | ||
let _execution_helper = OsExecutionHelper::<S>::new(os_input); | ||
todo!() | ||
} |