Skip to content

Commit

Permalink
Add redeposit gas flag to root database builder (#6491)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Oct 15, 2024
1 parent 65d3246 commit 7cfecf3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 12 additions & 0 deletions crates/cairo-lang-compiler/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub struct RootDatabaseBuilder {
plugin_suite: PluginSuite,
detect_corelib: bool,
auto_withdraw_gas: bool,
add_redeposit_gas: bool,
project_config: Option<Box<ProjectConfig>>,
cfg_set: Option<CfgSet>,
inlining_strategy: InliningStrategy,
Expand All @@ -100,6 +101,7 @@ impl RootDatabaseBuilder {
plugin_suite: get_default_plugin_suite(),
detect_corelib: false,
auto_withdraw_gas: true,
add_redeposit_gas: false,
project_config: None,
cfg_set: None,
inlining_strategy: InliningStrategy::Default,
Expand All @@ -121,6 +123,11 @@ impl RootDatabaseBuilder {
self
}

pub fn with_add_redeposit_gas(&mut self) -> &mut Self {
self.add_redeposit_gas = true;
self
}

pub fn detect_corelib(&mut self) -> &mut Self {
self.detect_corelib = true;
self
Expand Down Expand Up @@ -168,6 +175,11 @@ impl RootDatabaseBuilder {
add_withdraw_gas_flag_id,
Some(Arc::new(Flag::AddWithdrawGas(self.auto_withdraw_gas))),
);
let add_redeposit_gas_flag_id = FlagId::new(db.upcast(), "add_redeposit_gas");
db.set_flag(
add_redeposit_gas_flag_id,
Some(Arc::new(Flag::AddRedepositGas(self.add_redeposit_gas))),
);

if let Some(config) = &self.project_config {
update_crate_roots_from_project_config(&mut db, config.as_ref());
Expand Down
9 changes: 3 additions & 6 deletions crates/cairo-lang-test-runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::sync::Mutex;
use std::vec::IntoIter;

use anyhow::{Context, Result, bail};
use cairo_lang_compiler::db::RootDatabase;
use cairo_lang_compiler::diagnostics::DiagnosticsReporter;
use cairo_lang_compiler::project::setup_project;
use cairo_lang_filesystem::cfg::{Cfg, CfgSet};
use cairo_lang_filesystem::db::FilesGroupEx;
use cairo_lang_filesystem::flag::Flag;
use cairo_lang_filesystem::ids::{CrateId, FlagId};
use cairo_lang_filesystem::ids::CrateId;
use cairo_lang_runner::casm_run::format_next_item;
use cairo_lang_runner::profiling::{
ProfilingInfo, ProfilingInfoProcessor, ProfilingInfoProcessorParams,
Expand Down Expand Up @@ -235,13 +233,12 @@ impl TestCompiler {
b.detect_corelib();
b.with_cfg(CfgSet::from_iter([Cfg::name("test"), Cfg::kv("target", "test")]));
b.with_plugin_suite(test_plugin_suite());
b.with_add_redeposit_gas();
if config.starknet {
b.with_plugin_suite(starknet_plugin_suite());
}
b.build()?
};
let add_redeposit_gas_flag_id = FlagId::new(db, "add_redeposit_gas");
db.set_flag(add_redeposit_gas_flag_id, Some(Arc::new(Flag::AddRedepositGas(true))));

let main_crate_ids = setup_project(db, Path::new(&path))?;

Expand Down

0 comments on commit 7cfecf3

Please sign in to comment.