Skip to content

Commit d165ac9

Browse files
feat: add support for versioned constants in Orchestrator (#852)
Co-authored-by: apoorvsadana <[email protected]>
1 parent f1316f8 commit d165ac9

File tree

7 files changed

+49
-10
lines changed

7 files changed

+49
-10
lines changed

.github/workflows/task-lint-cargo.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ jobs:
3333
run: yes | make artifacts
3434

3535
- name: Cargo fmt
36-
run: cargo fmt -- --check
36+
run: |
37+
cargo fmt -- --check
38+
39+
# TODO(mehul 21/11/2025, hotfix): This is a temporary fix to ensure that the madara is fmt checked.
40+
# Madara does not belong to the toplevel workspace, so we need to lint it separately.
41+
# Remove this once we add madara back to toplevel workspace.
42+
cd madara
43+
cargo fmt -- --check
3744
3845
- name: Python Cairo setup (before clippy)
3946
uses: ./.github/actions/setup-python-cairo

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ strum = "0.26.3"
302302
async-std = { version = "1.13.0", features = ["attributes"] }
303303
majin-blob-core = { git = "https://github.com/AbdelStark/majin-blob", branch = "main" }
304304
majin-blob-types = { git = "https://github.com/AbdelStark/majin-blob", branch = "main" }
305-
generate-pie = { git = "https://github.com/keep-starknet-strange/snos", tag = "v0.14.0-alpha.1" }
305+
generate-pie = { git = "https://github.com/keep-starknet-strange/snos", tag = "v0.14.0-alpha.2" }
306306

307307
orchestrator-da-client-interface = { path = "orchestrator/crates/da-clients/da-client-interface" }
308308
orchestrator-ethereum-da-client = { path = "orchestrator/crates/da-clients/ethereum" }

orchestrator/src/cli/snos.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
use std::path::PathBuf;
2+
3+
use blockifier::blockifier_versioned_constants::VersionedConstants;
14
use clap::Args;
25
use url::Url;
36

47
// Getting the default fee token addresses from the SNOS
58
use generate_pie::constants::{DEFAULT_SEPOLIA_ETH_FEE_TOKEN, DEFAULT_SEPOLIA_STRK_FEE_TOKEN};
69

10+
fn parse_constants(path: &str) -> Result<VersionedConstants, String> {
11+
let path_buf = PathBuf::from(path);
12+
tracing::debug!(file_path = %path_buf.display(), "Loading versioned constants from file");
13+
VersionedConstants::from_path(&path_buf).map_err(|e| format!("Failed to load versioned constants from file: {}", e))
14+
}
15+
716
#[derive(Debug, Clone, Args)]
817
#[group(requires_all = ["rpc_for_snos"])]
918
pub struct SNOSCliArgs {
@@ -22,4 +31,10 @@ pub struct SNOSCliArgs {
2231
/// Address of ETH native fee token
2332
#[arg(env = "MADARA_ORCHESTRATOR_ETH_NATIVE_FEE_TOKEN_ADDRESS", long, required = false, default_value = DEFAULT_SEPOLIA_ETH_FEE_TOKEN)]
2433
pub eth_fee_token_address: String,
34+
35+
/// Path to a JSON file containing versioned constants to override the default Starknet constants.
36+
/// By default, versioned constants are picked from the official Starknet constants loaded in blockifier.
37+
/// Use this argument to override those defaults with custom versioned constants from a file.
38+
#[arg(env = "MADARA_ORCHESTRATOR_VERSIONED_CONSTANTS_PATH", long, required = false, value_parser = parse_constants)]
39+
pub versioned_constants: Option<VersionedConstants>,
2540
}

orchestrator/src/tests/config.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
use std::net::SocketAddr;
2-
use std::str::FromStr as _;
3-
use std::sync::Arc;
4-
51
use crate::core::client::database::MockDatabaseClient;
62
use crate::core::client::lock::{LockClient, MockLockClient};
73
use crate::core::client::queue::MockQueueClient;
@@ -27,6 +23,7 @@ use crate::types::Layer;
2723
use crate::utils::rest_client::RestClient;
2824
use alloy::primitives::Address;
2925
use axum::Router;
26+
use blockifier::blockifier_versioned_constants::VersionedConstants;
3027
use blockifier::bouncer::BouncerWeights;
3128
use cairo_vm::types::layout_name::LayoutName;
3229
use generate_pie::constants::{DEFAULT_SEPOLIA_ETH_FEE_TOKEN, DEFAULT_SEPOLIA_STRK_FEE_TOKEN};
@@ -42,6 +39,10 @@ use orchestrator_utils::env_utils::{
4239
};
4340
use starknet::providers::jsonrpc::HttpTransport;
4441
use starknet::providers::JsonRpcClient;
42+
use std::net::SocketAddr;
43+
use std::path::PathBuf;
44+
use std::str::FromStr as _;
45+
use std::sync::Arc;
4546
use url::Url;
4647
use uuid::Uuid;
4748
// Inspiration : https://rust-unofficial.github.io/patterns/patterns/creational/builder.html
@@ -713,6 +714,14 @@ pub(crate) fn get_env_params(test_id: Option<&str>) -> EnvParams {
713714
.expect("Invalid max gas price mul factor"),
714715
});
715716

717+
let versioned_constants_path = get_env_var_optional("MADARA_ORCHESTRATOR_VERSIONED_CONSTANTS_PATH")
718+
.expect("Couldn't get versioned constants path")
719+
.map(PathBuf::from);
720+
721+
let versioned_constants = versioned_constants_path
722+
.as_ref()
723+
.map(|path| VersionedConstants::from_path(path).expect("Invalid versioned constant file"));
724+
716725
let snos_config = SNOSParams {
717726
rpc_for_snos: Url::parse(&get_env_var_or_panic("MADARA_ORCHESTRATOR_RPC_FOR_SNOS"))
718727
.expect("Failed to parse MADARA_ORCHESTRATOR_RPC_FOR_SNOS"),
@@ -725,6 +734,7 @@ pub(crate) fn get_env_params(test_id: Option<&str>) -> EnvParams {
725734
"MADARA_ORCHESTRATOR_ETH_NATIVE_FEE_TOKEN_ADDRESS",
726735
DEFAULT_SEPOLIA_ETH_FEE_TOKEN,
727736
),
737+
versioned_constants,
728738
};
729739

730740
let max_num_blobs = get_env_var_or_default("MADARA_ORCHESTRATOR_MAX_NUM_BLOBS", "6").parse::<usize>().unwrap();

orchestrator/src/types/params/snos.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::cli::snos::SNOSCliArgs;
2+
use blockifier::blockifier_versioned_constants::VersionedConstants;
23
use url::Url;
34

45
#[derive(Debug, Clone)]
@@ -7,6 +8,7 @@ pub struct SNOSParams {
78
pub snos_full_output: bool,
89
pub strk_fee_token_address: String,
910
pub eth_fee_token_address: String,
11+
pub versioned_constants: Option<VersionedConstants>,
1012
}
1113

1214
impl From<SNOSCliArgs> for SNOSParams {
@@ -16,6 +18,7 @@ impl From<SNOSCliArgs> for SNOSParams {
1618
snos_full_output: args.snos_full_output,
1719
strk_fee_token_address: args.strk_fee_token_address,
1820
eth_fee_token_address: args.eth_fee_token_address,
21+
versioned_constants: args.versioned_constants,
1922
}
2023
}
2124
}

