Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
73d640a4a033f0c865d45da470ef40c1fb03a844
7ff9b71d8d87fc93ae7dbd8ba63f5176b0cd17be
12 changes: 6 additions & 6 deletions acvm-repo/acvm/src/compiler/optimizers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::circuit::{Circuit, Opcode};

mod constant_backpropagation;
// mod constant_backpropagation;
mod general;
mod redundant_range;
mod unused_memory;
Expand All @@ -9,7 +9,7 @@ pub(crate) use general::GeneralOptimizer;
pub(crate) use redundant_range::RangeOptimizer;
use tracing::info;

use self::constant_backpropagation::ConstantBackpropagationOptimizer;
// use self::constant_backpropagation::ConstantBackpropagationOptimizer;
use self::unused_memory::UnusedMemoryOptimizer;

use super::{transform_assert_messages, AcirTransformationMap};
Expand Down Expand Up @@ -58,16 +58,16 @@ pub(super) fn optimize_internal(acir: Circuit) -> (Circuit, Vec<usize>) {
let (acir, acir_opcode_positions) =
memory_optimizer.remove_unused_memory_initializations(acir_opcode_positions);

let (acir, acir_opcode_positions) =
ConstantBackpropagationOptimizer::backpropagate_constants(acir, acir_opcode_positions);
// let (acir, acir_opcode_positions) =
// ConstantBackpropagationOptimizer::backpropagate_constants(acir, acir_opcode_positions);

// Range optimization pass
let range_optimizer = RangeOptimizer::new(acir);
let (acir, acir_opcode_positions) =
range_optimizer.replace_redundant_ranges(acir_opcode_positions);

let (acir, acir_opcode_positions) =
ConstantBackpropagationOptimizer::backpropagate_constants(acir, acir_opcode_positions);
// let (acir, acir_opcode_positions) =
// ConstantBackpropagationOptimizer::backpropagate_constants(acir, acir_opcode_positions);

info!("Number of opcodes after: {}", acir.opcodes.len());

Expand Down
30 changes: 6 additions & 24 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ fn transform_module(
is_internal = true;
} else if is_custom_attribute(&secondary_attribute, "aztec(public)") {
is_public = true;
insert_init_check = false;
} else if is_custom_attribute(&secondary_attribute, "aztec(public-vm)") {
is_public_vm = true;
}
Expand Down Expand Up @@ -673,15 +672,6 @@ fn transform_function(

// Add initialization check
if insert_init_check {
if ty == "Public" {
let error = AztecMacroError::UnsupportedAttributes {
span: func.def.name.span(),
secondary_message: Some(
"public functions do not yet support initialization check".to_owned(),
),
};
return Err(error);
}
let init_check = create_init_check();
func.def.body.0.insert(0, init_check);
}
Expand Down Expand Up @@ -711,16 +701,7 @@ fn transform_function(

// Before returning mark the contract as initialized
if is_initializer {
if ty == "Public" {
let error = AztecMacroError::UnsupportedAttributes {
span: func.def.name.span(),
secondary_message: Some(
"public functions cannot yet be used as initializers".to_owned(),
),
};
return Err(error);
}
let mark_initialized = create_mark_as_initialized();
let mark_initialized = create_mark_as_initialized(ty);
func.def.body.0.push(mark_initialized);
}

Expand Down Expand Up @@ -1179,9 +1160,10 @@ fn create_init_check() -> Statement {
/// ```noir
/// mark_as_initialized(&mut context);
/// ```
fn create_mark_as_initialized() -> Statement {
fn create_mark_as_initialized(ty: &str) -> Statement {
let name = if ty == "Public" { "mark_as_initialized_public" } else { "mark_as_initialized" };
make_statement(StatementKind::Expression(call(
variable_path(chained_dep!("aztec", "initializer", "mark_as_initialized")),
variable_path(chained_dep!("aztec", "initializer", name)),
vec![mutable_reference("context")],
)))
}
Expand Down Expand Up @@ -1373,13 +1355,13 @@ fn create_avm_context() -> Result<Statement, AztecMacroError> {
/// Any primitive type that can be cast will be casted to a field and pushed to the context.
fn abstract_return_values(func: &NoirFunction) -> Option<Statement> {
let current_return_type = func.return_type().typ;
let last_statement = func.def.body.0.last();
let last_statement = func.def.body.0.last()?;

// TODO: (length, type) => We can limit the size of the array returned to be limited by kernel size
// Doesn't need done until we have settled on a kernel size
// TODO: support tuples here and in inputs -> convert into an issue
// Check if the return type is an expression, if it is, we can handle it
match last_statement? {
match last_statement {
Statement { kind: StatementKind::Expression(expression), .. } => {
match current_return_type {
// Call serialize on structs, push the whole array, calling push_array
Expand Down
2 changes: 1 addition & 1 deletion noir_stdlib/src/sha512.nr
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn digest<N>(msg: [u8; N]) -> [u8; 64] {
msg_block[i as Field] = 0;
i += 1;
} else if i < 128 {
let mut len = 8 * msg.len(); // u128 unsupported
let mut len = 8 * msg.len();
for j in 0..16 {
msg_block[127 - j] = len as u8;
len >>= 8;
Expand Down