Skip to content

Commit

Permalink
chore: remove winter-crypto dependency from core/Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbinth committed Jan 5, 2024
1 parent 0e6f9c1 commit 8c17205
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 45 deletions.
16 changes: 8 additions & 8 deletions assembly/src/ast/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ fn test_missing_import() {

let result = ProgramAst::parse(source);
match result {
Ok(_) => assert!(false),
Ok(_) => panic!("should have panicked"),
Err(err) => assert!(err.to_string().contains("module 'u64' was not imported")),
}
}
Expand All @@ -497,7 +497,7 @@ fn test_use_in_proc_body() {

let result = ModuleAst::parse(source);
match result {
Ok(_) => assert!(false),
Ok(_) => panic!("should have panicked"),
Err(err) => assert!(err.to_string().contains("import in procedure body")),
}
}
Expand All @@ -508,7 +508,7 @@ fn test_unterminated_proc() {

let result = ModuleAst::parse(source);
match result {
Ok(_) => assert!(false),
Ok(_) => panic!("should have panicked"),
Err(err) => assert!(err.to_string().contains("procedure 'foo' has no matching end")),
}
}
Expand All @@ -519,7 +519,7 @@ fn test_unterminated_if() {

let result = ModuleAst::parse(source);
match result {
Ok(_) => assert!(false),
Ok(_) => panic!("should have panicked"),
Err(err) => assert!(err.to_string().contains("if without matching else/end")),
}
}
Expand Down Expand Up @@ -820,15 +820,15 @@ fn test_ast_program_serde_control_flow() {

#[test]
fn assert_parsing_line_unmatched_begin() {
let source = format!("\n\nbegin\npush.1.2\n\nadd mul");
let source = "\n\nbegin\npush.1.2\n\nadd mul".to_string();
let err = ProgramAst::parse(&source).err().unwrap();
let location = SourceLocation::new(3, 1);
assert_eq!(err, ParsingError::unmatched_begin(&Token::new("begin", location)));
}

#[test]
fn assert_parsing_line_extra_param() {
let source = format!("begin add.1.2\nend");
let source = "begin add.1.2\nend".to_string();
let err = ProgramAst::parse(&source).err().unwrap();
let location = SourceLocation::new(1, 7);
assert_eq!(err, ParsingError::extra_param(&Token::new("add.1.2", location)));
Expand Down Expand Up @@ -875,15 +875,15 @@ fn assert_parsing_line_invalid_op() {

#[test]
fn assert_parsing_line_unexpected_eof() {
let source = format!("proc.foo\nadd\nend");
let source = "proc.foo\nadd\nend".to_string();
let err = ProgramAst::parse(&source).err().unwrap();
let location = SourceLocation::new(3, 1);
assert_eq!(err, ParsingError::unexpected_eof(location));
}

#[test]
fn assert_parsing_line_unexpected_token() {
let source = format!("proc.foo\nadd\nend\n\nmul");
let source = "proc.foo\nadd\nend\n\nmul".to_string();
let err = ProgramAst::parse(&source).err().unwrap();
let location = SourceLocation::new(5, 1);
assert_eq!(err, ParsingError::unexpected_token(&Token::new("mul", location), "begin"));
Expand Down
2 changes: 1 addition & 1 deletion assembly/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ fn program_with_reexported_proc_in_same_library() {
let ast = ModuleAst::parse(MODULE_BODY).unwrap();

// check docs
let docs_checked_eqz = ast.reexported_procs().get(0).unwrap().docs().unwrap();
let docs_checked_eqz = ast.reexported_procs().first().unwrap().docs().unwrap();
assert_eq!(
docs_checked_eqz,
"checked_eqz checks if the value is u32 and zero and returns 1 if it is, 0 otherwise"
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ sve = ["miden-crypto/sve", "std"]
math = { package = "winter-math", version = "0.7", default-features = false }
# miden-crypto = { package = "miden-crypto", version = "0.8", default-features = false }
miden-crypto = { package = "miden-crypto", git = "https://github.com/0xPolygonMiden/crypto", branch= "next", default-features = false }
winter-crypto = { package = "winter-crypto", version = "0.7", default-features = false }
winter-utils = { package = "winter-utils", version = "0.7", default-features = false }

[dev-dependencies]
Expand Down
9 changes: 4 additions & 5 deletions miden/src/repl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ pub fn start_repl(library_paths: &Vec<PathBuf>, use_stdlib: bool) {
program_lines.pop();
}
}
} else {
if should_print_stack {
println!("{}", str::repeat("0 ", 16));
}
} else if should_print_stack {
println!("{}", str::repeat("0 ", 16));
}

match rl.readline(">> ") {
Ok(line) => {
if line == "!program" {
Expand Down Expand Up @@ -297,7 +296,7 @@ fn execute(
.with_libraries(provided_libraries.clone().into_iter())
.map_err(|err| format!("{err}"))?;

let program = assembler.compile(&program).map_err(|err| format!("{err}"))?;
let program = assembler.compile(program).map_err(|err| format!("{err}"))?;

let stack_inputs = StackInputs::default();
let host = DefaultHost::default();
Expand Down
8 changes: 4 additions & 4 deletions miden/tests/integration/operations/decorators/advice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fn advice_push_mapval() {
vec![Felt::new(8), Felt::new(7), Felt::new(6), Felt::new(5)],
)];

let test = build_test!(source, &stack_inputs, vec![], MerkleStore::default(), adv_map);
let test = build_test!(source, &stack_inputs, [], MerkleStore::default(), adv_map);
test.expect_stack(&[5, 6, 7, 8]);

// --- test adv.mapval with offset ----------------------------------------
Expand All @@ -220,7 +220,7 @@ fn advice_push_mapval() {
vec![Felt::new(8), Felt::new(7), Felt::new(6), Felt::new(5)],
)];

let test = build_test!(source, &stack_inputs, vec![], MerkleStore::default(), adv_map);
let test = build_test!(source, &stack_inputs, [], MerkleStore::default(), adv_map);
test.expect_stack(&[5, 6, 7, 8]);

// --- test simple adv.mapvaln --------------------------------------------
Expand All @@ -243,7 +243,7 @@ fn advice_push_mapval() {
vec![Felt::new(11), Felt::new(12), Felt::new(13), Felt::new(14), Felt::new(15)],
)];

let test = build_test!(source, &stack_inputs, vec![], MerkleStore::default(), adv_map);
let test = build_test!(source, &stack_inputs, [], MerkleStore::default(), adv_map);
test.expect_stack(&[15, 14, 13, 12, 11, 5]);

// --- test adv.mapval with offset ----------------------------------------
Expand All @@ -269,7 +269,7 @@ fn advice_push_mapval() {
vec![Felt::new(11), Felt::new(12), Felt::new(13), Felt::new(14), Felt::new(15)],
)];

let test = build_test!(source, &stack_inputs, vec![], MerkleStore::default(), adv_map);
let test = build_test!(source, &stack_inputs, [], MerkleStore::default(), adv_map);
test.expect_stack(&[15, 14, 13, 12, 11, 5]);
}

Expand Down
8 changes: 4 additions & 4 deletions processor/src/chiplets/hasher/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn hasher_build_merkle_root() {

// build a Merkle tree
let leaves = init_leaves(&[1, 2]);
let tree = MerkleTree::new(leaves.to_vec()).unwrap();
let tree = MerkleTree::new(&leaves).unwrap();

// initialize the hasher and perform two Merkle branch verifications
let mut hasher = Hasher::default();
Expand Down Expand Up @@ -186,7 +186,7 @@ fn hasher_build_merkle_root() {

// build a Merkle tree
let leaves = init_leaves(&[1, 2, 3, 4, 5, 6, 7, 8]);
let tree = MerkleTree::new(leaves.to_vec()).unwrap();
let tree = MerkleTree::new(&leaves).unwrap();

// initialize the hasher and perform one Merkle branch verifications
let mut hasher = Hasher::default();
Expand Down Expand Up @@ -347,7 +347,7 @@ fn hasher_update_merkle_root() {

// build a Merkle tree
let leaves = init_leaves(&[1, 2]);
let mut tree = MerkleTree::new(leaves.to_vec()).unwrap();
let mut tree = MerkleTree::new(&leaves).unwrap();

// initialize the hasher and update both leaves
let mut hasher = Hasher::default();
Expand Down Expand Up @@ -457,7 +457,7 @@ fn hasher_update_merkle_root() {

// build a Merkle tree
let leaves = init_leaves(&[1, 2, 3, 4, 5, 6, 7, 8]);
let mut tree = MerkleTree::new(leaves.to_vec()).unwrap();
let mut tree = MerkleTree::new(&leaves).unwrap();

// initialize the hasher
let mut hasher = Hasher::default();
Expand Down
2 changes: 1 addition & 1 deletion processor/src/chiplets/memory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn build_trace_row(
row[0] = op_selectors[0];
row[1] = op_selectors[1];
row[CTX_COL_IDX] = ctx;
row[ADDR_COL_IDX] = Felt::from(addr);
row[ADDR_COL_IDX] = addr;
row[CLK_COL_IDX] = clk;
row[V_COL_RANGE.start] = new_val[0];
row[V_COL_RANGE.start + 1] = new_val[1];
Expand Down
2 changes: 1 addition & 1 deletion processor/src/operations/crypto_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ mod tests {
fn op_mpverify() {
let index = 5usize;
let nodes = init_leaves(&[1, 2, 3, 4, 5, 6, 7, 8]);
let tree = MerkleTree::new(nodes.to_vec()).unwrap();
let tree = MerkleTree::new(&nodes).unwrap();
let store = MerkleStore::from(&tree);
let root = tree.root();
let node = nodes[index];
Expand Down
29 changes: 11 additions & 18 deletions processor/src/system/tests.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
#[cfg(test)]
mod tests {
use crate::{DefaultHost, ExecutionOptions, Kernel, Operation, Process, StackInputs};
use crate::{DefaultHost, ExecutionOptions, Kernel, Operation, Process, StackInputs};

// Check that process returns an error if a maximum number of cycles is exceeded.
#[test]
fn cycles_num_exceeded() {
let stack = StackInputs::default();
let host = DefaultHost::default();
let mut process = Process::new(
Kernel::default(),
stack,
host,
ExecutionOptions::new(Some(64), 64).unwrap(),
);
for _ in 0..64 {
process.execute_op(Operation::Noop).unwrap();
}
assert!(process.execute_op(Operation::Noop).is_err());
// Check that process returns an error if a maximum number of cycles is exceeded.
#[test]
fn cycles_num_exceeded() {
let stack = StackInputs::default();
let host = DefaultHost::default();
let mut process =
Process::new(Kernel::default(), stack, host, ExecutionOptions::new(Some(64), 64).unwrap());
for _ in 0..64 {
process.execute_op(Operation::Noop).unwrap();
}
assert!(process.execute_op(Operation::Noop).is_err());
}
2 changes: 1 addition & 1 deletion processor/src/trace/tests/chiplets/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub fn b_chip_permutation() {
fn b_chip_mpverify() {
let index = 5usize;
let leaves = init_leaves(&[1, 2, 3, 4, 5, 6, 7, 8]);
let tree = MerkleTree::new(leaves.to_vec()).unwrap();
let tree = MerkleTree::new(&leaves).unwrap();

let stack_inputs = [
tree.root()[0].as_int(),
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tests/crypto/fri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn prepare_advice_stack(
stack.extend_from_slice(&com[(4 * i)..(4 * i + 4)]);
stack.extend_from_slice(&alphas[(4 * i)..(4 * i + 2)]);
// - 2 is due to the fact that we are folding by 4
stack.extend_from_slice(&vec![current_depth - 2, current_domain_size]);
stack.extend_from_slice(&[current_depth - 2, current_domain_size]);
current_depth -= 2;
}

Expand Down

0 comments on commit 8c17205

Please sign in to comment.