Skip to content

Commit 0d023bd

Browse files
committed
Merge branch 'main' of github.com:toolCHAINZ/crackers into ablation_b
2 parents ca8bd5d + 697a210 commit 0d023bd

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
@@ -120,25 +120,23 @@ fn synthesize(config: PathBuf) -> anyhow::Result<()> {
120120
.with(tracing_subscriber::fmt::layer().with_writer(writer))
121121
.init();
122122
let params = p.resolve()?;
123-
124-
match params.build_combined(&z3) {
125-
Ok(mut p) => match p.decide() {
126-
Ok(res) => match res {
127-
DecisionResult::AssignmentFound(a) => {
128-
event!(Level::INFO, "Synthesis successful :)");
129-
println!("{}", a)
130-
}
131-
DecisionResult::Unsat(a) => {
132-
event!(Level::ERROR, "Synthesis unsuccessful: {:?}", a);
133-
}
134-
},
135-
Err(e) => {
136-
event!(Level::ERROR, "Synthesis error: {}", e)
123+
let result = match params.combine_instructions{
124+
true => params.build_combined(&z3).and_then(|mut c|c.decide()),
125+
false => params.build_single(&z3).and_then(|mut c| c.decide())
126+
};
127+
match result {
128+
Ok(res) => match res {
129+
DecisionResult::AssignmentFound(a) => {
130+
event!(Level::INFO, "Synthesis successful :)");
131+
println!("{}", a)
132+
}
133+
DecisionResult::Unsat(a) => {
134+
event!(Level::ERROR, "Synthesis unsuccessful: {:?}", a);
137135
}
138136
},
139137
Err(e) => {
140-
event!(Level::ERROR, "Error setting up synthesis: {}", e)
138+
event!(Level::ERROR, "Synthesis error: {}", e)
141139
}
142-
};
140+
}
143141
Ok(())
144142
}

src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl CrackersConfig {
4040
b.gadget_library(library)
4141
.seed(self.meta.seed).slots(self.specification.max_instructions);
4242
b.selection_strategy(self.synthesis.strategy);
43+
b.combine_instructions(self.synthesis.combine_instructions);
4344
b.candidates_per_slot(self.synthesis.max_candidates_per_slot);
4445
b.parallel(self.synthesis.parallel).seed(self.meta.seed);
4546

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
@@ -38,6 +38,8 @@ pub enum Library {
3838
#[derive(Clone, Builder)]
3939
pub struct SynthesisParams {
4040
pub seed: i64,
41+
#[builder(default)]
42+
pub combine_instructions: bool,
4143
pub selection_strategy: SynthesisSelectionStrategy,
4244
#[builder(setter(custom))]
4345
pub gadget_library: Arc<GadgetLibrary>,

0 commit comments

Comments
 (0)