Skip to content

Commit 697c2c1

Browse files
committed
Merge branch 'main' of github.com:toolCHAINZ/crackers into ablation_a
2 parents b3373dd + 697a210 commit 697c2c1

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/bin/crackers/main.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,23 @@ fn synthesize(config: PathBuf) -> anyhow::Result<()> {
121121
.with(tracing_subscriber::fmt::layer().with_writer(writer))
122122
.init();
123123
let params = p.resolve()?;
124-
125-
match params.build_combined(&z3) {
126-
Ok(mut p) => match p.decide() {
127-
Ok(res) => match res {
128-
DecisionResult::AssignmentFound(a) => {
129-
event!(Level::INFO, "Synthesis successful :)");
130-
println!("{}", a)
131-
}
132-
DecisionResult::Unsat(a) => {
133-
event!(Level::ERROR, "Synthesis unsuccessful: {:?}", a);
134-
}
135-
},
136-
Err(e) => {
137-
event!(Level::ERROR, "Synthesis error: {}", e)
124+
let result = match params.combine_instructions{
125+
true => params.build_combined(&z3).and_then(|mut c|c.decide()),
126+
false => params.build_single(&z3).and_then(|mut c| c.decide())
127+
};
128+
match result {
129+
Ok(res) => match res {
130+
DecisionResult::AssignmentFound(a) => {
131+
event!(Level::INFO, "Synthesis successful :)");
132+
println!("{}", a)
133+
}
134+
DecisionResult::Unsat(a) => {
135+
event!(Level::ERROR, "Synthesis unsuccessful: {:?}", a);
138136
}
139137
},
140138
Err(e) => {
141-
event!(Level::ERROR, "Error setting up synthesis: {}", e)
139+
event!(Level::ERROR, "Synthesis error: {}", e)
142140
}
143-
};
141+
}
144142
Ok(())
145143
}

src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl CrackersConfig {
4141
.seed(self.meta.seed)
4242
.instructions(self.specification.get_spec(&self.sleigh)?);
4343
b.selection_strategy(self.synthesis.strategy);
44+
b.combine_instructions(self.synthesis.combine_instructions);
4445
b.candidates_per_slot(self.synthesis.max_candidates_per_slot);
4546
b.parallel(self.synthesis.parallel).seed(self.meta.seed);
4647

src/config/synthesis.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub struct SynthesisConfig {
77
pub strategy: SynthesisSelectionStrategy,
88
pub max_candidates_per_slot: usize,
99
pub parallel: usize,
10+
pub combine_instructions: bool
1011
}
1112

1213
impl Default for SynthesisConfig {
@@ -15,6 +16,7 @@ impl Default for SynthesisConfig {
1516
strategy: SynthesisSelectionStrategy::OptimizeStrategy,
1617
max_candidates_per_slot: 50,
1718
parallel: 4,
19+
combine_instructions: true
1820
}
1921
}
2022
}

src/synthesis/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub enum Library {
3939
#[derive(Clone, Builder)]
4040
pub struct SynthesisParams {
4141
pub seed: i64,
42+
#[builder(default)]
43+
pub combine_instructions: bool,
4244
pub selection_strategy: SynthesisSelectionStrategy,
4345
#[builder(setter(custom))]
4446
pub gadget_library: Arc<GadgetLibrary>,

0 commit comments

Comments
 (0)