Skip to content

Commit

Permalink
git subrepo pull (merge) noir
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "noir"
  merged:   "727473cb5"
upstream:
  origin:   "https://github.com/noir-lang/noir"
  branch:   "aztec-packages"
  commit:   "727473cb5"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"
  • Loading branch information
sirasistant committed Jan 22, 2024
1 parent 7c07665 commit 98a7fb9
Show file tree
Hide file tree
Showing 56 changed files with 512 additions and 1,276 deletions.
2 changes: 1 addition & 1 deletion noir/.github/workflows/docs-dead-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: ${{ github.workflow }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/DEAD_LINKS_IN_DOCS.md
4 changes: 2 additions & 2 deletions noir/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/noir-lang/noir
branch = aztec-packages
commit = 13f93d523342daf478e08e8ccc0f00962c7fbe05
parent = 41ae75cdee6285729551965972e8cb039ff3045a
commit = 727473cb5268d85cc524a9f4662cf8a7d5bd8996
parent = 7c076653169771223a378f6c01bd9d3e3aafb682
method = merge
cmdver = 0.4.6
71 changes: 46 additions & 25 deletions noir/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 29 additions & 12 deletions noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum AztecMacroError {
AztecComputeNoteHashAndNullifierNotFound { span: Span },
AztecContractHasTooManyFunctions { span: Span },
AztecContractConstructorMissing { span: Span },
UnsupportedFunctionArgumentType { span: Span, typ: UnresolvedTypeData },
}

impl From<AztecMacroError> for MacroError {
Expand All @@ -65,6 +66,11 @@ impl From<AztecMacroError> for MacroError {
secondary_message: None,
span: Some(span),
},
AztecMacroError::UnsupportedFunctionArgumentType { span, typ } => MacroError {
primary_message: format!("Provided parameter type `{typ:?}` is not supported in Aztec contract interface"),
secondary_message: None,
span: Some(span),
},
}
}
}
Expand Down Expand Up @@ -341,11 +347,14 @@ fn transform_module(

for func in module.functions.iter_mut() {
for secondary_attribute in func.def.attributes.secondary.clone() {
let crate_graph = &context.crate_graph[crate_id];
if is_custom_attribute(&secondary_attribute, "aztec(private)") {
transform_function("Private", func, storage_defined);
transform_function("Private", func, storage_defined)
.map_err(|err| (err.into(), crate_graph.root_file_id))?;
has_transformed_module = true;
} else if is_custom_attribute(&secondary_attribute, "aztec(public)") {
transform_function("Public", func, storage_defined);
transform_function("Public", func, storage_defined)
.map_err(|err| (err.into(), crate_graph.root_file_id))?;
has_transformed_module = true;
}
}
Expand Down Expand Up @@ -384,7 +393,11 @@ fn transform_module(
/// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs
/// - Hashes all of the function input variables
/// - This instantiates a helper function
fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool) {
fn transform_function(
ty: &str,
func: &mut NoirFunction,
storage_defined: bool,
) -> Result<(), AztecMacroError> {
let context_name = format!("{}Context", ty);
let inputs_name = format!("{}ContextInputs", ty);
let return_type_name = format!("{}CircuitPublicInputs", ty);
Expand All @@ -396,7 +409,7 @@ fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool)
}

// Insert the context creation as the first action
let create_context = create_context(&context_name, &func.def.parameters);
let create_context = create_context(&context_name, &func.def.parameters)?;
func.def.body.0.splice(0..0, (create_context).iter().cloned());

// Add the inputs to the params
Expand All @@ -423,6 +436,8 @@ fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool)
"Public" => func.def.is_open = true,
_ => (),
}

Ok(())
}

/// Transform Unconstrained
Expand Down Expand Up @@ -621,7 +636,7 @@ fn create_inputs(ty: &str) -> Param {
/// let mut context = PrivateContext::new(inputs, hasher.hash());
/// }
/// ```
fn create_context(ty: &str, params: &[Param]) -> Vec<Statement> {
fn create_context(ty: &str, params: &[Param]) -> Result<Vec<Statement>, AztecMacroError> {
let mut injected_expressions: Vec<Statement> = vec![];

// `let mut hasher = Hasher::new();`
Expand All @@ -637,7 +652,7 @@ fn create_context(ty: &str, params: &[Param]) -> Vec<Statement> {
injected_expressions.push(let_hasher);

// Iterate over each of the function parameters, adding to them to the hasher
params.iter().for_each(|Param { pattern, typ, span: _, visibility: _ }| {
for Param { pattern, typ, span, .. } in params {
match pattern {
Pattern::Identifier(identifier) => {
// Match the type to determine the padding to do
Expand Down Expand Up @@ -666,16 +681,18 @@ fn create_context(ty: &str, params: &[Param]) -> Vec<Statement> {
},
)
}
_ => panic!(
"[Aztec Noir] Provided parameter type: {:?} is not supported",
unresolved_type
),
_ => {
return Err(AztecMacroError::UnsupportedFunctionArgumentType {
typ: unresolved_type.clone(),
span: *span,
})
}
};
injected_expressions.push(expression);
}
_ => todo!(), // Maybe unreachable?
}
});
}

// Create the inputs to the context
let inputs_expression = variable("inputs");
Expand All @@ -697,7 +714,7 @@ fn create_context(ty: &str, params: &[Param]) -> Vec<Statement> {
injected_expressions.push(let_context);

// Return all expressions that will be injected by the hasher
injected_expressions
Ok(injected_expressions)
}

/// Abstract Return Type
Expand Down
1 change: 1 addition & 0 deletions noir/bootstrap_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ echo -e "\033[1mRetrieving noir packages from remote cache...\033[0m"
extract_repo noir-packages /usr/src/noir/packages ./
echo -e "\033[1mRetrieving nargo from remote cache...\033[0m"
extract_repo noir /usr/src/noir/target/release ./target/

4 changes: 4 additions & 0 deletions noir/compiler/fm/src/file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ impl FileMap {
pub fn get_file_id(&self, file_name: &PathString) -> Option<FileId> {
self.name_to_id.get(file_name).cloned()
}

pub fn all_file_ids(&self) -> impl Iterator<Item = &FileId> {
self.name_to_id.values()
}
}
impl Default for FileMap {
fn default() -> Self {
Expand Down
Loading

0 comments on commit 98a7fb9

Please sign in to comment.