orchestrator/src/worker/event_handler/jobs/snos.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl OsHintsConfigurationFromLayer for OsHintsConfiguration {
7676
fn with_layer(layer: Layer) -> OsHintsConfiguration {
7777
match layer {
7878
Layer::L2 => OsHintsConfiguration { debug_mode: true, full_output: true, use_kzg_da: false },
79-
Layer::L3 => OsHintsConfiguration { debug_mode: true, full_output: false, use_kzg_da: false },
79+
Layer::L3 => OsHintsConfiguration { debug_mode: true, full_output: false, use_kzg_da: true },
8080
}
8181
}
8282
}
@@ -110,6 +110,9 @@ impl JobHandlerTrait for SnosJobHandler {
110110
let snos_url = snos_url.trim_end_matches('/');
111111
debug!("Calling generate_pie function");
112112

113+
// Use pre-loaded versioned constants from config (loaded at startup)
114+
let versioned_constants = config.snos_config().versioned_constants.clone();
115+
113116
let input = PieGenerationInput {
114117
rpc_url: snos_url.to_string(),
115118
blocks: (start_block_number..=end_block_number).collect(),
@@ -125,6 +128,7 @@ impl JobHandlerTrait for SnosJobHandler {
125128
os_hints_config: OsHintsConfiguration::with_layer(config.layer().clone()),
126129
output_path: None, // No file output
127130
layout: config.params.snos_layout_name,
131+
versioned_constants,
128132
};
129133

130134
let snos_output: PieGenerationResult = generate_pie(input).await.map_err(|e| {

0 commit comments

Comments
 (0)