Skip to content

Commit 2128dc4

Browse files
starknet_os_runner: class provider
1 parent 29a4c1b commit 2128dc4

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/starknet_os_runner/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ starknet-types-core.workspace = true
1616
starknet_api.workspace = true
1717
starknet_os.workspace = true
1818
starknet_patricia.workspace = true
19+
cairo-lang-starknet-classes.workspace = true
1920
thiserror.workspace = true
2021
tokio.workspace = true
2122
url.workspace = true
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use std::collections::{BTreeMap, HashMap, HashSet};
2+
3+
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
4+
use starknet_api::core::{ClassHash, CompiledClassHash};
5+
use starknet_api::deprecated_contract_class::ContractClass;
6+
7+
use crate::errors::ClassesProviderError;
8+
9+
/// The classes required for a Starknet OS run.
10+
/// Matches the fields in `StarknetOsInput` and `OsBlockInput`.
11+
pub struct ClassesInput {
12+
/// Deprecated (Cairo 0) contract classes.
13+
/// Maps ClassHash to the contract class definition.
14+
pub deprecated_compiled_classes: BTreeMap<ClassHash, ContractClass>,
15+
/// Cairo 1+ contract classes (CASM).
16+
/// Maps CompiledClassHash to the CASM contract class definition.
17+
pub compiled_classes: BTreeMap<CompiledClassHash, CasmContractClass>,
18+
}
19+
20+
pub trait ClassesProvider {
21+
/// Fetches all classes required for the OS run based on the executed class hashes.
22+
fn get_classes(
23+
&self,
24+
executed_class_hashes: HashSet<ClassHash>,
25+
) -> Result<ClassesInput, ClassesProviderError>;
26+
}

crates/starknet_os_runner/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ pub enum ProofProviderError {
2323
#[error("RPC provider error: {0}")]
2424
Rpc(#[from] ProviderError),
2525
}
26+
27+
#[derive(Debug, Error)]
28+
pub enum ClassesProviderError {
29+
#[error("Failed to get classes: {0}")]
30+
GetClassesError(String),
31+
}

crates/starknet_os_runner/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod classes_provider;
12
pub mod errors;
23
pub mod storage_proofs;
34
pub mod virtual_block_executor;

0 commit comments

Comments
 (0)